| Issue |
244635
|
| Summary |
[SPARC] DWARF location of __thread variables uses an absolute relocation instead of R_SPARC_TLS_DTPOFF64
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
shalseth
|
On sparc64, the DWARF location of a `__thread` variable is an absolute address instead of a DTP-relative offset. gdb can't read thread-local variables in a program built with clang.
```c
__thread int pad = 1;
__thread int tv = 42;
void here (void) {}
int main (void)
{
here ();
return tv + pad - 43;
}
```
```
$ clang -g -O0 t.c -o t && gdb -batch -ex 'break here' -ex run -ex 'print tv' ./t 2>&1 | tail -1
Cannot access memory at address 0xfff8000100245564
$ gcc -g -O0 t.c -o t && gdb -batch -ex 'break here' -ex run -ex 'print tv' ./t 2>&1 | tail -1
$1 = 42
```
clang emits the operand of `DW_OP_const8u` as a plain address. It becomes an `R_SPARC_UA64` relocation:
```
.byte 14
.xword tv
.byte 224
```
GCC emits a DTP-relative offset with an `R_SPARC_TLS_DTPOFF64` relocation:
```
.byte 0xe
.xword %r_tls_dtpoff64(tv)
.byte 0x9b
```
The Sparc target doesn't override `getDebugThreadLocalSymbol`. X86, Mips and PowerPC do. Without the override the generic plain symbol reference is used.
glibc's nptl/tst-pthread-gdb-attach and tst-pthread-gdb-attach-static fail because of this when glibc is built with clang (https://github.com/sparclinux/issues/issues/96).
LLVM main 1ed0efd70af1, gdb 18.1, SPARC M7, Linux sparc64.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs