diff options
author | Nick Clifton <nickc@redhat.com> | 2019-06-26 17:03:32 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2019-06-26 17:03:32 +0100 |
commit | a68aa5d3020948564ef99d704d27e458ba22ad9d (patch) | |
tree | e413d62d4438b6a7605e7771c0028d89eba01e97 /bfd/mach-o.c | |
parent | 762c164d754fc456aa4764d2ed19cc4a3ec625fb (diff) | |
download | gdb-a68aa5d3020948564ef99d704d27e458ba22ad9d.zip gdb-a68aa5d3020948564ef99d704d27e458ba22ad9d.tar.gz gdb-a68aa5d3020948564ef99d704d27e458ba22ad9d.tar.bz2 |
Ensure that when attempting to process an ARM Mach-O file with unknown relocs, that a suitable error message is displayed.
PR 24703
binutils* bucomm.c (bfd_nonfatal): If no bfd error code has been set then
indicate this in the output.
(bfd_nonfatal_message): Likewise.
bfd * mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add error
messages for failures.
* mach-o.c (bfd_mach_o_canonicalize_relocs): Set an bfd error code
if returning an error value.
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r-- | bfd/mach-o.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c index d9edef2..4e64086 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -1501,7 +1501,11 @@ bfd_mach_o_canonicalize_non_scattered_reloc (bfd *abfd, { /* PR 17512: file: 006-2964-0.004. */ if (num > mdata->nsects) - return FALSE; + { + _bfd_error_handler (_("\ +malformed mach-o reloc: section index is greater than the number of sections")); + return FALSE; + } /* A section number. */ sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr; @@ -1609,7 +1613,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, { bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd); unsigned long i; - struct mach_o_reloc_info_external *native_relocs; + struct mach_o_reloc_info_external *native_relocs = NULL; bfd_size_type native_size; /* Allocate and read relocs. */ @@ -1617,7 +1621,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, /* PR 17512: file: 09477b57. */ if (native_size < count) - return -1; + goto err; native_relocs = (struct mach_o_reloc_info_external *) bfd_malloc (native_size); @@ -1636,8 +1640,11 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos, } free (native_relocs); return i; + err: free (native_relocs); + if (bfd_get_error () == bfd_error_no_error) + bfd_set_error (bfd_error_invalid_operation); return -1; } |