Implement the regular GD sequence and the two relaxation forms, to IE or LE.
Diff Detail
Event Timeline
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
240–245 | R_SPARC_TLS_IE_HI22/LO10? This is wrong, but I guess this is a hack that kinda works because IE isn't actually implemented yet? Which probably should happen before landing GD support... LD is less clear, but also seemingly unimplemented, only basic LE. | |
255 | Do you mean add %g7, %r2, %r3? | |
lld/ELF/Driver.cpp | ||
929 ↗ | (On Diff #346815) | Please keep this sorted |
lld/ELF/Relocations.cpp | ||
289–292 | Should this be more like hexagonNeedsTLSSymbol/hexagonTLSSymbolUpdate and combined with it, which has similar weirdness? | |
296–297 | Why would it need a GOT entry? SPARC doesn't even use a .got.plt, it synthesises the addresses directly in the PLT entries, but even on .got.plt architectures calls don't use the real GOT other than MIPS abicalls. |
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
240–245 | I wouldn't call this a hack, as long as the relocation type matches it's fine to use R_SPARC_HI22 or R_SPARC_LO10 here. | |
255 | Yes, it's a typo I carried over from Gold as that's the only reference for the relaxation sequences. | |
lld/ELF/Driver.cpp | ||
929 ↗ | (On Diff #346815) | Will do, I didn't notice they were sorted. |
lld/ELF/Relocations.cpp | ||
289–292 | No, I find this approach much cleaner than the late patching done for Hexagon. | |
296–297 | Ah, good catch, that was a leftover from some previous experiments. |
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
255 | The reference is the original Ulrich Drepper ELF TLS spec https://www.akkadia.org/drepper/tls.pdf | |
lld/ELF/Relocations.cpp | ||
289–292 | Hm, it's a bit ugly. Maybe @MaskRay has ideas. Does that mean Hexagon is buggy, too? |
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
240–245 | It's a bit of an abuse. I don't think it should be committed in this form. You should at least add the IE cases needed to support GD->IE so you can use the right relocations here even if you're not adding full IE support, though full IE support should be pretty straightforward to add too other than the tedium of test writing. |
Is IE supported now? I think the correct order is LE, IE, GD/LD.
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
229 | If you just want to make sparcv9 work, you don't need to implement TLS optimizations. | |
lld/ELF/Relocations.cpp | ||
294 | Avoid assert if the !call_sym path is reachable. You can call fatal | |
lld/test/ELF/sparcv9-tls-gd.s | ||
2 | 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. | |
6 | 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. |
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
61 | Can you check whether gotHeaderEntriesNum/gotPltHeaderEntriesNum should be changed? |
lld/ELF/Relocations.cpp | ||
---|---|---|
293 | tlsGetAddr |
lld/ELF/Arch/SPARCV9.cpp | ||
---|---|---|
61 | 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. | |
lld/ELF/Relocations.cpp | ||
294 | Both llvm-mc and GAS add a __tls_get_addr symbol, hence the use of assert. | |
lld/test/ELF/sparcv9-tls-gd.s | ||
2 | Will do, I used ! as the other SPARC test cases were using it. | |
6 | Does that matter here? I'm not checking any offset in the RELOC checks. |
Rebased on top of D102908.
Correct computation of relaxed tp-relative offset.
Turn add into or/xor during the relaxation.
Can you check whether gotHeaderEntriesNum/gotPltHeaderEntriesNum should be changed?