[PATCH v2] elf: Cache full internal symbol table for relocatable input
Jan Beulich
jbeulich@suse.com
Fri Oct 17 12:48:24 GMT 2025
On 11.10.2025 08:37, H.J. Lu wrote:
> On Sat, Oct 11, 2025 at 9:08 AM Sam James <sam@gentoo.org> wrote:
>>
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>>> Add bfd_elf_get_elf_syms_cached to cache internal symbol table for
>>> relocatable input and use the internal symbol table cache for both local
>>> and global symbols to avoid swapping in the same symbol table repeatedly
>>> for --gc-sections. This improves linker --gc-sections speed by ~2x for
>>> PR ld/33530.
>>>
>>> elf_link_input_bfd is updated to not to pass preallocated buffers to
>>> bfd_elf_get_elf_syms_cache.
>>
>> All tests pass now for me, including:
>>
>> === libctf Summary ===
>>
>> # of expected passes 39
>> # of unsupported tests 1
>>
>> I'll test it more in the wild tonight and tomorrow.
>
> Here is the v2 patch to keep bfd_elf_get_elf_syms interface unchanged.
What I can't spot are provisions towards systems with little memory available,
like possibly 32-bit ones. (I'm sure you're aware of ld's --no-keep-memory
option.)
In the 2nd hunk altering the body of what was bfd_elf_get_elf_syms(), may I
ask that in the body of the outermost if() you use an if/else-if/else chain,
to reduce indentation some?
The patch also could do with splitting up some. At the first glance it looks
as if e.g. the reloc-cookie related changes could as well be a separate,
follow-on change.
Jan
More information about the Binutils
mailing list