]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld plugin bfd_make_readable leak
authorAlan Modra <amodra@gmail.com>
Wed, 22 Jan 2025 23:54:46 +0000 (10:24 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 23 Jan 2025 05:10:09 +0000 (15:40 +1030)
commit3097045a18a8878bc40548bd0995f9bad5609c43
tree51bf4955c5eed8bc04338b29201aa7117acd460c
parentee8f3b6c78e1df055184635aedfe0ac1333a6706
ld plugin bfd_make_readable leak

bfd_make_readable leaks memory that could be freed by
_free_cached_info except that does too much in releasing all bfd
memory.  (The fact that we had to hack around keeping the bfd filename
also indicates that releasing all bfd memory was too much.)  So this
patch moves code releasing bfd_alloc'd memory to the COFF
_free_cached_info, where the syms and suchlike are released.  This is
the memory that archive handling wants to release in the call there to
bfd_free_cached_info.

* coffgen.c (_bfd_coff_free_cached_info): Release syms.
* opncls.c (_bfd_new_bfd): Correct error return path.
(_bfd_free_cached_info): Don't kill all abfd->memory.
(_bfd_delete_bfd): Adjust fallback for bfd_free_cached_info.
(bfd_make_readable): Call target bfd_free_cached_info and
_bfd_free_cached_info plus reinstate section_htab.
bfd/coffgen.c
bfd/opncls.c