[lld] [LLD][COFF] Add support for custom DOS stub (PR #122561)
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 02:10:40 PST 2025
================
@@ -1035,6 +1036,17 @@ void Writer::sortSections() {
sortBySectionOrder(it.second->chunks);
}
+void Writer::calculateStubDependentSizes() {
+ if (ctx.config.dosStub)
+ dosStubSize = ctx.config.dosStub->getBufferSize();
+ else
+ dosStubSize = sizeof(dos_header) + sizeof(dosProgram);
+
+ coffHeaderOffset = dosStubSize + sizeof(PEMagic);
----------------
zmodem wrote:
Since the PEMagic needs to be 8-byte aligned, I think we need to round up dosStubSize here: `alignTo(dosStubSize, 8)`.
Also, we need to audit all the uses of dosStubSize. For example, `Writer::writePEChecksum()` uses dosStubSize to locate the coffHeader. It should use coffHeaderOffset instead.
https://github.com/llvm/llvm-project/pull/122561
More information about the llvm-commits
mailing list