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

LemonBoy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 21 02:54:15 PDT 2021


LemonBoy added a comment.

In D102862#2772849 <https://reviews.llvm.org/D102862#2772849>, @MaskRay wrote:

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

D102908 <https://reviews.llvm.org/D102908> implements IE & its relaxation, once that's merged I'll rebase this patch.
LD is on the roadmap as I need it to link programs against glibc.
There's also one more GOT relocation that's blocked on D102575 <https://reviews.llvm.org/D102575>, the LLD's side is quite simple.



================
Comment at: lld/ELF/Arch/SPARCV9.cpp:57
+
+  gotBaseSymInGotPlt = false;
 }
----------------
MaskRay wrote:
> Can you check whether gotHeaderEntriesNum/gotPltHeaderEntriesNum should be changed?
AFAICS the systemv ABI doesn't reserve any GOT entry (and `.got.plt` is not used). The only "quirk", 4 reserved PLT entries, is already taken into account.


================
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");
+
----------------
MaskRay wrote:
> Avoid assert if the `!call_sym` path is reachable. You can call `fatal`
Both `llvm-mc` and GAS add a `__tls_get_addr` symbol, hence the use of `assert`.
I'll switch to `fatal` as that's perhaps more robust against malformed input.


================
Comment at: lld/test/ELF/sparcv9-tls-gd.s:1
+! REQUIRES: sparc
+! RUN: echo '.tbss; .globl y; y: .word 0' > %t.s
----------------
MaskRay wrote:
> 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.
Will do, I used `!` as the other SPARC test cases were using it.


================
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
----------------
MaskRay wrote:
> 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.
Does that matter here? I'm not checking any offset in the `RELOC` checks.


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

https://reviews.llvm.org/D102862



More information about the llvm-commits mailing list