[lld] 462c208 - [LLD][COFF] Move entry thunk offset writing to writeSections (NFC) (#151254)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 03:59:48 PDT 2025
Author: Jacek Caban
Date: 2025-07-31T12:59:44+02:00
New Revision: 462c2084c4eff2b6a50f7686d5b67d41526c8c29
URL: https://github.com/llvm/llvm-project/commit/462c2084c4eff2b6a50f7686d5b67d41526c8c29
DIFF: https://github.com/llvm/llvm-project/commit/462c2084c4eff2b6a50f7686d5b67d41526c8c29.diff
LOG: [LLD][COFF] Move entry thunk offset writing to writeSections (NFC) (#151254)
To make it easier to add entry thunks to other chunk types.
Added:
Modified:
lld/COFF/Chunks.cpp
lld/COFF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 01752cdc6a9da..4ba5d80b581ef 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -422,12 +422,6 @@ 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,
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 076561807af47..62019f19292a1 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -2544,7 +2544,15 @@ void Writer::writeSections() {
}
parallelForEach(sec->chunks, [&](Chunk *c) {
- c->writeTo(secBuf + c->getRVA() - sec->getRVA());
+ uint8_t *buf = secBuf + c->getRVA() - sec->getRVA();
+ c->writeTo(buf);
+
+ // 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 = c->getEntryThunk())
+ write32le(buf - sizeof(uint32_t),
+ entryThunk->getRVA() - c->getRVA() + 1);
});
}
}
More information about the llvm-commits
mailing list