Fix addrss violation when processing a corrupt SH COFF binary.
authorNick Clifton <nickc@redhat.com>
Wed, 21 Jun 2017 15:36:44 +0000 (16:36 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 21 Jun 2017 15:36:44 +0000 (16:36 +0100)
PR binutils/21646
* coff-sh.c (sh_reloc): Check for an out of range reloc.

bfd/ChangeLog
bfd/coff-sh.c

index 35b9d97a98fecd84a448b39bca2d9058956b7205..b1cf4f9c33367fa9dd9d85923ccfecd211246f95 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-21  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/21646
+       * coff-sh.c (sh_reloc): Check for an out of range reloc.
+
 2017-06-21  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/21639
index d76f98ad059bb0b5b6b492d53af3d70fc076eaea..26d296baa05e66826fab8c21c6f35e1ad6796c0c 100644 (file)
@@ -596,6 +596,9 @@ sh_reloc (bfd *      abfd,
       && bfd_is_und_section (symbol_in->section))
     return bfd_reloc_undefined;
 
+  if (addr > input_section->size)
+    return bfd_reloc_outofrange;
+
   sym_value = get_symbol_value (symbol_in);
 
   switch (r_type)
@@ -2910,7 +2913,6 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
   struct internal_reloc *internal_relocs = NULL;
   struct internal_syment *internal_syms = NULL;
 
-fprintf (stderr, "DATA = %p\n", data);
   /* We only need to handle the case of relaxing, or of having a
      particular set of section contents, specially.  */
   if (relocatable