Re: [PATCH] bfd: release the PE COMDAT hash once all sections are made

Oleg Tolmatcev <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <CACcXsZjS_2d-x-zPEYNVQ=bQEFWsCt+OM7O7Wi1gSv82rr_Oxw@mail.gmail.com>
пт, 21 авг. 2026 г. в 13:51, Jan Beulich <[email protected]>:
>
> On 20.08.2026 21:23, Oleg Tolmatcev wrote:
> > styp_to_sec_flags builds pe_data (abfd)->comdat_hash, one entry plus a
> > strdup'd symbol name per input section.  Nothing frees it during a link,
> > so it survives to exit.
> >
> > Free it once the section table has been built.  This is safe because
> > styp_to_sec_flags recreates the hash whenever it finds it NULL.
> >
> > This significantly reduces peak memory usage.
>
> This is the positive side. How much extra overhead does recreating the
> hash impose? How often might it need recreating in the worst case? Looks
> like the answer is zero / never (make_a_section_from_file() is called
> solely from coff_real_object_p(), and is the sole caller of
> bfd_coff_styp_to_sec_flags_hook()), but your description suggests
> otherwise. May I suggest to replace the paragraph with
>
> "Free it once the section table has been built.  This is safe because
>  styp_to_sec_flags() would recreate the hash whenever it finds it NULL.
>  That's not presently necessary, though."
>
> ? If that's okay with you, I can replace the piece of text while
> committing.
>
> Jan

I am of course okay with that too. Thank you.

Oleg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.