From 375de94a5e426b8277598a5f4d9e036b4b5d8b30 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 29 Jun 2007 01:51:55 +0000 Subject: [PATCH] * elf32-ppc.c (ppc_elf_info_to_howto): Check for invalid relocation types. --- bfd/ChangeLog | 5 +++++ bfd/elf32-ppc.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e89264fec1c..9cf09dfea89 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-06-29 Nathan Froyd + + * elf32-ppc.c (ppc_elf_info_to_howto): Check for invalid relocation + types. + 2007-06-29 Alan Modra * elf32-spu.c (spu_elf_fake_sections): New function. diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 0e36be65ad8..b84f0af2ad8 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -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. */ -- 2.30.2