OSDN Git Service

* elf32-ppc.c (ppc_elf_info_to_howto): Check for invalid relocation
authorAlan Modra <amodra@bigpond.net.au>
Fri, 29 Jun 2007 01:51:55 +0000 (01:51 +0000)
committerAlan Modra <amodra@bigpond.net.au>
Fri, 29 Jun 2007 01:51:55 +0000 (01:51 +0000)
types.

bfd/ChangeLog
bfd/elf32-ppc.c

index e89264f..9cf09df 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-29  Nathan Froyd  <froydnj@codesourcery.com>
+
+       * elf32-ppc.c (ppc_elf_info_to_howto): Check for invalid relocation
+       types.
+
 2007-06-29  Alan Modra  <amodra@bigpond.net.au>
 
        * elf32-spu.c (spu_elf_fake_sections): New function.
index 0e36be6..b84f0af 100644 (file)
@@ -1607,6 +1607,17 @@ ppc_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
   BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
   cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
+
+  /* Just because the above assert didn't trigger doesn't mean that
+     ELF32_R_TYPE (dst->r_info) is necessarily a valid relocation.  */
+  if (!cache_ptr->howto)
+    {
+      (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
+                             abfd, ELF32_R_TYPE (dst->r_info));
+      bfd_set_error (bfd_error_bad_value);
+
+      cache_ptr->howto = ppc_elf_howto_table[R_PPC_NONE];
+    }
 }
 
 /* Handle the R_PPC_ADDR16_HA and R_PPC_REL16_HA relocs.  */