https://sourceware.org/bugzilla/show_bug.cgi?id=33530

--- Comment #13 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alan Modra <[email protected]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8b99ca44515b2b56f1492786e23522e4abbe8a96

commit 8b99ca44515b2b56f1492786e23522e4abbe8a96
Author: Alan Modra <[email protected]>
Date:   Thu Oct 30 16:26:50 2025 +1030

    Don't read and cache local syms for gc-sections

    Most places just need the local sym section, so reading and sometimes
    caching the symbols is excessive.  A symbol shndx can be stored in 4
    bytes, an elf symbol internal form requires 32 bytes.  When caching
    the local symbols we went slightly crazy trying to avoid memory usage,
    resulting in the symbols being freed then immediately read again for
    the testcase in the PR33530.

    To avoid this problem, this patch caches the local symbol section
    indices in the bfd rather than in the reloc cookie.  They are not
    initialised until there is a need for them, so unlike elf_sym_hashes
    for global syms you cannot rely on them being present.

    One place that does need local syms is adjust_eh_frame_local_symbols,
    but that is called once via bfd_discard_info so there is no problem
    simply reading them.  The other place that needs local syms is
    ppc64_elf_gc_mark_hook for the old ELFv1 ABI when handling .opd.
    bfd_sym_from_r_symndx should be sufficient for function pointer
    references to static functions, which is how this code is triggered.

            PR 33530
            * elf-bfd.h (struct elf_reloc_cookie): Delete "locsyms",
            "sym_hashes", "bad_symtab".  Make "locsymcount" and
            "extsymoff" unsigned int.
            (struct elf_obj_tdata): Add loc_shndx.
            (elf_loc_shndx): Define.
            (_bfd_get_local_sym_section): Declare.
            * elf-eh-frame.c (find_merged_cie): Use
            _bfd_get_local_sym_section for local syms.
            (adjust_eh_frame_local_symbols): Read local syms if any match
            .eh_frame section.  Return them if changed.
            (_bfd_elf_discard_section_eh_frame): Adjust.
            * elf64-ppc.c (ppc64_elf_gc_mark_hook): Use
            _bfd_get_local_sym_section.  Use bfd_sym_from_r_symndx when
            reading opd local symbol.
            * elflink.c (_bfd_get_local_sym_section): New function.
            (_bfd_elf_section_for_symbol): Use it.
            (elf_link_add_object_symbols): Remove unnecessary cast on
            bfd_zalloc return.
            (init_reloc_cookie): Remove "info" and "keep_memory" params.
            Adjust all callers.  Don't stash elf_sym_hashes and
            elf_bad_symtab to cookie.  Don't read local syms to cookie.
            (fini_reloc_cookie): Do nothing.
            (_bfd_elf_gc_mark_hook): Use _bfd_get_local_sym_section.
            (elf_gc_mark_debug_section): Likewise.
            (bfd_elf_reloc_symbol_deleted_p): Likewise.  Update cookie use.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to