aboutsummaryrefslogtreecommitdiff
path: root/nptl_db
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-04-21 11:50:43 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-04-21 11:50:43 +0200
commita64afc225240b2b27129ccfb0516d7c958b98040 (patch)
tree02bdfc42d7b25fd2f537e6aad77be75f33af44ba /nptl_db
parentaaa23c35071537e2dcf5807e956802ed215210aa (diff)
downloadglibc-a64afc225240b2b27129ccfb0516d7c958b98040.zip
glibc-a64afc225240b2b27129ccfb0516d7c958b98040.tar.gz
glibc-a64afc225240b2b27129ccfb0516d7c958b98040.tar.bz2
nptl_db: Support different libpthread/ld.so load orders (bug 27744)
libthread_db is loaded once GDB encounters libpthread, and at this point, ld.so may not have been processed by GDB yet. As a result, _rtld_global cannot be accessed by regular means from libthread_db. To make this work until GDB can be fixed, acess _rtld_global through a pointer stored in libpthread. The new test does not reproduce bug 27744 with --disable-hardcoded-path-in-tests, but is still a valid smoke test. With --enable-hardcoded-path-in-tests, it is necessary to avoid add-symbol-file because this can tickle a GDB bug. Fixes commit 1daccf403b1bd86370eb94edca794dc106d02039 ("nptl: Move stack list variables into _rtld_global"). Tested-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'nptl_db')
-rw-r--r--nptl_db/structs.def3
-rw-r--r--nptl_db/td_init.c15
-rw-r--r--nptl_db/thread_dbP.h2
3 files changed, 11 insertions, 9 deletions
diff --git a/nptl_db/structs.def b/nptl_db/structs.def
index 999a9fc..8a613dd 100644
--- a/nptl_db/structs.def
+++ b/nptl_db/structs.def
@@ -100,8 +100,7 @@ DB_STRUCT_FIELD (pthread, dtvp)
#endif
#if !(IS_IN (libpthread) && !defined SHARED)
-DB_STRUCT (rtld_global)
-DB_RTLD_VARIABLE (_rtld_global)
+DB_VARIABLE (__nptl_rtld_global)
#endif
DB_RTLD_GLOBAL_FIELD (dl_tls_dtv_slotinfo_list)
DB_RTLD_GLOBAL_FIELD (dl_stack_user)
diff --git a/nptl_db/td_init.c b/nptl_db/td_init.c
index 1d15681..06b5adc 100644
--- a/nptl_db/td_init.c
+++ b/nptl_db/td_init.c
@@ -33,13 +33,14 @@ td_init (void)
bool
__td_ta_rtld_global (td_thragent_t *ta)
{
- if (ta->ta_addr__rtld_global == 0
- && td_mod_lookup (ta->ph, LD_SO, SYM__rtld_global,
- &ta->ta_addr__rtld_global) != PS_OK)
+ if (ta->ta_addr__rtld_global == 0)
{
- ta->ta_addr__rtld_global = (void*)-1;
- return false;
+ psaddr_t rtldglobalp;
+ if (DB_GET_VALUE (rtldglobalp, ta, __nptl_rtld_global, 0) == TD_OK)
+ ta->ta_addr__rtld_global = rtldglobalp;
+ else
+ ta->ta_addr__rtld_global = (void *) -1;
}
- else
- return ta->ta_addr__rtld_global != (void*)-1;
+
+ return ta->ta_addr__rtld_global != (void *)-1;
}
diff --git a/nptl_db/thread_dbP.h b/nptl_db/thread_dbP.h
index 580a70c..712fa3a 100644
--- a/nptl_db/thread_dbP.h
+++ b/nptl_db/thread_dbP.h
@@ -108,6 +108,8 @@ struct td_thragent
# undef DB_SYMBOL
# undef DB_VARIABLE
+ psaddr_t ta_addr__rtld_global;
+
/* The method of locating a thread's th_unique value. */
enum
{