[lld] [llvm] [LLD] [COFF] Fix linking import libraries with -wholearchive: (PR #122806)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 01:50:17 PST 2025


mstorsjo wrote:

> It seems that link.exe gives this error if there's no other object file defining the empty section. If we do add a separate object that adds a concrete definition of the section, even if it is entirely empty, linking succeeds - and we can observe that link.exe doesn't give these empty sections any extra alignment at all.

However, while I can get MS link.exe to link this example by adding such an extra object file, I note curiously that the value in the relocation ends up incorrect - it seems to set the address of the start of the whole `.idata` section, not the start of the `.idata$4` section chunk as intended. This happens both with the `IMAGE_REL_AMD64_ADDR64` relocation you used in your example yaml, and with `IMAGE_REL_AMD64_ADDR32NB` as the real import directory uses. That's weird...

https://github.com/llvm/llvm-project/pull/122806


More information about the llvm-commits mailing list