summaryrefslogtreecommitdiff
path: root/lld/COFF/Chunks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF/Chunks.cpp')
-rw-r--r--lld/COFF/Chunks.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 0cae52785a00..2807c8945205 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -31,8 +31,8 @@ using llvm::support::ulittle32_t;
namespace lld::coff {
-SectionChunk::SectionChunk(ObjFile *f, const coff_section *h)
- : Chunk(SectionKind), file(f), header(h), repl(this) {
+SectionChunk::SectionChunk(ObjFile *f, const coff_section *h, Kind k)
+ : Chunk(k), file(f), header(h), repl(this) {
// Initialize relocs.
if (file)
setRelocs(file->getCOFFObj()->getRelocations(header));
@@ -410,6 +410,12 @@ void SectionChunk::writeTo(uint8_t *buf) const {
applyRelocation(buf + rel.VirtualAddress, rel);
}
+
+ // Write the offset to EC entry thunk preceding section contents. The low bit
+ // is always set, so it's effectively an offset from the last byte of the
+ // offset.
+ if (Defined *entryThunk = getEntryThunk())
+ write32le(buf - sizeof(uint32_t), entryThunk->getRVA() - rva + 1);
}
void SectionChunk::applyRelocation(uint8_t *off,