diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2025-05-23 12:30:52 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2025-05-24 10:07:42 -0400 |
commit | f76436396f33f583ecec33188777ab73f4e59404 (patch) | |
tree | 1fd7174778ad7400bce066c499a7e6016015faad | |
parent | 77307a766b6bb1ddd3604f335f30f2e751e77f45 (diff) | |
download | binutils-f76436396f33f583ecec33188777ab73f4e59404.zip binutils-f76436396f33f583ecec33188777ab73f4e59404.tar.gz binutils-f76436396f33f583ecec33188777ab73f4e59404.tar.bz2 |
gdb/solib-svr4: check that solib is SVR4 in tls_maybe_fill_slot and tls_maybe_erase_slot
Functions tls_maybe_fill_slot and tls_maybe_erase_slot blindly assume
that the passe solibs come from solib-svr4. This is not always the
case, because they are called even on the systems where the solib
implementation isn't solib-svr4. Add some checks to return early in
that case.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32990
Change-Id: I0a281e1f4826aa1914460c2213f0fae1bdc9af7c
Tested-By: Hannes Domani <ssbssa@yahoo.de>
Approved-By: Andrew Burgess <aburgess@redhat.com>
-rw-r--r-- | gdb/solib-svr4.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 9f56d86..a1dc13c 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1728,6 +1728,10 @@ glibc_link_map_to_tls_module_id (CORE_ADDR lm_addr) static void tls_maybe_fill_slot (solib &so) { + auto *li = dynamic_cast<lm_info_svr4 *> (so.lm_info.get ()); + if (li == nullptr) + return; + struct svr4_info *info = get_svr4_info (current_program_space); if (!info->glibc_tls_slots_inited) { @@ -1753,7 +1757,6 @@ tls_maybe_fill_slot (solib &so) auto it = std::find (info->glibc_tls_slots.begin (), info->glibc_tls_slots.end (), 0); - auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ()); if (it == info->glibc_tls_slots.end ()) info->glibc_tls_slots.push_back (li->lm_addr); else @@ -1771,8 +1774,11 @@ tls_maybe_erase_slot (program_space *pspace, const solib &so, if (still_in_use) return; + auto *li = dynamic_cast<lm_info_svr4 *> (so.lm_info.get ()); + if (li == nullptr) + return; + struct svr4_info *info = get_svr4_info (pspace); - auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ()); auto it = std::find (info->glibc_tls_slots.begin (), info->glibc_tls_slots.end (), li->lm_addr); |