[PATCH v2] x86: Cache the symbol table when packing relative relocations

H.J. Lu hjl.tools@gmail.com
Sat Jan 10 02:27:57 GMT 2026


On Sat, Jan 10, 2026 at 7:53 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> When packing relative relocations, x86 linker may load the same symbol
> table repeatedly, which can take a long time.  On Intel Core i7-1195G7
> with 32GB RAM, it takes more than 45 minutes to create an output with
> -pie -z pack-relative-relocs from an input with 208025 code sections.
> Cache the symbol table to reduce the link time to less than 2 seconds.
>
> On the same machine, creating 3.1GB clang executable in LLVM 21.1.3 debug
> build:
>
> user            55.39 seconds
> system          6.71 seconds
> total           65.80 seconds
> maximum set(GB) 10.43
> page faults     2406941
>
> PR ld/33765
> * elfxx-x86.c (elf_x86_relative_reloc_record_add): Remove
> keep_symbuf_p.
> (_bfd_x86_elf_link_relax_section): Updated.  Cache the symbol
> table to avoid loading it again.
>
> --
> H.J.

Here is the v2 patch to cache the symbol table before the loop.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-x86-Cache-the-symbol-table-when-packing-relative-.patch
Type: text/x-patch
Size: 5271 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260110/863b147e/attachment.bin>


More information about the Binutils mailing list