[PATCH 3/9] Handle TLS variable lookups when using separate debug object files.

John Baldwin
2019-01-22T18:43:45Z

The object files stored in the shared object list are the original
object files, not the separate debug object files. However, when
resolving a TLS variable, the variable is resolved against a separate
debug object file if it exists. In this case,
svr4_fetch_objfile_link_map was failing to find the link map entry
since the debug object file is not in its internal list, only the
original object file.

gdb/ChangeLog:

* solib-svr4.c (svr4_fetch_objfile_link_map): Look for
objfile->separate_debug_objfile_backlink if not NULL.
---
gdb/ChangeLog | 5 +++++
gdb/solib-svr4.c | 5 +++++
2 files changed, 10 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 056a60fa23..c02e534fe5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-22 John Baldwin <jhb@FreeBSD.org>
+
+ * solib-svr4.c (svr4_fetch_objfile_link_map): Look for
+ objfile->separate_debug_objfile_backlink if not NULL.
+
2019-01-22 John Baldwin <jhb@FreeBSD.org>

* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 787b98ba26..d7a792580d 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1548,6 +1548,11 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
if (objfile == symfile_objfile)
return info->main_lm_addr;

+ /* If OBJFILE is a separate debug object file, look for the
+ original object file. */
+ if (objfile->separate_debug_objfile_backlink != NULL)
+ objfile = objfile->separate_debug_objfile_backlink;
+
/* The other link map addresses may be found by examining the list
of shared libraries. */
for (so = master_so_list (); so; so = so->next)
--
2.19.2