LM32 linker segmentation faults
authorAlan Modra <amodra@gmail.com>
Tue, 28 May 2019 05:04:37 +0000 (14:34 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 28 May 2019 05:08:31 +0000 (14:38 +0930)
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.

bfd/ChangeLog
bfd/elf32-lm32.c
bfd/elflink.c

index fd0dfcb420251d59d717814234695963ab4e5563..de58a02a174ef44103ee7233c99e5f70421b72b8 100644 (file)
@@ -1,3 +1,10 @@
+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
index 3a72eaa4069c9b24ce729309075809df3e25a9ae..242876489fa277d8ea013af3386c4328cd1a5abb 100644 (file)
@@ -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
index ddeaa08d505fd55838dc1bef4b5e136a2c07207a..02ea2dc3e1dc14a918cb7143e470e6fd239a7096 100644 (file)
@@ -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)
     {
This page took 0.032538 seconds and 4 git commands to generate.