diff options
author | Alan Modra <amodra@gmail.com> | 2022-08-16 00:16:49 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-08-16 00:25:10 +0930 |
commit | 450da4bd38ae529a6879baafe59b1e88507b5fd9 (patch) | |
tree | 7f7794e1b3bff3b9466a127cc10e296b6c9eeec3 /binutils/objcopy.c | |
parent | 105afa7f230e5fed8f5a2eb28bc14d7696f5ac72 (diff) | |
download | binutils-450da4bd38ae529a6879baafe59b1e88507b5fd9.zip binutils-450da4bd38ae529a6879baafe59b1e88507b5fd9.tar.gz binutils-450da4bd38ae529a6879baafe59b1e88507b5fd9.tar.bz2 |
PR29362, some binutils memory leaks
2022-08-16 Alan Modra <amodra@gmail.com>
Cunlong Li <shenxiaogll@163.com>
PR 29362
* dwarf.c (free_debug_information): New function, extracted..
(free_debug_memory): ..from here.
(process_debug_info): Use it when before clearing out unit
debug_information. Clear all fields.
* objcopy.c (delete_symbol_htabs): New function.
(main): Call it via xatexit.
(copy_archive): Free "dir".
* objdump.c (free_debug_section): Free reloc_info.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r-- | binutils/objcopy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index b907b02..1118a22 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1048,6 +1048,20 @@ create_symbol_htabs (void) redefine_specific_reverse_htab = create_symbol_htab (); } +static void +delete_symbol_htabs (void) +{ + htab_delete (strip_specific_htab); + htab_delete (strip_unneeded_htab); + htab_delete (keep_specific_htab); + htab_delete (localize_specific_htab); + htab_delete (globalize_specific_htab); + htab_delete (keepglobal_specific_htab); + htab_delete (weaken_specific_htab); + htab_delete (redefine_specific_htab); + htab_delete (redefine_specific_reverse_htab); +} + /* Add a symbol to strip_specific_list. */ static void @@ -3736,6 +3750,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, } rmdir (dir); + free (dir); } static void @@ -6016,6 +6031,7 @@ main (int argc, char *argv[]) } create_symbol_htabs (); + xatexit (delete_symbol_htabs); if (argv != NULL) bfd_set_error_program_name (argv[0]); |