Speed up objcopy's note merging algorithm. (#29993)

This commit is contained in:
Nick Clifton 2023-01-18 11:27:31 +00:00
parent 6765525905
commit 66f76524de
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,44 @@
--- binutils.orig/binutils/objcopy.c 2023-01-16 12:15:46.405649346 +0000
+++ binutils-2.39/binutils/objcopy.c 2023-01-16 12:16:48.892667868 +0000
@@ -2383,6 +2383,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.
@@ -2404,7 +2406,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;
@@ -2466,11 +2470,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. */

View File

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug} Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.39 Version: 2.39
Release: 7%{?dist} Release: 8%{?dist}
License: GPLv3+ License: GPLv3+
URL: https://sourceware.org/binutils URL: https://sourceware.org/binutils
@ -315,6 +315,10 @@ Patch23: binutils-libiberty-configure-compile-warnings.patch
# Lifetime: Fixed in 2.40 # Lifetime: Fixed in 2.40
Patch24: binutils-CVE-2022-4285.patch Patch24: binutils-CVE-2022-4285.patch
# Purpose: Speed up objcopy's note merging algorithm.
# Lifetime: Fixed in 2.41
Patch25: binutils-objcopy-note-merge-speedup.patch
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
Provides: bundled(libiberty) Provides: bundled(libiberty)
@ -971,6 +975,9 @@ exit 0
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%changelog %changelog
* Mon Jan 16 2023 Nick Clifton <nickc@redhat.com> - 2.39-8
- Speed up objcopy's note merging algorithm. (#29993)
* Tue Dec 13 2022 Nick Clifton <nickc@redhat.com> - 2.39-7 * Tue Dec 13 2022 Nick Clifton <nickc@redhat.com> - 2.39-7
- Fix a potential dereference of a NULL pointer. (#2152946) - Fix a potential dereference of a NULL pointer. (#2152946)