From 22af7cb3ad6c0479d714410cdc945938d67705ac Mon Sep 17 00:00:00 2001 From: hjl Date: Sat, 9 Apr 2011 15:37:56 +0000 Subject: [PATCH] Return relocation error on unsupported relocation. 2011-04-09 H.J. Lu * elf32-i386.c (elf_i386_relocate_section): Return relocation error on unsupported relocation. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-i386.c | 7 ++++++- bfd/elf64-x86-64.c | 9 +++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c745c2ac3d..a7242776c6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2011-04-09 H.J. Lu + * elf32-i386.c (elf_i386_relocate_section): Return relocation + error on unsupported relocation. + * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. + +2011-04-09 H.J. Lu + PR binutils/12657 * hosts/x86-64linux.h (elf_prstatus32): Replace __pid_t with pid_t. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 1b76cb4a45..acabeb31f4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -3451,7 +3451,11 @@ elf_i386_relocate_section (bfd *output_bfd, sreloc = elf_section_data (input_section)->sreloc; - BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL); + if (sreloc == NULL || sreloc->contents == NULL) + { + r = bfd_reloc_notsupported; + goto check_relocation_error; + } loc = sreloc->contents; loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel); @@ -4096,6 +4100,7 @@ do_relocation: contents, rel->r_offset, relocation, 0); +check_relocation_error: if (r != bfd_reloc_ok) { const char *name; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 927b3ed4a5..ea837a3946 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3411,7 +3411,11 @@ elf_x86_64_relocate_section (bfd *output_bfd, sreloc = elf_section_data (input_section)->sreloc; - BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL); + if (sreloc == NULL || sreloc->contents == NULL) + { + r = bfd_reloc_notsupported; + goto check_relocation_error; + } elf_append_rela (output_bfd, sreloc, &outrel); @@ -3868,6 +3872,7 @@ do_relocation: contents, rel->r_offset, relocation, rel->r_addend); +check_relocation_error: if (r != bfd_reloc_ok) { const char *name; @@ -3896,7 +3901,7 @@ do_relocation: else { (*_bfd_error_handler) - (_("%B(%A+0x%lx): reloc against `%s': error %d"), + (_("%B(%A+0x%lx): reloc against `%s': error %r"), input_bfd, input_section, (long) rel->r_offset, name, (int) r); return FALSE; -- 2.11.0