]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aout, ecoff and som free_cached_info
authorAlan Modra <amodra@gmail.com>
Thu, 26 Mar 2026 02:17:05 +0000 (12:47 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 26 Mar 2026 05:32:31 +0000 (16:02 +1030)
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.

bfd/aoutx.h
bfd/ecoff.c
bfd/pdp11.c
bfd/som.c

index cb2d9270db956f9ba040e4cfb99c396916a9bcc4..a1b9a59e36f7b28493ab0d8e60deeda0047adce7 100644 (file)
@@ -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);
 }
 \f
index 50e42afed18b450cc1b011e427062ac6062f2d5f..cd56a46c4608dd031dac6c08a92d9aa92e7b8b84 100644 (file)
@@ -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)
index d1d761d9adb9a8ae1b1b7a1e2b34cb9cd501818f..d5b984268b03a9f393be7925fd1b8fb77451cb1d 100644 (file)
@@ -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);
 }
 \f
index a39c061762df568656d2061dbcfbf7ce51e741bb..5db989938c8eba3fe429e8b77c63642df01086df 100644 (file)
--- 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;