aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-07-29 17:34:18 +0930
committerAlan Modra <amodra@gmail.com>2020-07-29 17:39:54 +0930
commit4d68fd750fa0ce9de7a5245f9eff539f31a95fb6 (patch)
tree12a79a0a26572122cebbb39015714597fd2daac6
parent5987401fcbc9933808fa0d84d1b01c93356c39a1 (diff)
downloadgdb-4d68fd750fa0ce9de7a5245f9eff539f31a95fb6.zip
gdb-4d68fd750fa0ce9de7a5245f9eff539f31a95fb6.tar.gz
gdb-4d68fd750fa0ce9de7a5245f9eff539f31a95fb6.tar.bz2
Don't segfault on discarded section dynsyms
We get lots of errors before we get to this code, but let's not segfault. * elflink.c (bfd_elf_final_link): Don't segfault on local dynsyms defined in excluded sections.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elflink.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1e7fb4a..8e8dc99 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-07-29 Alan Modra <amodra@gmail.com>
+
+ * elflink.c (bfd_elf_final_link): Don't segfault on local dynsyms
+ defined in excluded sections.
+
2020-07-28 Alan Modra <amodra@gmail.com>
* elf.c (assign_section_numbers): Comment. Don't segfault on
diff --git a/bfd/elflink.c b/bfd/elflink.c
index a3823e6..5089616 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12599,10 +12599,13 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
the original st_name with the dynstr_index. */
sym = e->isym;
sym.st_other &= ~ELF_ST_VISIBILITY (-1);
+ sym.st_shndx = SHN_UNDEF;
s = bfd_section_from_elf_index (e->input_bfd,
e->isym.st_shndx);
- if (s != NULL)
+ if (s != NULL
+ && s->output_section != NULL
+ && elf_section_data (s->output_section) != NULL)
{
sym.st_shndx =
elf_section_data (s->output_section)->this_idx;