Skip to content

Commit 462c208

Browse files
authored
[LLD][COFF] Move entry thunk offset writing to writeSections (NFC) (#151254)
To make it easier to add entry thunks to other chunk types.
1 parent aac70d6 commit 462c208

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lld/COFF/Chunks.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,6 @@ void SectionChunk::writeTo(uint8_t *buf) const {
422422

423423
applyRelocation(buf + rel.VirtualAddress, rel);
424424
}
425-
426-
// Write the offset to EC entry thunk preceding section contents. The low bit
427-
// is always set, so it's effectively an offset from the last byte of the
428-
// offset.
429-
if (Defined *entryThunk = getEntryThunk())
430-
write32le(buf - sizeof(uint32_t), entryThunk->getRVA() - rva + 1);
431425
}
432426

433427
void SectionChunk::applyRelocation(uint8_t *off,

lld/COFF/Writer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,15 @@ void Writer::writeSections() {
25442544
}
25452545

25462546
parallelForEach(sec->chunks, [&](Chunk *c) {
2547-
c->writeTo(secBuf + c->getRVA() - sec->getRVA());
2547+
uint8_t *buf = secBuf + c->getRVA() - sec->getRVA();
2548+
c->writeTo(buf);
2549+
2550+
// Write the offset to EC entry thunk preceding section contents. The low
2551+
// bit is always set, so it's effectively an offset from the last byte of
2552+
// the offset.
2553+
if (Defined *entryThunk = c->getEntryThunk())
2554+
write32le(buf - sizeof(uint32_t),
2555+
entryThunk->getRVA() - c->getRVA() + 1);
25482556
});
25492557
}
25502558
}

0 commit comments

Comments
 (0)