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/binutils-2_25-branch] Remove one unnecessary iteration in insertion sort


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

commit 352d25d9bb6dff7b30d1c6a4f4c6192572c8e817
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Sep 17 12:53:29 2015 +0930

    Remove one unnecessary iteration in insertion sort
    
    	PR 18867
    	* elflink.c (elf_link_adjust_relocs): Correct start of insertion
    	sort main loop.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/elflink.c | 6 ++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index bff0c56..da5f886 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-17  Alan Modra  <amodra@gmail.com>
+
+	PR 18867
+	* elflink.c (elf_link_adjust_relocs): Correct start of insertion
+	sort main loop.
+
 2015-09-16  Alan Modra  <amodra@gmail.com>
 
 	PR 18867
diff --git a/bfd/elflink.c b/bfd/elflink.c
index a754ac5..076fa6d 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8172,7 +8172,7 @@ elf_link_adjust_relocs (bfd *abfd,
 	  memcpy (base, onebuf, elt_size);
 	}
 
-      for (p = base + elt_size; p < end; )
+      for (p = base + elt_size; (p += elt_size) < end; )
 	{
 	  /* base to p is sorted, *p is next to insert.  */
 	  r_off = (*ext_r_off) (p);
@@ -8214,10 +8214,8 @@ elf_link_adjust_relocs (bfd *abfd,
 		  memmove (loc, p, runlen);
 		  memcpy (loc + runlen, buf, sortlen);
 		}
-	      p += runlen;
+	      p += runlen - elt_size;
 	    }
-	  else
-	    p += elt_size;
 	}
       /* Hashes are no longer valid.  */
       free (reldata->hashes);


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