Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc...
authorNick Clifton <nickc@redhat.com>
Fri, 19 Feb 2016 15:20:30 +0000 (15:20 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 19 Feb 2016 15:20:30 +0000 (15:20 +0000)
PR ld/19628
* reloc.c (bfd_generic_get_relocated_section_contents): Stop
processing if we encounter a reloc without an associated symbol.

bfd/ChangeLog
bfd/reloc.c

index 1c9e201e76ec478fdabef1daafbf1c358790e909..b1b404765e17e2096ad84597b996afc4844ce4b1 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-19  Nick Clifton  <nickc@redhat.com>
+
+       PR ld/19628
+       * reloc.c (bfd_generic_get_relocated_section_contents): Stop
+       processing if we encounter a reloc without an associated symbol.
+
 2016-02-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/19617
index 3ef704f8db889b435310bd5e2b4626fa9c6d4a90..a1683d8df5785ec7cd7d49a6f58478a282374f67 100644 (file)
@@ -7939,6 +7939,7 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
   if (reloc_count > 0)
     {
       arelent **parent;
+
       for (parent = reloc_vector; *parent != NULL; parent++)
        {
          char *error_message = NULL;
@@ -7946,6 +7947,16 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
          bfd_reloc_status_type r;
 
          symbol = *(*parent)->sym_ptr_ptr;
+         /* PR ld/19628: A specially crafted input file
+            can result in a NULL symbol pointer here.  */
+         if (symbol == NULL)
+           {
+             link_info->callbacks->einfo
+               (_("%X%P: %B(%A): error: relocation for offset %V has no value\n"),
+                abfd, input_section, (* parent)->address);
+             goto error_return;
+           }
+
          if (symbol->section && discarded_section (symbol->section))
            {
              bfd_byte *p;