]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove one unnecessary iteration in insertion sort
authorAlan Modra <amodra@gmail.com>
Thu, 17 Sep 2015 03:23:29 +0000 (12:53 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Sep 2015 03:16:18 +0000 (12:46 +0930)
PR 18867
* elflink.c (elf_link_adjust_relocs): Correct start of insertion
sort main loop.

bfd/ChangeLog
bfd/elflink.c

index bff0c56432b0caf0120a25a29e963c180486cae8..da5f88625008ee385bc3afc4ac9a80fb2d7ce7fb 100644 (file)
@@ -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
index a754ac524379191c3302f9666c72a1433b7c1401..076fa6d9c0d072a73cede8d4a9dc1445ab431ce5 100644 (file)
@@ -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);