]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas obj-coff memory leaks
authorAlan Modra <amodra@gmail.com>
Wed, 12 Feb 2025 21:55:01 +0000 (08:25 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 13 Feb 2025 21:56:42 +0000 (08:26 +1030)
commitd1c34b3c05760afac3fbf6b1dd7c7b7a0732275c
treecbbaf0e6bd04ff66db191269316abe060845246c
parent27c6f1271bacc44552f612ce8a801d725dabb6cf
gas obj-coff memory leaks

This patch addresses memory leaks in gas that show up when running the
testsuite on x86_64-w64-mingw32.  The seh_ctx_cur, and weak sym naming
leaks can occur many times during assembly.  The symbol hook and
section leaks are not so important since this memory needs to persist
until closing the output bfd.

* config/obj-coff-seh.c (do_seh_endproc): Free seh_ctx_cur and
its fields.
* config/obj-coff-seh.h (struct seh_context): Remove unused
"next" field.
* config/obj-coff.c (coff_obj_symbol_new_hook): Use notes_alloc
for aux entries.
(coff_obj_symbol_clone_hook): Likewise.
(obj_coff_def): Don't strdup name unless we need to do so
for tc_canonicalize_symbol_name.  Free after making symbol.
(weak_name2altname, weak_altname2name): Return a char*.
(weak_uniquify): Use notes_concat.
(pecoff_obj_set_weak_hook, pecoff_obj_clear_weak_hook): Free name
returned by weak_name2altname.
(coff_frob_symbol): Similarly for weak_altname2name.
(obj_coff_section): Use notes_memdup0.
* symbols.h: Add include guard.
(notes_memdup0): New inline function.
gas/config/obj-coff-seh.c
gas/config/obj-coff-seh.h
gas/config/obj-coff.c
gas/symbols.h