[PATCH] D62106: [X86] Support -fno-plt __tls_get_addr calls
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 7 08:12:08 PDT 2019
MaskRay added a comment.
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).
Do you know why the Rust lib uses -fno-plt TLS code sequence? I'm thinking if its depended llvm should be configured with `-DENABLE_X86_RELAX_RELOCATIONS=ON` so that you don't need -Wa,-mrelax-relocations=yes
% llvm-objdump -dr file2.rlib
...
8: ff 15 00 00 00 00 callq *(%rip)
000000000000000a: R_X86_64_GOTPCREL __tls_get_addr-4
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