[PATCH] D70398: [lld] Support copy relocations for TLS symbols

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 09:56:58 PST 2019


MaskRay added a comment.

In D70398#1751716 <https://reviews.llvm.org/D70398#1751716>, @jrtc27 wrote:

> What's strange is that TLS GD(/LD)/IE *don't* have linker relaxations currently even in BFD (and no `R_RISCV_RELAX` relocations are emitted since both compilers know it's not currently a relaxable sequence) despite RISC-V's love of linker relaxations for other things, so the model chosen at compile-time is set in stone. The only exception is that a 32-bit LE offset gets relaxed into a 12-bit LE offset when possible, but that's not changing the model. It really feels like they should have gone with IE and defined linker relaxations (something that even other architectures have here, albeit they pad with NOPs rather than deleting code) instead of this approach, but alas that's what we have.


The ABI does not say about any relaxation: code sequences can not be changed but dynamic DTPMOD relocations can be omitted if applicable, e.g. https://sourceware.org/bugzilla/show_bug.cgi?id=24676 https://sourceware.org/bugzilla/show_bug.cgi?id=24673.

I think we should improve the current TLS ABI:

- Replace traditional General Dynamic and Local Dynamic with TLSDESC (https://github.com/riscv/riscv-elf-psabi-doc/issues/94). Define the relaxations to Initial Exec and Local Exec (in lld, `R_RELAX_TLS_GD_TO_IE` and `R_RELAX_TLS_GD_TO_LE`).
- Define how Initial Exec relaxes to Local Exec (in lld, `R_RELAX_IE_TO_LE`).

I made a comment on https://sourceware.org/bugzilla/show_bug.cgi?id=23825 . Rich Felker pointed out that https://github.com/riscv/riscv-gcc/pull/118, which is applicable on GCC 7,8 and 9, can disallow Local Exec for extern TLS variable accesses https://github.com/richfelker/musl-cross-make/commit/52527c462f255065bcb053f14a13b747a8a30005. So we have a simple GCC fix. If we can reach a consensus, I think we can drop this lld change (sorry but I feel that allowing this case seems really, really bad).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70398





More information about the llvm-commits mailing list