[binutils-gdb/masterr] Remove sym_fns::sym_finish

Tom Tromey tromey@sourceware.org
Thu Jan 8 13:42:08 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=591b11832b4c27befa069e66ec3647ed3322a225

commit 591b11832b4c27befa069e66ec3647ed3322a225
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Jan 5 17:19:35 2026 -0700

    Remove sym_fns::sym_finish
    
    sym_finish::sym_finish isn't needed by any existing code, so this
    patch removes it.
    
    Note that it should never be needed again.  It's much cleaner, IMO,
    for symbol readers to attach data to the objfile or per-BFD via the
    registry.  Then, any cleanup will be automatic.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/coffread.c      | 12 ------------
 gdb/elfread.c       | 11 -----------
 gdb/machoread.c     |  6 ------
 gdb/objfiles.c      | 10 ----------
 gdb/symfile-debug.c | 13 -------------
 gdb/symfile.c       |  5 -----
 gdb/symfile.h       |  7 -------
 gdb/xcoffread.c     | 13 -------------
 8 files changed, 77 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index da45c4195bf..a94da096e15 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -717,16 +717,6 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
     }
 }
 
-/* Perform any local cleanups required when we are done with a
-   particular objfile.  I.E, we are in the process of discarding all
-   symbol information for an objfile, freeing up all memory held for
-   it, and unlinking the objfile struct from the global list of known
-   objfiles.  */
-
-static void
-coff_symfile_finish (struct objfile *objfile)
-{
-}
 

 
 /* Given pointers to a symbol table in coff style exec file,
@@ -2105,8 +2095,6 @@ static const struct sym_fns coff_sym_fns =
 				   for sym_read() */
   coff_symfile_read,		/* sym_read: read a symbol file into
 				   symtab */
-  coff_symfile_finish,		/* sym_finish: finished with file,
-				   cleanup */
   default_symfile_offsets,	/* sym_offsets: xlate external to
 				   internal form */
   default_symfile_segments,	/* sym_segments: Get segment
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 7367007bf6e..062a4845bb4 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1279,16 +1279,6 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   objfile->object_format_has_copy_relocs = true;
 }
 
-/* Perform any local cleanups required when we are done with a particular
-   objfile.  I.E, we are in the process of discarding all symbol information
-   for an objfile, freeing up all memory held for it, and unlinking the
-   objfile struct from the global list of known objfiles.  */
-
-static void
-elf_symfile_finish (struct objfile *objfile)
-{
-}
-
 /* ELF specific initialization routine for reading symbols.  */
 
 static void
