summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elfcode.h6
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/objcopy.c27
-rw-r--r--binutils/testsuite/binutils-all/note-2-64.d4
5 files changed, 39 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 455153c22a7..7f59fa01a1d 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 80b26aa803a..00684d59607 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;
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 058ebf38bec..4f29d19c315 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-08 Nick Clifton <nickc@redhat.com>
+
+ * 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.
+
2017-12-06 Jim Wilson <jimw@sifive.com>
PR 22465
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index f40b355c14b..5026fd8af21 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3785,14 +3785,24 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
}
else
{
- relpp = (arelent **) xmalloc (relsize);
- relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
- if (relcount < 0)
+ if (isection->orelocation != NULL)
{
- status = 1;
- bfd_nonfatal_message (NULL, ibfd, isection,
- _("relocation count is negative"));
- return;
+ /* Some other function has already set up the output relocs
+ for us, so scan those instead of the default relocs. */
+ relcount = isection->reloc_count;
+ relpp = isection->orelocation;
+ }
+ else
+ {
+ relpp = (arelent **) xmalloc (relsize);
+ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
+ if (relcount < 0)
+ {
+ status = 1;
+ bfd_nonfatal_message (NULL, ibfd, isection,
+ _("relocation count is negative"));
+ return;
+ }
}
if (strip_symbols == STRIP_ALL)
@@ -3815,7 +3825,8 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
temp_relpp [temp_relcount++] = relpp [i];
}
relcount = temp_relcount;
- free (relpp);
+ if (isection->orelocation == NULL)
+ free (relpp);
relpp = temp_relpp;
}
diff --git a/binutils/testsuite/binutils-all/note-2-64.d b/binutils/testsuite/binutils-all/note-2-64.d
index 85358213a2c..f9be89756ae 100644
--- a/binutils/testsuite/binutils-all/note-2-64.d
+++ b/binutils/testsuite/binutils-all/note-2-64.d
@@ -3,6 +3,10 @@
#objcopy: --merge-notes
#name: merge notes section (64-bits)
#source: note-2-64.s
+#not-target: sparc64-*-*
+# Internally the Sparc64 backend uses two relocs for every one reloc visible externally.
+# Unfortunately the BFD library does not provide a target specific way to delete individual
+# relocs, so the note merging feature fails.
#...
Owner Data size Description