Fix seg-fault in linker when passed a corrupt binary input file.
authorNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 17:46:26 +0000 (17:46 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 17:47:07 +0000 (17:47 +0000)
PR lf/20908
* elflink.c (bfd_elf_final_link): Check for ELF flavour binaries
when following indirect links.

bfd/ChangeLog
bfd/elflink.c

index c8085e7b42c79619b59daf2d3bc37eabb70c318d..1fe3cd40e7dc53ebeb08d097faa60b76f4be7647 100644 (file)
@@ -1,5 +1,9 @@
 2016-12-02  Nick Clifton  <nickc@redhat.com>
 
+       PR lf/20908
+       * elflink.c (bfd_elf_final_link): Check for ELF flavour binaries
+       when following indirect links.
+
        PR ld/20909
        * aoutx.h (aout_link_add_symbols): Fix off-by-one error in check
        for an illegal string offset.
index 5f87f87553746e2ade15639efa2334b3b779b5a1..320f3bea433eb370aad6cd35f9a58123f6690a74 100644 (file)
@@ -11342,6 +11342,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
              asection *sec;
 
              sec = p->u.indirect.section;
+             /* See PR 20908 for a reproducer.  */
+             if (bfd_get_flavour (sec->owner) != bfd_target_elf_flavour)
+               {
+                 _bfd_error_handler (_("%B: not in ELF format"), sec->owner);
+                 goto error_return;
+               }
              esdi = elf_section_data (sec);
 
              /* Mark all sections which are to be included in the