This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc with no associa
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 19 Feb 2016 15:21:13 -0000
- Subject: [binutils-gdb] Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc with no associa
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=737684142b3f7dfa6d440c8363750911a8ac20ce
commit 737684142b3f7dfa6d440c8363750911a8ac20ce
Author: Nick Clifton <nickc@redhat.com>
Date: Fri Feb 19 15:20:30 2016 +0000
Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc with no associated symbol.
PR ld/19628
* reloc.c (bfd_generic_get_relocated_section_contents): Stop
processing if we encounter a reloc without an associated symbol.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/reloc.c | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1c9e201..b1b4047 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-19 Nick Clifton <nickc@redhat.com>
+
+ PR ld/19628
+ * reloc.c (bfd_generic_get_relocated_section_contents): Stop
+ processing if we encounter a reloc without an associated symbol.
+
2016-02-18 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19617
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 3ef704f..a1683d8 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -7939,6 +7939,7 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
if (reloc_count > 0)
{
arelent **parent;
+
for (parent = reloc_vector; *parent != NULL; parent++)
{
char *error_message = NULL;
@@ -7946,6 +7947,16 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
bfd_reloc_status_type r;
symbol = *(*parent)->sym_ptr_ptr;
+ /* PR ld/19628: A specially crafted input file
+ can result in a NULL symbol pointer here. */
+ if (symbol == NULL)
+ {
+ link_info->callbacks->einfo
+ (_("%X%P: %B(%A): error: relocation for offset %V has no value\n"),
+ abfd, input_section, (* parent)->address);
+ goto error_return;
+ }
+
if (symbol->section && discarded_section (symbol->section))
{
bfd_byte *p;