diff --git a/Fix-slowdown-about-partial-linking.patch b/Fix-slowdown-about-partial-linking.patch new file mode 100644 index 0000000000000000000000000000000000000000..45aac57703c9167cd893541285b7743cb00ffd64 --- /dev/null +++ b/Fix-slowdown-about-partial-linking.patch @@ -0,0 +1,138 @@ +From 97eea7a09e8c7c72a763e21608a52cc0e07e3fc6 Mon Sep 17 00:00:00 2001 +From: Xin Wang +Date: Mon, 20 Jan 2025 14:46:44 +0800 +Subject: [PATCH] Fix slowdown about partial linking + +--- + ld/ldlang.c | 66 ++++++++++++++++++++++++++++++++++++----------------- + 1 file changed, 45 insertions(+), 21 deletions(-) + +diff --git a/ld/ldlang.c b/ld/ldlang.c +index a357f802..3b6b8563 100644 +--- a/ld/ldlang.c ++++ b/ld/ldlang.c +@@ -1246,6 +1246,7 @@ struct out_section_hash_entry + { + struct bfd_hash_entry root; + lang_statement_union_type s; ++ struct out_section_hash_entry *tail; + }; + + /* The hash table. */ +@@ -1255,10 +1256,10 @@ static struct bfd_hash_table output_section_statement_table; + /* Support routines for the hash table used by lang_output_section_find, + initialize the table, fill in an entry and remove the table. */ + +-static struct bfd_hash_entry * +-output_section_statement_newfunc (struct bfd_hash_entry *entry, +- struct bfd_hash_table *table, +- const char *string) ++static struct out_section_hash_entry * ++output_section_statement_newfunc_1 (struct bfd_hash_entry *entry, ++ struct bfd_hash_table *table, ++ const char *string) + { + lang_output_section_statement_type **nextp; + struct out_section_hash_entry *ret; +@@ -1268,12 +1269,12 @@ output_section_statement_newfunc (struct bfd_hash_entry *entry, + entry = (struct bfd_hash_entry *) bfd_hash_allocate (table, + sizeof (*ret)); + if (entry == NULL) +- return entry; ++ return NULL; + } + + entry = bfd_hash_newfunc (entry, table, string); + if (entry == NULL) +- return entry; ++ return NULL; + + ret = (struct out_section_hash_entry *) entry; + memset (&ret->s, 0, sizeof (ret->s)); +@@ -1298,6 +1299,20 @@ output_section_statement_newfunc (struct bfd_hash_entry *entry, + instead. */ + nextp = &ret->s.output_section_statement.next; + lang_statement_append (&lang_os_list, &ret->s, nextp); ++ return ret; ++} ++ ++static struct bfd_hash_entry * ++output_section_statement_newfunc (struct bfd_hash_entry *entry, ++ struct bfd_hash_table *table, ++ const char *string) ++{ ++ struct out_section_hash_entry *ret; ++ ++ ret = output_section_statement_newfunc_1 (entry, table, string); ++ if (ret == NULL) ++ return NULL; ++ ret->tail = ret; + return &ret->root; + } + +@@ -1523,31 +1538,39 @@ lang_output_section_statement_lookup (const char *name, + { + /* We have a section of this name, but it might not have the correct + constraint. */ ++ struct out_section_hash_entry *first_ent = entry; + struct out_section_hash_entry *last_ent; + + name = entry->s.output_section_statement.name; +- do ++ if (create != 2 ++ && !(create && constraint == SPECIAL)) + { +- if (create != 2 +- && !(create && constraint == SPECIAL) +- && (constraint == entry->s.output_section_statement.constraint ++ do ++ { ++ if (constraint == entry->s.output_section_statement.constraint + || (constraint == 0 +- && entry->s.output_section_statement.constraint >= 0))) +- return &entry->s.output_section_statement; +- last_ent = entry; +- entry = (struct out_section_hash_entry *) entry->root.next; ++ && entry->s.output_section_statement.constraint >= 0)) ++ return &entry->s.output_section_statement; ++ last_ent = entry; ++ entry = (struct out_section_hash_entry *) entry->root.next; ++ } ++ while (entry != NULL ++ && name == entry->s.output_section_statement.name); + } +- while (entry != NULL +- && name == entry->s.output_section_statement.name); ++ else ++ last_ent = first_ent->tail; + + if (!create) + return NULL; + +- entry +- = ((struct out_section_hash_entry *) +- output_section_statement_newfunc (NULL, +- &output_section_statement_table, +- name)); ++ /* Only the first entry needs the tail pointer. */ ++ entry = bfd_hash_allocate (&output_section_statement_table, ++ offsetof (struct out_section_hash_entry, tail)); ++ if (entry != NULL) ++ entry ++ = output_section_statement_newfunc_1 (&entry->root, ++ &output_section_statement_table, ++ name); + if (entry == NULL) + { + einfo (_("%F%P: failed creating section `%s': %E\n"), name); +@@ -1555,6 +1578,7 @@ lang_output_section_statement_lookup (const char *name, + } + entry->root = last_ent->root; + last_ent->root.next = &entry->root; ++ first_ent->tail = entry; + } + + entry->s.output_section_statement.name = name; +-- +2.33.0 + diff --git a/binutils.spec b/binutils.spec index cad71c7f2fc28bac6e381a14c60d94e2712bb156..038f4967bff9a2e6242dd732eed7b8bc39e58239 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?_with_debug:-debug} Version: 2.41 -Release: 14 +Release: 15 License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later URL: https://sourceware.org/binutils @@ -366,6 +366,11 @@ Patch5010: binutils-BPF-reloc-4.patch # BPF support enabled. # Lifetime: Permanent. Patch5011: binutils-gold-warn-unsupported.patch + +# Purpose: Fix slowdown about partial linking. +# Lifetime: Fixed in 2.44 +Patch5012: Fix-slowdown-about-partial-linking.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -1382,6 +1387,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Wed Feb 5 2025 wangxin - 2.41-15 +- Fix slowdown about partial linking + * Mon Jan 20 2025 Funda Wang - 2.41-14 - Add support for the BPF target (rh#1825193) - Accept and ignore R_BPF_64_NODYLD32 relocations (rh#2245296)