Fix seg-fault when trying to place non-ELF orphan sections.
authorNick Clifton <nickc@redhat.com>
Wed, 2 Aug 2017 10:45:05 +0000 (11:45 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 2 Aug 2017 10:45:05 +0000 (11:45 +0100)
PR 21884
* emultempl/elf32.em (_place_orphan): Skip non-ELF binaries when
looking for sections to merge.

ld/ChangeLog
ld/emultempl/elf32.em

index 3c918e6c58337a2a0f13e49122e0cadfd0149c50..9acf64efd7e6ac75290f248c2069c30c99a116bf 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-02  Nick Clifton  <nickc@redhat.com>
+
+       PR 21884
+       * emultempl/elf32.em (_place_orphan): Skip non-ELF binaries when
+       looking for sections to merge.
+
 2017-07-31  Alan Modra  <amodra@gmail.com>
 
        * ld.texinfo (plt-localentry): Revise.
index d2551b6f2c01b7f9bb4c9bc73842c9142926f289..8cdcc6c7f9153aaf2021d3b6618caeb0519f7a8d 100644 (file)
@@ -2150,6 +2150,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
           one of them has SHF_EXCLUDE.  Don't merge 2 sections with
           different sh_info.  */
        if (os->bfd_section != NULL
+           /* PR 21884: Don't merge non-ELF sections.  */
+           && bfd_get_flavour (os->bfd_section->owner) == bfd_target_elf_flavour
            && (elf_section_data (os->bfd_section)->this_hdr.sh_info
                == elf_section_data (s)->this_hdr.sh_info)
            && (os->bfd_section->flags == 0