[binutils-gdb] bfd: release the PE COMDAT hash once all sections are made
Jan Beulich via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=81d6f0640e78b4987b09690451d4edd80b55217f commit 81d6f0640e78b4987b09690451d4edd80b55217f Author: Oleg Tolmatcev <[email protected]> Date: Wed Aug 26 08:58:11 2026 +0200 bfd: release the PE COMDAT hash once all sections are made 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() would recreate the hash whenever it finds it NULL. Presently that wouldn't ever come into play, though. This significantly reduces peak memory usage. bfd/ * coffgen.c (coff_real_object_p): Free the COMDAT hash after the section table has been built. Signed-off-by: Oleg Tolmatcev <[email protected]> Diff: --- bfd/coffgen.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index f3060642a5d..92b867bd187 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -368,6 +368,13 @@ coff_real_object_p (bfd *abfd, } _bfd_coff_free_symbols (abfd); + + if (obj_pe (abfd) && pe_data (abfd)->comdat_hash != NULL) + { + htab_delete (pe_data (abfd)->comdat_hash); + pe_data (abfd)->comdat_hash = NULL; + } + return coff_object_cleanup; fail: