aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-10-04 07:47:05 +0930
committerAlan Modra <amodra@gmail.com>2024-10-04 22:16:49 +0930
commit753e2f771b1bba72426354aef364c8d986ed999c (patch)
tree38380ded5d08f9ef3ba0792e30fb9a23f9e8c968
parent06116013f80e474800cfb122924bc2a6f060606a (diff)
downloadgdb-753e2f771b1bba72426354aef364c8d986ed999c.zip
gdb-753e2f771b1bba72426354aef364c8d986ed999c.tar.gz
gdb-753e2f771b1bba72426354aef364c8d986ed999c.tar.bz2
gdb segv in elfread.c:elf_rel_plt_read
After commit 68bbe1183379, ELF symbols read via bfd_canonicalize_symtab and similar functions which have bad st_name fields will have NULL in the name rather than "(null)". gdb.base/bfd-errors.exp deliberately creates a faulty shared library with st_name pointing outside of .dynsym for some symbols, and thus now results in NULL symbol names. This triggers a segv on string_buffer.assign(name). Fix that.
-rw-r--r--gdb/elfread.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e959d3a..2e68b0d 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -612,6 +612,8 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX);
name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr);
+ if (!name)
+ continue;
address = relplt->relocation[reloc].address;
asection *msym_section;