Blame SOURCES/gdb-rhbz1320945-power9-10of38.patch

2c2fa1
commit ec93045b400ec68b0c5716d75f27a87533b57058
2c2fa1
Author: Nick Clifton <nickc@redhat.com>
2c2fa1
Date:   Tue Jan 6 17:54:02 2015 +0000
2c2fa1
2c2fa1
    Fix memory access violations for objdump triggered by fuzzed binaries.
2c2fa1
    
2c2fa1
            PR binutils/17512
2c2fa1
            * reloc.c (bfd_get_reloc_size): Handle a reloc size of -1.
2c2fa1
            (bfd_perform_relocation): Include the size of the reloc in the
2c2fa1
            test for an out of range relocation.
2c2fa1
            (bfd_generic_get_relocated_section_contents): Remove reloc range
2c2fa1
            test.
2c2fa1
2c2fa1
### a/bfd/ChangeLog
2c2fa1
### b/bfd/ChangeLog
2c2fa1
## -1,6 +1,12 @@
2c2fa1
 2015-01-06  Nick Clifton  <nickc@redhat.com>
2c2fa1
 
2c2fa1
 	PR binutils/17512
2c2fa1
+	* reloc.c (bfd_get_reloc_size): Handle a reloc size of -1.
2c2fa1
+	(bfd_perform_relocation): Include the size of the reloc in the
2c2fa1
+	test for an out of range relocation.
2c2fa1
+	(bfd_generic_get_relocated_section_contents): Remove reloc range
2c2fa1
+	test.
2c2fa1
+
2c2fa1
 	* coff-i860.c (CALC_ADDEND): Always set an addend value.
2c2fa1
 	* tekhex.c (getvalue): Add an end pointer parameter.  Use it to
2c2fa1
 	avoid reading off the end of the buffer.
2c2fa1
--- a/bfd/reloc.c
2c2fa1
+++ b/bfd/reloc.c
2c2fa1
@@ -437,6 +437,7 @@ bfd_get_reloc_size (reloc_howto_type *howto)
2c2fa1
     case 3: return 0;
2c2fa1
     case 4: return 8;
2c2fa1
     case 8: return 16;
2c2fa1
+    case -1: return 2;
2c2fa1
     case -2: return 4;
2c2fa1
     default: abort ();
2c2fa1
     }
2c2fa1
@@ -618,7 +619,11 @@ bfd_perform_relocation (bfd *abfd,
2c2fa1
     }
2c2fa1
 
2c2fa1
   /* Is the address of the relocation really within the section?  */
2c2fa1
-  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
2c2fa1
+  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)
2c2fa1
+      /* PR 17512: file: c146ab8b.
2c2fa1
+	 PR 17512: file: 46dff27f.
2c2fa1
+	 Include the size of the reloc in the test for out of range addresses.  */
2c2fa1
+      - bfd_get_reloc_size (howto))
2c2fa1
     return bfd_reloc_outofrange;
2c2fa1
 
2c2fa1
   /* Work out which section the relocation is targeted at and the
2c2fa1
@@ -7623,10 +7628,6 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
2c2fa1
 	      (*parent)->howto = &none_howto;
2c2fa1
 	      r = bfd_reloc_ok;
2c2fa1
 	    }
2c2fa1
-	  /* PR 17512: file: c146ab8b.  */
2c2fa1
-	  else if ((*parent)->address * bfd_octets_per_byte (abfd)
2c2fa1
-		   >= bfd_get_section_size (input_section))
2c2fa1
-	    r = bfd_reloc_outofrange;
2c2fa1
 	  else
2c2fa1
 	    r = bfd_perform_relocation (input_bfd,
2c2fa1
 					*parent,