[PATCH] D102862: [lld][ELF][SPARC] Support TLS GD relocations

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 21:09:35 PDT 2021


MaskRay added a comment.

Is IE supported now? I think the correct order is LE, IE, GD/LD.



================
Comment at: lld/ELF/Arch/SPARCV9.cpp:201
+
+void SPARCV9::relaxTlsGdToIe(uint8_t *loc, const Relocation &rel,
+                             uint64_t val) const {
----------------
If you just want to make sparcv9 work, you don't need to implement TLS optimizations.
It is additional complexity without many benefits.


================
Comment at: lld/ELF/Relocations.cpp:294
+        Symbol *call_sym = symtab->find("__tls_get_addr");
+        assert(call_sym && "__tls_get_addr symbol is not defined");
+
----------------
Avoid assert if the `!call_sym` path is reachable. You can call `fatal`


================
Comment at: lld/test/ELF/sparcv9-tls-gd.s:1
+! REQUIRES: sparc
+! RUN: echo '.tbss; .globl y; y: .word 0' > %t.s
----------------
Just use `#`. Avoid `!`

You can use riscv-tls-gd.s or ppc-tls-gd.s as an example.

For simplicity, you can test just `-no-pie` or `-pie`,  instead of both.


================
Comment at: lld/test/ELF/sparcv9-tls-gd.s:5
+! RUN: llvm-mc -filetype=obj -triple=sparcv9 %t.s -o %tx.o
+! RUN: ld.lld %tx.o -shared -o %tx.so
+! RUN: ld.lld %t.o %tx.o -shared -o %t.so
----------------
If a shared object is used as an input in a subsequent link, you need `--soname=whatever` to fix the DT_SONAME, otherwise the DT_NEEDED string will be %t, which is varying on different machines. Grep soname= in this directory.


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

https://reviews.llvm.org/D102862



More information about the llvm-commits mailing list