[binutils-gdb] LM32 linker segmentation faults
Alan Modra
amodra@sourceware.org
Tue May 28 05:45:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a0f6fd217fa53ab80a335fb69f12f1f28ac3335a
commit a0f6fd217fa53ab80a335fb69f12f1f28ac3335a
Author: Alan Modra <amodra@gmail.com>
Date: Tue May 28 14:34:37 2019 +0930
LM32 linker segmentation faults
PR 24596
* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Don't segfault
on NULL output_section.
* elflink.c (elf_final_link_free): Don't free -1 symshndxbuf.
Diff:
---
bfd/ChangeLog | 7 +++++++
bfd/elf32-lm32.c | 3 ++-
bfd/elflink.c | 3 ++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fd0dfcb..de58a02 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,13 @@
2019-05-28 Alan Modra <amodra@gmail.com>
PR 24596
+ * elf32-lm32.c (lm32_elf_finish_dynamic_sections): Don't segfault
+ on NULL output_section.
+ * elflink.c (elf_final_link_free): Don't free -1 symshndxbuf.
+
+2019-05-28 Alan Modra <amodra@gmail.com>
+
+ PR 24596
* elf32-m68k.c (elf_m68k_get_got_entry): Don't create a new
entry when MUST_FIND. Abort when MUST_FIND not found.
(elf_m68k_get_bfd2got_entry): Likewise.
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 3a72eaa..2428764 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -1444,7 +1444,8 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
FALSE, FALSE, TRUE);
if (hend
&& (hend->type == bfd_link_hash_defined
- || hend->type == bfd_link_hash_defweak))
+ || hend->type == bfd_link_hash_defweak)
+ && hend->u.def.section->output_section != NULL)
{
bfd_vma value =
lm32fdpic_fixup32_section (info)->output_section->vma
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ddeaa08..02ea2dc 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11682,7 +11682,8 @@ elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
free (flinfo->indices);
if (flinfo->sections != NULL)
free (flinfo->sections);
- if (flinfo->symshndxbuf != NULL)
+ if (flinfo->symshndxbuf != NULL
+ && flinfo->symshndxbuf != (Elf_External_Sym_Shndx *) -1)
free (flinfo->symshndxbuf);
for (o = obfd->sections; o != NULL; o = o->next)
{
More information about the Binutils-cvs
mailing list