Fix accessing TLS variables with no debug info
Since
2273f0ac95a7 ("change minsyms not to be relocated at
read-time"), printing TLS symbols of objfiles with a non-zero base
address, without debug info, fails.
E.g., with:
$ mv /usr/lib/debug /usr/lib/debug-x
to get debug info out of the way, we get:
$ echo 'int main(){}' | gcc -pthread -x c -
$ ./gdb -q -ex start -ex 'p (int) errno' ./a.out
Cannot access memory at address 0xffffef7c0698
instead of the expected:
$1 = 0
The regression is not visible with glibc debuginfo installed.
The problem is that we compute the address of TLS minsyms incorrectly.
To trigger the problem, it is important that the variable is in an
objfile with a non-zero base address. While glibc is a shared library
for 'errno', it's easier for the testcase to use PIE instead of a
shlib. For TLS variables in PT_EXEC the regression obviously does not
happen.
gdb/ChangeLog
2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* parse.c (find_minsym_type_and_address): Don't relocate addresses
of TLS symbols.
gdb/testsuite/ChangeLog
2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.threads/tls-nodebug-pie.c: New file.
* gdb.threads/tls-nodebug-pie.exp: New file.