Skip to content

Commit f764363

Browse files
committed
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 <[email protected]> Approved-By: Andrew Burgess <[email protected]>
1 parent 77307a7 commit f764363

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gdb/solib-svr4.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,10 @@ glibc_link_map_to_tls_module_id (CORE_ADDR lm_addr)
17281728
static void
17291729
tls_maybe_fill_slot (solib &so)
17301730
{
1731+
auto *li = dynamic_cast<lm_info_svr4 *> (so.lm_info.get ());
1732+
if (li == nullptr)
1733+
return;
1734+
17311735
struct svr4_info *info = get_svr4_info (current_program_space);
17321736
if (!info->glibc_tls_slots_inited)
17331737
{
@@ -1753,7 +1757,6 @@ tls_maybe_fill_slot (solib &so)
17531757
auto it = std::find (info->glibc_tls_slots.begin (),
17541758
info->glibc_tls_slots.end (),
17551759
0);
1756-
auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
17571760
if (it == info->glibc_tls_slots.end ())
17581761
info->glibc_tls_slots.push_back (li->lm_addr);
17591762
else
@@ -1771,8 +1774,11 @@ tls_maybe_erase_slot (program_space *pspace, const solib &so,
17711774
if (still_in_use)
17721775
return;
17731776

1777+
auto *li = dynamic_cast<lm_info_svr4 *> (so.lm_info.get ());
1778+
if (li == nullptr)
1779+
return;
1780+
17741781
struct svr4_info *info = get_svr4_info (pspace);
1775-
auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
17761782
auto it = std::find (info->glibc_tls_slots.begin (),
17771783
info->glibc_tls_slots.end (),
17781784
li->lm_addr);

0 commit comments

Comments
 (0)