aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-05-01 14:11:27 +0930
committerAlan Modra <amodra@gmail.com>2017-05-01 14:13:31 +0930
commitee7e95efb98186c09dc2c39b32263aa15b147bb0 (patch)
tree9d98ce04b8d2257ceb50d609325160ae44a2d53d /binutils/objcopy.c
parent6224c858130fe5c5e5d8b2abdec1cea35986d9e7 (diff)
downloadgdb-ee7e95efb98186c09dc2c39b32263aa15b147bb0.zip
gdb-ee7e95efb98186c09dc2c39b32263aa15b147bb0.tar.gz
gdb-ee7e95efb98186c09dc2c39b32263aa15b147bb0.tar.bz2
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.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c13
1 files changed, 8 insertions, 5 deletions
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);
}