aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-sh.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-06-21 16:36:44 +0100
committerNick Clifton <nickc@redhat.com>2017-06-21 16:36:44 +0100
commit6879f5a99e25c068fec34126b6b0fe4325223aa0 (patch)
tree0c704ae4a8179615dca70cb52455ab8c3bfff15b /bfd/coff-sh.c
parent2234eee61c42ad3f4d17894236873e04b633e969 (diff)
downloadbinutils-6879f5a99e25c068fec34126b6b0fe4325223aa0.zip
binutils-6879f5a99e25c068fec34126b6b0fe4325223aa0.tar.gz
binutils-6879f5a99e25c068fec34126b6b0fe4325223aa0.tar.bz2
Fix addrss violation when processing a corrupt SH COFF binary.
PR binutils/21646 * coff-sh.c (sh_reloc): Check for an out of range reloc.
Diffstat (limited to 'bfd/coff-sh.c')
-rw-r--r--bfd/coff-sh.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index d76f98a..26d296b 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -596,6 +596,9 @@ sh_reloc (bfd * abfd,
&& bfd_is_und_section (symbol_in->section))
return bfd_reloc_undefined;
+ if (addr > input_section->size)
+ return bfd_reloc_outofrange;
+
sym_value = get_symbol_value (symbol_in);
switch (r_type)
@@ -2910,7 +2913,6 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
struct internal_reloc *internal_relocs = NULL;
struct internal_syment *internal_syms = NULL;
-fprintf (stderr, "DATA = %p\n", data);
/* We only need to handle the case of relaxing, or of having a
particular set of section contents, specially. */
if (relocatable