Tidy dwarf1 cached section contents

* dwarf1.c (_bfd_dwarf1_cleanup_debug_info): New function.
	* libbfd-in.h (_bfd_dwarf1_cleanup_debug_info): Declare.
	* elf.c (_bfd_elf_close_and_cleanup): Call it.
	* elf-bfd.h (struct elf_obj_tdata): Make dwarf1_find_line_info
	a void*.
	* libbfd.h: Regenerate.
This commit is contained in:
Alan Modra
2023-03-24 16:28:08 +10:30
parent c569a946f6
commit 17749b3926
5 changed files with 22 additions and 1 deletions

View File

@@ -593,3 +593,15 @@ _bfd_dwarf1_find_nearest_line (bfd *abfd,
return false;
}
void
_bfd_dwarf1_cleanup_debug_info (bfd *abfd ATTRIBUTE_UNUSED, void **pinfo)
{
struct dwarf1_debug* stash = *pinfo;
if (stash == NULL)
return;
free (stash->debug_section);
free (stash->line_section);
}

View File

@@ -2070,7 +2070,7 @@ struct elf_obj_tdata
void *line_info;
/* A place to stash dwarf1 info for this bfd. */
struct dwarf1_debug *dwarf1_find_line_info;
void *dwarf1_find_line_info;
/* A place to stash dwarf2 info for this bfd. */
void *dwarf2_find_line_info;

View File

@@ -9592,6 +9592,7 @@ _bfd_elf_close_and_cleanup (bfd *abfd)
if (elf_tdata (abfd)->o != NULL && elf_shstrtab (abfd) != NULL)
_bfd_elf_strtab_free (elf_shstrtab (abfd));
_bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info);
_bfd_dwarf1_cleanup_debug_info (abfd, &tdata->dwarf1_find_line_info);
_bfd_stab_cleanup (abfd, &tdata->line_info);
}

View File

@@ -573,6 +573,10 @@ extern bool _bfd_dwarf1_find_nearest_line
(bfd *, asymbol **, asection *, bfd_vma,
const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
/* Clean up the data used to handle DWARF 1 debugging information. */
extern void _bfd_dwarf1_cleanup_debug_info
(bfd *, void **) ATTRIBUTE_HIDDEN;
struct dwarf_debug_section
{
const char * uncompressed_name;

View File

@@ -579,6 +579,10 @@ extern bool _bfd_dwarf1_find_nearest_line
(bfd *, asymbol **, asection *, bfd_vma,
const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
/* Clean up the data used to handle DWARF 1 debugging information. */
extern void _bfd_dwarf1_cleanup_debug_info
(bfd *, void **) ATTRIBUTE_HIDDEN;
struct dwarf_debug_section
{
const char * uncompressed_name;