This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] merge_gnu_build_notes reloc deletion


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

commit ee7e95efb98186c09dc2c39b32263aa15b147bb0
Author: Alan Modra <amodra@gmail.com>
Date:   Mon May 1 14:11:27 2017 +0930

    merge_gnu_build_notes reloc deletion
    
    If moving relocs, the next reloc to look at is at the same location.
    
    	* objcopy.c (merge_gnu_build_notes): Correct code deleting
    	relocs.

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

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9eea3a0..ae8defb 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-01  Alan Modra  <amodra@gmail.com>
+
+	* objcopy.c (merge_gnu_build_notes): Correct code deleting
+	relocs.
+
 2017-04-28  Nick Clifton  <nickc@redhat.com>
 
 	PR binutils/21439
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9bad4b7..42c7775 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2185,15 +2185,18 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte
 
       if (relcount > 0)
 	{
-	  arelent ** rel;
+	  arelent **rel = relpp;
 
-	  for (rel = relpp; rel < relpp + relcount; rel ++)
-	    if ((* rel)->howto == NULL)
+	  while (rel < relpp + relcount)
+	    if ((*rel)->howto != NULL)
+	      rel++;
+	    else
 	      {
 		/* Delete eliminated relocs.
 		   FIXME: There are better ways to do this.  */
-		memmove (rel, rel + 1, ((relcount - (rel - relpp)) - 1) * sizeof (* rel));
-		relcount --;
+		memmove (rel, rel + 1,
+			 ((relcount - (rel - relpp)) - 1) * sizeof (*rel));
+		relcount--;
 	      }
 	  bfd_set_reloc (abfd, sec, relpp, relcount);
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]