Fix seg-fault linking corrupt binary.
authorNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 14:40:46 +0000 (14:40 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 14:40:46 +0000 (14:40 +0000)
PR ld/20912
* emultempl/elf32.em (_place_orphan): Test for ELF format of the
orphan before looking for the SHF_EXCLUDE flag.

ld/ChangeLog
ld/emultempl/elf32.em

index c4bbe552cfe9d170bcf64448930404081573079a..e9734ac95b922413a51903e3e07a9073a24c0f5b 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-02  Nick Clifton  <nickc@redhat.com>
+
+       PR ld/20912
+       * emultempl/elf32.em (_place_orphan): Test for ELF format of the
+       orphan before looking for the SHF_EXCLUDE flag.
+
 2016-12-02  Josh Conner  <joshconner@google.com>
 
         * Makefile.am: Add dependency information for earmelf_fuchsia.c.
index 36aa7db886dc080703bc579b02b3f6504c1bbdc4..1fd6313d8f8e9ff106f7166b3c9205b1ad4183b4 100644 (file)
@@ -2062,9 +2062,9 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
        if (os->bfd_section != NULL
            && (os->bfd_section->flags == 0
                || ((!bfd_link_relocatable (&link_info)
-                    || (((elf_section_flags (s)
-                         ^ elf_section_flags (os->bfd_section))
-                        & SHF_EXCLUDE) == 0))
+                    || (iself && (((elf_section_flags (s)
+                                    ^ elf_section_flags (os->bfd_section))
+                                   & SHF_EXCLUDE) == 0)))
                    && ((s->flags ^ os->bfd_section->flags)
                     & (SEC_LOAD | SEC_ALLOC)) == 0
                    && _bfd_elf_match_sections_by_type (link_info.output_bfd,