[all-commits] [llvm/llvm-project] fb3c1b: [ELF] Reject local-exec TLS relocations for -shared
Fangrui Song via All-commits
all-commits at lists.llvm.org
Mon Dec 21 08:47:24 PST 2020
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fb3c1b3de5ce7342438d7451f01a14f9c52323cd
https://github.com/llvm/llvm-project/commit/fb3c1b3de5ce7342438d7451f01a14f9c52323cd
Author: Fangrui Song <i at maskray.me>
Date: 2020-12-21 (Mon, 21 Dec 2020)
Changed paths:
M lld/ELF/Relocations.cpp
R lld/test/ELF/Inputs/i386-static-tls-model4.s
M lld/test/ELF/aarch64-tls-le.s
M lld/test/ELF/arm-tls-le32.s
M lld/test/ELF/i386-static-tls-model.s
M lld/test/ELF/i386-tls-le.s
M lld/test/ELF/i386-zrel-zrela.s
M lld/test/ELF/mips-tls-hilo.s
M lld/test/ELF/ppc64-local-exec-tls.s
M lld/test/ELF/riscv-tls-le.s
M lld/test/ELF/tls.s
R lld/test/ELF/x86-64-reloc-tpoff32-fpic.s
Log Message:
-----------
[ELF] Reject local-exec TLS relocations for -shared
For x86-64, D33100 added a diagnostic for local-exec TLS relocations referencing a preemptible symbol.
This patch generalizes it to non-preemptible symbols (see `-Bsymbolic` in `tls.s`)
on all targets.
Local-exec TLS relocations resolve to offsets relative to a fixed point within
the static TLS block, which are only meaningful for the executable.
With this change, `clang -fpic -shared -fuse-ld=bfd a.c` on the following example will be flagged for AArch64/ARM/i386/x86-64/RISC-V
```
static __attribute__((tls_model("local-exec"))) __thread long TlsVar = 42;
long bump() { return ++TlsVar; }
```
Note, in GNU ld, at least arm, riscv and x86's ports have the similar
diagnostics, but aarch64 and ppc64 do not error.
Differential Revision: https://reviews.llvm.org/D93331
More information about the All-commits
mailing list