This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Don't force Local Exec TLS for non-PIC
ClosedPublic

Authored by jrtc27 on Nov 24 2019, 3:25 PM.

Details

Summary

Forcing Local Exec TLS requires the use of copy relocations. Copy
relocations need special handling in the runtime linker when being used
against TLS symbols, which is present in glibc, but not in FreeBSD nor
musl, and so cannot be relied upon. Moreover, copy relocations are a
hack that embed the size of an object in the ABI when it otherwise
wouldn't be, and break protected symbols (which are expected to be DSO
local), whilst also wasting space, thus they should be avoided whenever
possible. As discussed in D70398, RISC-V should move away from forcing
Local Exec, and instead use Initial Exec like other targets, with
possible linker relaxation to follow. The RISC-V GCC maintainers also
intend to adopt this more-conventional behaviour (see
https://github.com/riscv/riscv-elf-psabi-doc/issues/122).

Diff Detail

Event Timeline

jrtc27 created this revision.Nov 24 2019, 3:25 PM
MaskRay accepted this revision.Nov 24 2019, 4:08 PM
This revision is now accepted and ready to land.Nov 24 2019, 4:08 PM
This revision was automatically updated to reflect the committed changes.