fix: error on R_X86_64_32/32S relocations in shared objects #2083
fix: error on R_X86_64_32/32S relocations in shared objects #2083deepakshirkem wants to merge 1 commit into
Conversation
| // Both GNU ld and lld error: recompile with -fPIC | ||
| //#Arch:x86_64 | ||
| //#LinkArgs:--no-gc-sections -shared | ||
| //#SkipLinker:ld |
There was a problem hiding this comment.
Could be good to enable ld (and possibly lld) for the test. If all linkers have "recompile with -fPIC" then you could have that as the error matcher. If you want to verify that Wild says the message below, then you could add "ExpectErrorWild" (implementing it should be pretty trivial - there's already an "ExpectWarningWild")
…ker#2074) R_X86_64_32 and R_X86_64_32S cannot be used when making a shared object because the dynamic linker has no way to patch 32-bit absolute relocations at runtime. Wild was silently emitting R_X86_64_64 instead of erroring, producing a broken shared object. Add an early check in apply_relocation to error when these relocation types are encountered while building a shared object, matching the behavior of GNU ld and lld. Also add ExpectErrorWild test directive (analogous to ExpectWarningWild) to allow testing Wild-specific error messages independently. Fixes wild-linker#2074
d188457 to
0d781f8
Compare
|
@davidlattimore, One question: should we extend this PR to also report an error for sub-pointer-size absolute relocations on other 64-bit architectures such as AArch64, RISC-V64, PPC64, and LoongArch64? |
|
That'd be great if you can make the check generic. It could also be good to look to see if the check can be done in the layout phase rather than the write phase. That said, it's OK if it stays in the write phase. |
R_X86_64_32 and R_X86_64_32S cannot be used when making a shared object because the dynamic linker has no way to patch 32-bit absolute relocations at runtime. Wild was silently emitting R_X86_64_64 instead of erroring, producing a broken shared object.
Add an early check in apply_relocation to error when these relocation types are encountered while building a shared object, matching the behavior of GNU ld and lld.
Fixes #2074