From b29b8669ad250df649a0f02c5575e7163a2cd9e4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 17 Sep 2015 12:53:29 +0930 Subject: [PATCH] Remove one unnecessary iteration in insertion sort PR 18867 * elflink.c (elf_link_adjust_relocs): Correct start of insertion sort main loop. --- bfd/ChangeLog | 6 ++++++ bfd/elflink.c | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a99c2e0bad4..26a05378dce 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2015-09-17 Alan Modra + + PR 18867 + * elflink.c (elf_link_adjust_relocs): Correct start of insertion + sort main loop. + 2015-09-16 Alan Modra PR 18867 diff --git a/bfd/elflink.c b/bfd/elflink.c index 8659099df0d..4e52d7bf090 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8313,7 +8313,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); @@ -8355,10 +8355,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); -- 2.30.2