[PATCH] D62106: [X86] Support -fno-plt __tls_get_addr calls

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 7 13:13:11 PDT 2019


nikic added a comment.

In D62106#1572612 <https://reviews.llvm.org/D62106#1572612>, @MaskRay wrote:

> In D62106#1572600 <https://reviews.llvm.org/D62106#1572600>, @nikic wrote:
>
> > > ld.bfd doesn't allow R_X86_64_GOTPCREL. You can work around the issue with:
> > > 
> > >   % clang -fno-plt -fpic a.cc -Wa,-mrelax-relocations=yes -fuse-ld=bfd
> >
> > Thanks, I've verified that setting `RelaxELFRelocations` in `TargetOptions` indeed works around the issue. I'm a bit concerned about what other compatibility issues this will cause though. If I understood correctly, relax relocations is a relatively recent feature and not compatible with older linkers, so may not be a suitable compiler default.
>
>
> I think `R_X86_64_GOTPCRELX` should be usable in ld.bfd and gold since 2016. In gold, -fno-plt R_X86_64_GOTPCREL was supported in Aug 2016 (https://sourceware.org/bugzilla/show_bug.cgi?id=20216).


Thanks for the information. As 2016 is still quite recent, I don't think we'll be able to turn on relax relocations by default and need some other solution. Given the flaky linker support, would it be possible to add an option to keep using PLT for `__tls_get_addr` despite `RtLibUseGOT`?

> Do you know why the Rust lib uses -fno-plt TLS code sequence?

As rust uses full relro, using PLT doesn't really have any advantage, so it is disabled by default nowadays.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62106/new/

https://reviews.llvm.org/D62106





More information about the llvm-commits mailing list