This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Make --no-relax disable R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization
ClosedPublic

Authored by MaskRay on Nov 10 2021, 2:21 PM.

Details

Summary

This brings back the original version of D81359.
I have found several use cases now.

  • Unlike GNU ld, LLD's relocation processing is one pass. If we decide to optimize(relax) R_X86_64_{,REX_}GOTPCRELX, we will suppress GOT generation and cannot undo the decision later. Optimizing R_X86_64_REX_GOTPCRELX can usually make it easy to hit relocation R_X86_64_REX_GOTPCRELX out of range. Without --no-relax, the user has to recompile with -Wa,-mrelax-relocations=no.
  • The option would help during my investigationg of the root cause of https://git.kernel.org/linus/09e43968db40c33a73e9ddbfd937f46d5c334924
  • There is need for relaxation for AArch64 & RISC-V. Implementing this for x86-64 improves consistency with little target-specific cost (two-line X86_64.cpp change).

Diff Detail

Event Timeline

MaskRay created this revision.Nov 10 2021, 2:21 PM
MaskRay requested review of this revision.Nov 10 2021, 2:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 2:21 PM
lld/docs/ld.lld.1
348

I'd probably change the wording a bit, either drop the second part ("This disables R_X86_64 ... ") or indicate that currently it works only for x86_64. I'm not really sure it's that useful, "Disable target-specific relaxations." seems to be sufficient and won't require frequent updates.

MaskRay added inline comments.Nov 10 2021, 3:40 PM
lld/docs/ld.lld.1
348

This is a manpage where additional information can be useful. It's otherwise unclear --no-relax can help with R_X86_64_REX_GOTPCRELX issues.

lld/docs/ld.lld.1
348

I meant the following: "For x86_64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization."
(it just sounds a bit more natural, but i do not insist)

MaskRay updated this revision to Diff 386672.Nov 11 2021, 2:47 PM
MaskRay marked 2 inline comments as done.

Add "For x86_64 " to ld.lld.1

This revision is now accepted and ready to land.Nov 11 2021, 3:22 PM
MaskRay edited the summary of this revision. (Show Details)Nov 12 2021, 9:43 AM
MaskRay retitled this revision from [ELF] Make --no-relax disable R_X86_64_{,REX_}GOTPCRELX GOT optimization to [ELF] Make --no-relax disable R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.Nov 12 2021, 9:48 AM