This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH, AArch64] Improve relocation error check in elf64_aarch64_check_relocs.
- From: Will Newton <will dot newton at linaro dot org>
- To: binutils at sourceware dot org
- Cc: patches at linaro dot org
- Date: Fri, 26 Apr 2013 16:12:28 +0100
- Subject: [PATCH, AArch64] Improve relocation error check in elf64_aarch64_check_relocs.
There doesn't seem to be a good reason why this check should only be
applied to local symbols. Move the check up and add an error message
similar to the x86_64 port. Take advantage of the fact that
elf64_aarch64_howto_from_type does error checking for us - if it
returns NULL then the relocation was not recognized.
bfd/ChangeLog:
2013-04-26 Will Newton <will.newton@linaro.org>
* elf64-aarch64.c (elf64_aarch64_check_relocs): Move relocation
error check up and add error message.
---
bfd/elf64-aarch64.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/bfd/elf64-aarch64.c b/bfd/elf64-aarch64.c
index 9a6d8b4..e3cae95 100644
--- a/bfd/elf64-aarch64.c
+++ b/bfd/elf64-aarch64.c
@@ -4306,6 +4306,14 @@ elf64_aarch64_relocate_section (bfd *output_bfd,
bfd_reloc.howto = elf64_aarch64_howto_from_type (r_type);
howto = bfd_reloc.howto;
+ if (howto == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%B: unrecognized relocation (0x%x) in section `%A'"),
+ input_bfd, input_section, r_type);
+ return FALSE;
+ }
+
h = NULL;
sym = NULL;
sec = NULL;
@@ -4330,12 +4338,6 @@ elf64_aarch64_relocate_section (bfd *output_bfd,
return FALSE;
}
- if (r_type >= R_AARCH64_dyn_max)
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
}
else
--
1.8.1.4