aout, ecoff and som free_cached_info
Checks
Commit Message
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.
@@ -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);
}
@@ -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)
@@ -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);
}
@@ -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;