aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-10-04 13:30:09 +0930
committerAlan Modra <amodra@gmail.com>2024-10-04 17:47:21 +0930
commit0c13ac533e59589793ee6c8045cff98663f3ea85 (patch)
tree2c9f6a2e80735a8f65dcb43f5ee733cde1f672b1 /bfd/elf.c
parent265757dc6e4d011a1b33ef1b3bfcd7f100f12f64 (diff)
downloadgdb-0c13ac533e59589793ee6c8045cff98663f3ea85.zip
gdb-0c13ac533e59589793ee6c8045cff98663f3ea85.tar.gz
gdb-0c13ac533e59589793ee6c8045cff98663f3ea85.tar.bz2
get_synthetic_symtab fixes for commit 68bbe1183379
Given that relocation symbol name can now be NULL for ELF, adjust various get_synthetic_symtab routines so they don't segfault. * elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name possibly being NULL. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise. * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise. * elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise. * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 38bfb1c..39ee641 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -13537,17 +13537,19 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd,
size = count * sizeof (asymbol);
p = relplt->relocation;
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
- {
- size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
- if (p->addend != 0)
- {
+ if ((*p->sym_ptr_ptr)->name != NULL)
+ {
+ size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+ if (p->addend != 0)
+ {
#ifdef BFD64
- size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64);
+ size += (sizeof ("+0x") - 1 + 8
+ + 8 * (bed->s->elfclass == ELFCLASS64));
#else
- size += sizeof ("+0x") - 1 + 8;
+ size += sizeof ("+0x") - 1 + 8;
#endif
- }
- }
+ }
+ }
s = *ret = (asymbol *) bfd_malloc (size);
if (s == NULL)
@@ -13565,6 +13567,9 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd,
if (addr == (bfd_vma) -1)
continue;
+ if ((*p->sym_ptr_ptr)->name == NULL)
+ continue;
+
*s = **p->sym_ptr_ptr;
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
we are defining a symbol, ensure one of them is set. */