Page MenuHomePhabricator

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

Authored by MaskRay on Wed, Nov 10, 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.Wed, Nov 10, 2:21 PM
MaskRay requested review of this revision.Wed, Nov 10, 2:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptWed, Nov 10, 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.Wed, Nov 10, 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.Thu, Nov 11, 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.Thu, Nov 11, 3:22 PM
MaskRay edited the summary of this revision. (Show Details)Fri, Nov 12, 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.Fri, Nov 12, 9:48 AM