@@ -1331,7 +1321,6 @@ static const struct sym_fns elf_sym_fns =
 {
   elf_symfile_init,		/* read initial info, setup for sym_read() */
   elf_symfile_read,		/* read a symbol file into symtab */
-  elf_symfile_finish,		/* finished with file, cleanup */
   default_symfile_offsets,	/* Translate ext. to int. relocation */
   elf_symfile_segments,		/* Get segment information from a file.  */
   NULL,
diff --git a/gdb/machoread.c b/gdb/machoread.c
index b6454922700..aa76ee779c5 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -871,11 +871,6 @@ macho_symfile_relocate (struct objfile *objfile, asection *sectp,
   return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
 }
 
-static void
-macho_symfile_finish (struct objfile *objfile)
-{
-}
-
 static void
 macho_symfile_offsets (struct objfile *objfile,
 		       const section_addr_info &addrs)
@@ -926,7 +921,6 @@ macho_symfile_offsets (struct objfile *objfile,
 static const struct sym_fns macho_sym_fns = {
   macho_symfile_init,           /* read initial info, setup for sym_read() */
   macho_symfile_read,           /* read a symbol file into symtab */
-  macho_symfile_finish,         /* finished with file, cleanup */
   macho_symfile_offsets,        /* xlate external to internal form */
   default_symfile_segments,	/* Get segment information from a file.  */
   NULL,
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 8c38d9655a6..8e6fd07d84b 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -476,16 +476,6 @@ objfile::~objfile ()
   breakpoint_free_objfile (this);
   btrace_free_objfile (this);
 
-  /* First do any symbol file specific actions required when we are
-     finished with a particular symbol file.  Note that if the objfile
-     is using reusable symbol information (via mmalloc) then each of
-     these routines is responsible for doing the correct thing, either
-     freeing things which are valid only during this particular gdb
-     execution, or leaving them to be reused during the next one.  */
-
-  if (sf != NULL)
-    (*sf->sym_finish) (this);
-
   /* Before the symbol table code was redone to make it easier to
      selectively load and remove information particular to a specific
      linkage unit, gdb used to do these things whenever the monolithic
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 2ede106fd6f..5e4e6224ddb 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -732,18 +732,6 @@ debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   debug_data->real_sf->sym_read (objfile, symfile_flags);
 }
 
-static void
-debug_sym_finish (struct objfile *objfile)
-{
-  const struct debug_sym_fns_data *debug_data
-    = symfile_debug_objfile_data_key.get (objfile);
-
-  gdb_printf (gdb_stdlog, "sf->sym_finish (%s)\n",
-	      objfile_debug_name (objfile));
-
-  debug_data->real_sf->sym_finish (objfile);
-}
-
 static void
 debug_sym_offsets (struct objfile *objfile,
 		   const section_addr_info &info)
@@ -823,7 +811,6 @@ install_symfile_debug_logging (struct objfile *objfile)
 
   COPY_SF_PTR (real_sf, debug_data, sym_init, debug_sym_init);
   COPY_SF_PTR (real_sf, debug_data, sym_read, debug_sym_read);
-  COPY_SF_PTR (real_sf, debug_data, sym_finish, debug_sym_finish);
   COPY_SF_PTR (real_sf, debug_data, sym_offsets, debug_sym_offsets);
   COPY_SF_PTR (real_sf, debug_data, sym_segments, debug_sym_segments);
   COPY_SF_PTR (real_sf, debug_data, sym_read_linetable,
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 01467a9adc4..d0bb61dda38 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2552,11 +2552,6 @@ reread_symbols (int from_tty)
 
 	     Try to keep the freeing order compatible with free_objfile.  */
 
-	  if (objfile.sf != NULL)
-	    {
-	      (*objfile.sf->sym_finish) (&objfile);
-	    }
-
 	  objfile.registry_fields.clear_registry ();
 
 	  /* Clean up any state BFD has sitting around.  */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 8d9399ad7e9..336fe93d582 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -130,13 +130,6 @@ struct sym_fns
 
   void (*sym_read) (struct objfile *, symfile_add_flags);
 
-  /* Called when we are finished with an objfile.  Should do all
-     cleanup that is specific to the object file format for the
-     particular objfile.  */
-
-  void (*sym_finish) (struct objfile *);
-
-
   /* This function produces a file-dependent section_offsets
      structure, allocated in the objfile's storage.
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index a9ea574b3d5..5a9a39042b8 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -100,8 +100,6 @@ static void scan_xcoff_symtab (struct objfile *);
 
 static void xcoff_symfile_init (struct objfile *);
 
-static void xcoff_symfile_finish (struct objfile *);
-
 /* Search all BFD sections for the section whose target_index is
    equal to N_SCNUM.  Set *BFD_SECT to that section.  The section's
    associated index in the objfile's section_offset table is also
@@ -182,16 +180,6 @@ xcoff_symfile_init (struct objfile *objfile)
   xcoff_objfile_data_key.emplace (objfile);
 }
 
-/* Perform any local cleanups required when we are done with a particular
-   objfile.  I.E, we are in the process of discarding all symbol information
-   for an objfile, freeing up all memory held for it, and unlinking the
-   objfile struct from the global list of known objfiles.  */
-
-static void
-xcoff_symfile_finish (struct objfile *objfile)
-{
-}
-
 /* Swap raw symbol at *RAW and put the name in *NAME, the symbol in
    *SYMBOL, the first auxent in *AUX.  Advance *RAW and *SYMNUMP over
    the symbol and its auxents.  */
@@ -494,7 +482,6 @@ static const struct sym_fns xcoff_sym_fns =
 
   xcoff_symfile_init,		/* read initial info, setup for sym_read() */
   xcoff_initial_scan,		/* read a symbol file into symtab */
-  xcoff_symfile_finish,		/* finished with file, cleanup */
   xcoff_symfile_offsets,	/* xlate offsets ext->int form */
   default_symfile_segments,	/* Get segment information from a file.  */
   aix_process_linenos,


More information about the Gdb-cvs mailing list