You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mingw-binutils/SOURCES/binutils-objcopy-note-merge...

46 lines
1.6 KiB

diff -rupN --no-dereference binutils-2.40/binutils/objcopy.c binutils-2.40-new/binutils/objcopy.c
--- binutils-2.40/binutils/objcopy.c 2023-01-14 01:00:00.000000000 +0100
+++ binutils-2.40-new/binutils/objcopy.c 2023-03-09 14:52:06.043249302 +0100
@@ -2403,6 +2403,8 @@ merge_gnu_build_notes (bfd * ab
other note then if they are both of the same type (open
or func) then they can be merged and one deleted. If
they are of different types then they cannot be merged. */
+ objcopy_internal_note * prev_note = NULL;
+
for (pnote = pnotes; pnote < pnotes_end; pnote ++)
{
/* Skip already deleted notes.
@@ -2424,7 +2426,9 @@ merge_gnu_build_notes (bfd * ab
objcopy_internal_note * back;
/* Rule 2: Check to see if there is an identical previous note. */
- for (iter = 0, back = pnote - 1; back >= pnotes; back --)
+ for (iter = 0, back = prev_note ? prev_note : pnote - 1;
+ back >= pnotes;
+ back --)
{
if (is_deleted_note (back))
continue;
@@ -2486,11 +2490,18 @@ merge_gnu_build_notes (bfd * ab
break;
}
}
-#if DEBUG_MERGE
+
+
if (! is_deleted_note (pnote))
- merge_debug ("Unable to do anything with note at %#08lx\n",
- (pnote->note.namedata - (char *) contents) - 12);
+ {
+ /* Keep a pointer to this note, so that we can
+ start the next search for rule 2 matches here. */
+ prev_note = pnote;
+#if DEBUG_MERGE
+ merge_debug ("Unable to do anything with note at %#08lx\n",
+ (pnote->note.namedata - (char *) contents) - 12);
#endif
+ }
}
/* Resort the notes. */