[SPARC] Use a DTP-relative offset for the DWARF location of TLS variables (#244842)
The SPARC target did not override getDebugThreadLocalSymbol, so the
DW_OP_const4u/DW_OP_const8u operand in the location of a thread-local
variable was emitted as a plain address (R_SPARC_32/R_SPARC_UA64)
instead of the variable's offset within the module's TLS block. gdb
then could not read thread-local variables in programs built with clang.
Emit %r_tls_dtpoff32/%r_tls_dtpoff64, as GCC does, which become
R_SPARC_TLS_DTPOFF32/R_SPARC_TLS_DTPOFF64. Accept these specifiers in
.word/.xword in the assembler, mark the referenced symbol STT_TLS like
GNU as, and teach the RelocationResolver about the relocations so
llvm-dwarfdump does not warn about them.
Fixes #244635
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
GitOrigin-RevId: b579a243fe8d87bf18a5f5aa7a730e0accfe7c7d
7 files changed