From 7ed6f92aaffdcc0995b0247379fb8ea621854dce Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 4 Apr 2018 02:00:48 +0100 Subject: PR binutils/22875: MIPS/ELF: Also fail with relocation placeholders Do not consider placeholder EMPTY_HOWTO relocation entries valid in `rtype_to_howto' MIPS handlers. Instead issue an unsupported relocation type error and return a NULL howto as with relocations outside the three ISA-specific min-max ranges. bfd/ * elf32-mips.c (mips_elf32_rtype_to_howto): Also return unsuccessfully for placeholder howtos. * elf64-mips.c (mips_elf64_rtype_to_howto): Likewise. * elfn32-mips.c (mips_elf_n32_rtype_to_howto): Likewise. --- bfd/elf32-mips.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'bfd/elf32-mips.c') diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index c3c96a4..87147b5 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2198,6 +2198,8 @@ mips_elf32_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p ATTRIBUTE_UNUSED) { + reloc_howto_type *howto = NULL; + switch (r_type) { case R_MIPS_GNU_VTINHERIT: @@ -2216,17 +2218,18 @@ mips_elf32_rtype_to_howto (bfd *abfd, return &elf_mips_eh_howto; default: if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max) - return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min]; + howto = &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min]; if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max) - return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min]; - if (r_type >= (unsigned int) R_MIPS_max) - { - _bfd_error_handler (_("%pB: unsupported relocation type %#x"), - abfd, r_type); - bfd_set_error (bfd_error_bad_value); - return NULL; - } - return &elf_mips_howto_table_rel[r_type]; + howto = &elf_mips16_howto_table_rel[r_type - R_MIPS16_min]; + if (r_type < R_MIPS_max) + howto = &elf_mips_howto_table_rel[r_type]; + if (howto != NULL && howto->name != NULL) + return howto; + + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return NULL; } } -- cgit v1.1