Confusion in coff_object_cleanup

A bfd_cleanup function needs to run when only tdata is correct for the
bfd.  The xvec may have changed during bfd_check_format and thus the
flavour may be incorrect.  The format won't have changed but checking
is superfluous.  (In contrast to _bfd_free_cached_info or
_close_and_cleanup where we do need to check things.)

Not getting this correct leaked comdat_hash.

Also, pe_ILF_cleanup ought to call coff_object_cleanup as do all PE
files.

	* coffgen.c (coff_object_cleanup): Don't check bfd flavour or
	format.
	* peicode.h (pe_ILF_cleanup): Call coff_object_cleanup.
This commit is contained in:
Alan Modra
2023-08-27 12:57:16 +09:30
parent 398f1ddf5e
commit 26d0081b52
2 changed files with 10 additions and 11 deletions

View File

@@ -1180,6 +1180,8 @@ pe_ILF_build_a_bfd (bfd * abfd,
static void
pe_ILF_cleanup (bfd *abfd)
{
coff_object_cleanup (abfd);
struct bfd_in_memory *bim = abfd->iostream;
free (bim->buffer);
free (bim);