[binutils-gdb] aout, ecoff and som free_cached_info
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef27fb95dfc6647a43f09afa2b4936bb6ca4a576 commit ef27fb95dfc6647a43f09afa2b4936bb6ca4a576 Author: Alan Modra <[email protected]> Date: Thu Mar 26 12:47:05 2026 +1030 aout, ecoff and som free_cached_info By inspection the aout, som and ecoff object targets either do not support _bfd_check_format[bfd_core], or they use different tdata to the bfd_object support, eg. i386lynx.c and lynx-core.c. Some use entirely separate bfd_target vecs for bfd_object vs. bfd_core. In any of these cases we either should not or do not need to support bfd_core in their free_cached_info functions. This patch removes the bfd_core test from free_cached_info for these targets. * aoutx.h (bfd_free_cached_info): Ignore bfd_core. Move section handling out of tdata test. * pdp11.c (bfd_free_cached_info): Likewise. * som.c (som_bfd_free_cached_info): Likewise. * ecoff.c (_bfd_ecoff_bfd_free_cached_info): Ignore bfd_core. Diff: --- bfd/aoutx.h | 12 ++++++------ bfd/ecoff.c | 3 +-- bfd/pdp11.c | 12 ++++++------ bfd/som.c | 23 +++++++++++------------ 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/bfd/aoutx.h b/bfd/aoutx.h index cb2d9270db9..a1b9a59e36f 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -2893,20 +2893,20 @@ NAME (aout, sizeof_headers) (bfd *abfd, bool NAME (aout, bfd_free_cached_info) (bfd *abfd) { - if ((bfd_get_format (abfd) == bfd_object - || bfd_get_format (abfd) == bfd_core) +#define BFCI_FREE(x) do { free (x); x = NULL; } while (0) + if (bfd_get_format (abfd) == bfd_object && abfd->tdata.aout_data != NULL) { -#define BFCI_FREE(x) do { free (x); x = NULL; } while (0) BFCI_FREE (adata (abfd).line_buf); BFCI_FREE (obj_aout_symbols (abfd)); BFCI_FREE (obj_aout_external_syms (abfd)); BFCI_FREE (obj_aout_external_strings (abfd)); - for (asection *o = abfd->sections; o != NULL; o = o->next) - BFCI_FREE (o->relocation); -#undef BFCI_FREE } + for (asection *o = abfd->sections; o != NULL; o = o->next) + BFCI_FREE (o->relocation); +#undef BFCI_FREE + return _bfd_generic_bfd_free_cached_info (abfd); } diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 50e42afed18..cd56a46c460 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -114,8 +114,7 @@ _bfd_ecoff_bfd_free_cached_info (bfd *abfd) { struct ecoff_tdata *tdata; - if ((bfd_get_format (abfd) == bfd_object - || bfd_get_format (abfd) == bfd_core) + if (bfd_get_format (abfd) == bfd_object && (tdata = ecoff_data (abfd)) != NULL) { while (tdata->mips_refhi_list != NULL) diff --git a/bfd/pdp11.c b/bfd/pdp11.c index d1d761d9adb..d5b984268b0 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -2524,20 +2524,20 @@ NAME (aout, sizeof_headers) (bfd *abfd, bool NAME (aout, bfd_free_cached_info) (bfd *abfd) { - if ((bfd_get_format (abfd) == bfd_object - || bfd_get_format (abfd) == bfd_core) +#define BFCI_FREE(x) do { free (x); x = NULL; } while (0) + if (bfd_get_format (abfd) == bfd_object && abfd->tdata.aout_data != NULL) { -#define BFCI_FREE(x) do { free (x); x = NULL; } while (0) BFCI_FREE (adata (abfd).line_buf); BFCI_FREE (obj_aout_symbols (abfd)); BFCI_FREE (obj_aout_external_syms (abfd)); BFCI_FREE (obj_aout_external_strings (abfd)); - for (asection *o = abfd->sections; o != NULL; o = o->next) - BFCI_FREE (o->relocation); -#undef BFCI_FREE } + for (asection *o = abfd->sections; o != NULL; o = o->next) + BFCI_FREE (o->relocation); +#undef BFCI_FREE + return _bfd_generic_bfd_free_cached_info (abfd); } diff --git a/bfd/som.c b/bfd/som.c index a39c061762d..5db989938c8 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -6719,25 +6719,24 @@ som_write_armap (bfd *abfd, static bool som_bfd_free_cached_info (bfd *abfd) { +#define FREE(x) do { free (x); x = NULL; } while (0) if (bfd_get_format (abfd) == bfd_object - || bfd_get_format (abfd) == bfd_core) + && abfd->tdata.som_data != NULL) { - asection *o; - -#define FREE(x) do { free (x); x = NULL; } while (0) /* Free the native string and symbol tables. */ FREE (obj_som_symtab (abfd)); FREE (obj_som_stringtab (abfd)); - for (o = abfd->sections; o != NULL; o = o->next) - { - /* Free the native relocations. */ - o->reloc_count = (unsigned) -1; - FREE (som_section_data (o)->reloc_stream); - /* Do not free the generic relocations as they are objalloc'ed. */ - } -#undef FREE } + for (asection *o = abfd->sections; o != NULL; o = o->next) + { + /* Free the native relocations. */ + o->reloc_count = (unsigned) -1; + FREE (som_section_data (o)->reloc_stream); + /* Do not free the generic relocations as they are objalloc'ed. */ + } +#undef FREE + /* Do not call _bfd_generic_bfd_free_cached_info here. som_write_armap needs to access the bfd objalloc memory. */ return true;