(elf_link_input_bfd): Handle the case where a badly formatted input file results
authorNick Clifton <nickc@redhat.com>
Wed, 27 Apr 2005 10:09:43 +0000 (10:09 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 27 Apr 2005 10:09:43 +0000 (10:09 +0000)
in a reloc which has no associated global symbol

bfd/ChangeLog
bfd/elflink.c

index bf49cc0e42450a02d28e3fb945d2f18d55d890ff..2e70d771a140d8af85b4fdf7764d340b749be72d 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-26  Jerome Guitton  <guitton@gnat.com>
 
        * bfd.m4 (BFD_NEED_DECLARATION): Restore.
index cd9131ef3805d301d0afc7c0e954fe502e26e3eb..bf2178090c7bad5cdb4967af769c846c379240b5 100644 (file)
@@ -7019,6 +7019,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;
This page took 0.03229 seconds and 4 git commands to generate.