[PATCH] bfd: release the PE COMDAT hash once all sections are made
Oleg Tolmatcev
oleg.tolmatcev@gmail.com
Thu Aug 20 19:23:46 GMT 2026
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.
bfd/
* coffgen.c (coff_real_object_p): Free the COMDAT hash after
the section table has been built.
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
---
bfd/coffgen.c | 7 +++++++
1 file changed, 7 insertions(+)
In one of my tests this reduces peak memory usage by 12%: 773 MB out of 6532 MB.
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:
--
2.55.0.windows.3
More information about the Binutils
mailing list