[binutils-gdb] Don't merge notes when the relocs associated with them cannot be reliably deleted.

Nick Clifton nickc@sourceware.org
Tue May 2 15:55:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1395c6ce47510babad3dcb9892f6f2517a3f2b59

commit 1395c6ce47510babad3dcb9892f6f2517a3f2b59
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue May 2 16:54:53 2017 +0100

    Don't merge notes when the relocs associated with them cannot be reliably deleted.
    
    	* objcopy.c (merge_gnu_build_notes): Disable merge if there are
    	more internal relocs than external relocs.

Diff:
---
 binutils/ChangeLog | 5 +++++
 binutils/objcopy.c | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index aef436d..d13dbb6 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-02  Nick Clifton  <nickc@redhat.com>
+
+	* objcopy.c (merge_gnu_build_notes): Disable merge if there are
+	more internal relocs than external relocs.
+
 2017-05-02  Maciej W. Rozycki  <macro@imgtec.com>
 
 	* testsuite/binutils-all/mips/mips16-undecoded.d: Adjust the
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 42c7775..36952ec 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2137,6 +2137,13 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte
 	    relcount = 0;
 	}
 
+      /* A few targets (eg MIPS, SPARC) create multiple internal relocs to
+	 represent a single external reloc.  Unfortunately the current BFD
+	 API does not handle deleting relocs in such situations very well
+	 and so it is unsafe to proceed.  */
+      if (relcount > sec->reloc_count)
+	goto done;
+
       /* Eliminate the duplicates.  */
       new = new_contents = xmalloc (size);
       for (pnote = pnotes, old = contents;



More information about the Binutils-cvs mailing list