]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
(elf_link_input_bfd): Handle the case where a badly formatted input file results
authorNick Clifton <nickc@redhat.com>
Wed, 27 Apr 2005 16:47:24 +0000 (16:47 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 27 Apr 2005 16:47:24 +0000 (16:47 +0000)
in a reloc which has no associated global symbol.

bfd/ChangeLog
bfd/elflink.c

index 194f7414a7ff6a766668adbb50596e41a5fcd65e..616f20dd49260f93cd9975e6673843f0d6bfd8d1 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-27  Nick Clifton  <nickc@redhat.com>
+
+       * elflink.c (elf_link_input_bfd): Handle the case where a badly
+       formatted input file results in a reloc which has no associated
+       global symbol.
+
 2005-04-20  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * configure.in: Bump version to 2.15.97.
index 914096c017f41144535a85d58db2a986dd2e48a2..3a10c715ba6e4ef9b015c9cdd4a9ac352ae61a43 100644 (file)
@@ -6993,6 +6993,23 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
                          && finfo->sections[r_symndx] == NULL))
                    {
                      h = sym_hashes[r_symndx - extsymoff];
+
+                     /* Badly formatted input files can contain relocs that
+                        reference non-existant symbols.  Check here so that
+                        we do not seg fault.  */
+                     if (h == NULL)
+                       {
+                         char buffer [32];
+
+                         sprintf_vma (buffer, rel->r_info);
+                         (*_bfd_error_handler)
+                           (_("error: %B contains a reloc (0x%s) for section %A "
+                              "that references a non-existent global symbol"),
+                            input_bfd, o, buffer);
+                         bfd_set_error (bfd_error_bad_value);
+                         return FALSE;
+                       }
+
                      while (h->root.type == bfd_link_hash_indirect
                             || h->root.type == bfd_link_hash_warning)
                        h = (struct elf_link_hash_entry *) h->root.u.i.link;