commit:     63ade68e90d9dd80f9d6419b0fdba04c7d1f9421
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 13:07:05 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 13:07:05 2026 +0000
URL:        
https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/commit/?id=63ade68e

9999: add patch for slow Rust link

Bug: https://sourceware.org/PR33765
Signed-off-by: Sam James <sam <AT> gentoo.org>

 9999/0005-slow-link.patch | 70 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/9999/0005-slow-link.patch b/9999/0005-slow-link.patch
new file mode 100644
index 0000000..9166486
--- /dev/null
+++ b/9999/0005-slow-link.patch
@@ -0,0 +1,70 @@
+https://sourceware.org/bugzilla/show_bug.cgi?id=33765#c7
+--- a/bfd/elfxx-x86.c
++++ b/bfd/elfxx-x86.c
+@@ -1011,7 +1011,7 @@ elf_x86_relative_reloc_record_add
+    struct elf_x86_relative_reloc_data *relative_reloc,
+    Elf_Internal_Rela *rel, asection *sec,
+    asection *sym_sec, struct elf_link_hash_entry *h,
+-   Elf_Internal_Sym *sym, bfd_vma offset, bool *keep_symbuf_p)
++   Elf_Internal_Sym *sym, bfd_vma offset)
+ {
+   bfd_size_type newidx;
+ 
+@@ -1055,8 +1055,6 @@ elf_x86_relative_reloc_record_add
+     {
+       relative_reloc->data[newidx].sym = sym;
+       relative_reloc->data[newidx].u.sym_sec = sym_sec;
+-      /* We must keep the symbol buffer since SYM will be used later.  */
+-      *keep_symbuf_p = true;
+     }
+   relative_reloc->data[newidx].offset = offset;
+   relative_reloc->data[newidx].address = 0;
+@@ -1087,7 +1085,6 @@ _bfd_x86_elf_link_relax_section (bfd *abfd 
ATTRIBUTE_UNUSED,
+   bool is_x86_64;
+   bool unaligned_section;
+   bool return_status = false;
+-  bool keep_symbuf = false;
+ 
+   /* Assume we're not going to change any sizes, and we'll only need
+      one pass.  */
+@@ -1278,8 +1275,7 @@ _bfd_x86_elf_link_relax_section (bfd *abfd 
ATTRIBUTE_UNUSED,
+         if (!elf_x86_relative_reloc_record_add (info,
+                                                 &htab->relative_reloc,
+                                                 irel, htab->elf.sgot,
+-                                                sec, h, isym, offset,
+-                                                &keep_symbuf))
++                                                sec, h, isym, offset))
+           goto error_return;
+ 
+         continue;
+@@ -1348,8 +1344,7 @@ _bfd_x86_elf_link_relax_section (bfd *abfd 
ATTRIBUTE_UNUSED,
+                ((unaligned_section || unaligned_offset)
+                 ? &htab->unaligned_relative_reloc
+                 : &htab->relative_reloc),
+-               irel, input_section, sec, h, isym, offset,
+-               &keep_symbuf))
++               irel, input_section, sec, h, isym, offset))
+           goto error_return;
+       }
+     }
+@@ -1359,14 +1354,12 @@ _bfd_x86_elf_link_relax_section (bfd *abfd 
ATTRIBUTE_UNUSED,
+   return_status = true;
+ 
+ error_return:
+-  if ((unsigned char *) isymbuf != symtab_hdr->contents)
+-    {
+-      /* Cache the symbol buffer if it must be kept.  */
+-      if (keep_symbuf)
+-      symtab_hdr->contents = (unsigned char *) isymbuf;
+-      else
+-      free (isymbuf);
+-    }
++  if (isymbuf != NULL
++      && (unsigned char *) isymbuf != symtab_hdr->contents)
++    /* Cache the symbol buffer to avoid loading it again.  If the input
++       has many code sections, loading the same symbol table over and
++       over can take a long time.  */
++    symtab_hdr->contents = (unsigned char *) isymbuf;
+   if (elf_section_data (input_section)->relocs != internal_relocs)
+     free (internal_relocs);
+   return return_status;

Reply via email to