aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-12-08 10:07:14 +0000
committerNick Clifton <nickc@redhat.com>2017-12-08 10:07:14 +0000
commit2d054e6bfdfb0f58fb9cc501c29327df34fec697 (patch)
tree9ac200639d7ff30b0da20b6ad2d431a5bbb35b1e /bfd
parentc8bed57010e8789212a6841db4b397b175a00f9e (diff)
downloadfsf-binutils-gdb-2d054e6bfdfb0f58fb9cc501c29327df34fec697.zip
fsf-binutils-gdb-2d054e6bfdfb0f58fb9cc501c29327df34fec697.tar.gz
fsf-binutils-gdb-2d054e6bfdfb0f58fb9cc501c29327df34fec697.tar.bz2
Fix stripping relocs in a file with mergeable notes.
A recent Fedora bug (1520805) exposed a problem with objcopy's reloc copying code, when a binary also contains mergeable notes. The note merging code would delete some relocs, but then the reloc copying code would try to put them back again, which did not work. So I am checking in the patch below to fix the problem. The patch also tweaks one of the binutils note merging tests so that it is skipped for the Sparc64 target, since this has funky relocs. binutils * objcopy.c (copy_relocations_in_section): Use the orelocations field of the input section, if it has been initialised. * testsuite/binutils-all/note-2-64.d: Skip test on Sparc64. bfd * elfcode.h (elf_write_relocs): Check for an empty howto field.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elfcode.h6
2 files changed, 10 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 455153c..7f59fa0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2017-12-08 Nick Clifton <nickc@redhat.com>
+
+ * elfcode.h (elf_write_relocs): Check for an empty howto field.
+
2017-12-08 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
* bfd.c (bfd_get_sign_extend_vma): Handle aix5coff64-rs6000.
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 80b26aa..00684d5 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -958,6 +958,12 @@ elf_write_relocs (bfd *abfd, asection *sec, void *data)
return;
}
+ if (ptr->howto == NULL)
+ {
+ *failedp = TRUE;
+ return;
+ }
+
src_rela.r_offset = ptr->address + addr_offset;
src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
src_rela.r_addend = ptr->addend;