_bfd_free_cached_info

doc/bfdint.texi and comments in the aout and som code about this
function are just wrong, and its name is not very apt.  Better would
be _bfd_mostly_destroy, and we certainly should not be saying anything
about the possibility of later recreating anything lost by this
function.  What's more, if _bfd_free_cached_info is called when
creating an archive map to reduce memory usage by throwing away
symbols, the target _close_and_cleanup function won't have access to
tdata or section bfd_user_data to tidy memory.  This means most of the
target _close_and_cleanup function won't do anything, and therefore
sometimes will result in memory leaks.

This patch fixes the documentation problems and moves most of the
target _close_and_cleanup code to target _bfd_free_cached_info.
Another notable change is that bfd_generic_bfd_free_cached_info is now
defined as _bfd_free_cached_info rather than _bfd_bool_bfd_true,
ie. the default now frees objalloc memory.
This commit is contained in:
Alan Modra
2023-06-07 14:16:06 +09:30
parent 0a22a8f27d
commit ba75d1c55c
31 changed files with 150 additions and 179 deletions

View File

@@ -2618,8 +2618,8 @@ const bfd_target rs6000_xcoff64_vec =
},
/* Generic */
_bfd_coff_close_and_cleanup,
_bfd_bool_bfd_true,
coff_close_and_cleanup,
coff_bfd_free_cached_info,
coff_new_section_hook,
_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window,
@@ -2891,8 +2891,8 @@ const bfd_target rs6000_xcoff64_aix_vec =
},
/* Generic */
_bfd_coff_close_and_cleanup,
_bfd_bool_bfd_true,
coff_close_and_cleanup,
coff_bfd_free_cached_info,
coff_new_section_hook,
_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window,