+2021-03-20  Tom Tromey  <tom@tromey.com>
+
+       * psymtab.c (require_partial_symbols): Check that 'sf' is not
+       null.
+       * xcoffread.c (xcoff_sym_fns): Update.
+       * symfile.h (struct sym_fns) <qf>: Remove.
+       * symfile.c (syms_from_objfile_1, reread_symbols): Update.
+       * symfile-debug.c (objfile::has_partial_symbols)
+       (objfile::find_last_source_symtab)
+       (objfile::forget_cached_source_info)
+       (objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
+       (objfile::print_stats, objfile::dump)
+       (objfile::expand_symtabs_for_function)
+       (objfile::expand_all_symtabs)
+       (objfile::expand_symtabs_with_fullname)
+       (objfile::map_matching_symbols)
+       (objfile::expand_symtabs_matching)
+       (objfile::find_pc_sect_compunit_symtab)
+       (objfile::map_symbol_filenames)
+       (objfile::find_compunit_symtab_by_address)
+       (objfile::lookup_global_symbol_language, debug_sym_fns)
+       (install_symfile_debug_logging): Update.
+       * objfiles.h (struct objfile) <qf>: New member.
+       * mipsread.c (ecoff_sym_fns): Update.
+       * machoread.c (macho_sym_fns): Update.
+       * elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names):
+       Don't declare.
+       (elf_symfile_read, elf_sym_fns, elf_sym_fns_lazy_psyms): Update.
+       * dbxread.c (aout_sym_fns): Update.
+       * coffread.c (coff_sym_fns): Update.
+
 2021-03-20  Tom Tromey  <tom@tromey.com>
 
        * symfile.h (symbol_compare_ftype, symbol_filename_ftype)
 
   default_symfile_relocate,    /* sym_relocate: Relocate a debug
                                   section.  */
   NULL,                                /* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_coffread ();
 
   NULL,
   default_symfile_relocate,    /* Relocate a debug section.  */
   NULL,                                /* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_dbxread ();
 
 #include "dwarf2/public.h"
 
 /* Forward declarations.  */
-extern const struct sym_fns elf_sym_fns_gdb_index;
-extern const struct sym_fns elf_sym_fns_debug_names;
 extern const struct sym_fns elf_sym_fns_lazy_psyms;
 
 /* The struct elfinfo is available only during ELF symbol table and
          switch (index_kind)
            {
            case dw_index_kind::GDB_INDEX:
-             objfile_set_sym_fns (objfile, &elf_sym_fns_gdb_index);
+             objfile->qf = &dwarf2_gdb_index_functions;
              break;
            case dw_index_kind::DEBUG_NAMES:
-             objfile_set_sym_fns (objfile, &elf_sym_fns_debug_names);
+             objfile->qf = &dwarf2_debug_names_functions;
              break;
            }
        }
   NULL,
   default_symfile_relocate,    /* Relocate a debug section.  */
   &elf_probe_fns,              /* sym_probe_fns */
-  &psym_functions
 };
 
 /* The same as elf_sym_fns, but not registered and lazily reads
   NULL,
   default_symfile_relocate,    /* Relocate a debug section.  */
   &elf_probe_fns,              /* sym_probe_fns */
-  &psym_functions
-};
-
-/* The same as elf_sym_fns, but not registered and uses the
-   DWARF-specific GNU index rather than psymtab.  */
-const struct sym_fns elf_sym_fns_gdb_index =
-{
-  elf_new_init,                        /* init anything gbl to entire symab */
-  elf_symfile_init,            /* read initial info, setup for sym_red() */
-  elf_symfile_read,            /* read a symbol file into symtab */
-  NULL,                                /* sym_read_psymbols */
-  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,
-  default_symfile_relocate,    /* Relocate a debug section.  */
-  &elf_probe_fns,              /* sym_probe_fns */
-  &dwarf2_gdb_index_functions
-};
-
-/* The same as elf_sym_fns, but not registered and uses the
-   DWARF-specific .debug_names index rather than psymtab.  */
-const struct sym_fns elf_sym_fns_debug_names =
-{
-  elf_new_init,                        /* init anything gbl to entire symab */
-  elf_symfile_init,            /* read initial info, setup for sym_red() */
-  elf_symfile_read,            /* read a symbol file into symtab */
-  NULL,                                /* sym_read_psymbols */
-  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,
-  default_symfile_relocate,    /* Relocate a debug section.  */
-  &elf_probe_fns,              /* sym_probe_fns */
-  &dwarf2_debug_names_functions
 };
 
 /* STT_GNU_IFUNC resolver vector to be installed to gnu_ifunc_fns_p.  */
 
   NULL,
   macho_symfile_relocate,      /* Relocate a debug section.  */
   NULL,                                /* sym_get_probes */
-  &psym_functions
 };
 
 void _initialize_machoread ();
 
   NULL,
   default_symfile_relocate,    /* Relocate a debug section.  */
   NULL,                                /* sym_probe_fns */
-  &psym_functions
 };
 
 void _initialize_mipsread ();
 
 
   const struct sym_fns *sf = nullptr;
 
+  /* The "quick" (aka partial) symbol functions for this symbol
+     reader.  */
+  const struct quick_symbol_functions *qf = nullptr;
+
   /* Per objfile data-pointers required by other GDB modules.  */
 
   REGISTRY_FIELDS {};
 
     {
       objfile->flags |= OBJF_PSYMTABS_READ;
 
-      if (objfile->sf->sym_read_psymbols)
+      if (objfile->sf != nullptr
+         && objfile->sf->sym_read_psymbols)
        {
          if (verbose)
            printf_filtered (_("Reading symbols from %s...\n"),
 
       && sf != nullptr
       && sf->sym_read_psymbols != NULL)
     retval = true;
-  else if (sf != nullptr)
-    retval = sf->qf->has_symbols (this);
+  else if (qf != nullptr)
+    retval = qf->has_symbols (this);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
                      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    retval = sf->qf->find_last_source_symtab (this);
+  if (qf != nullptr)
+    retval = qf->find_last_source_symtab (this);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n",
     fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
                      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->forget_cached_source_info (this);
+  if (qf != nullptr)
+    qf->forget_cached_source_info (this);
 }
 
 bool
                      host_address_to_string (&callback));
 
   bool retval = false;
-  if (sf != nullptr)
-    retval = (sf->qf->map_symtabs_matching_filename
+  if (qf != nullptr)
+    retval = (qf->map_symtabs_matching_filename
              (this, name, real_path, callback));
 
   if (debug_symfile)
                      objfile_debug_name (this), kind, name,
                      domain_name (domain));
 
-  if (sf != nullptr)
-    retval = sf->qf->lookup_symbol (this, kind, name, domain);
+  if (qf != nullptr)
+    retval = qf->lookup_symbol (this, kind, name, domain);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
     fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
                      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->print_stats (this);
+  if (qf != nullptr)
+    qf->print_stats (this);
 }
 
 void
     fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
                      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->dump (this);
+  if (qf != nullptr)
+    qf->dump (this);
 }
 
 void
                      "qf->expand_symtabs_for_function (%s, \"%s\")\n",
                      objfile_debug_name (this), func_name);
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_for_function (this, func_name);
+  if (qf != nullptr)
+    qf->expand_symtabs_for_function (this, func_name);
 }
 
 void
     fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
                      objfile_debug_name (this));
 
-  if (sf != nullptr)
-    sf->qf->expand_all_symtabs (this);
+  if (qf != nullptr)
+    qf->expand_all_symtabs (this);
 }
 
 void
                      "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
                      objfile_debug_name (this), fullname);
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_with_fullname (this, fullname);
+  if (qf != nullptr)
+    qf->expand_symtabs_with_fullname (this, fullname);
 }
 
 void
                      domain_name (domain), global,
                      host_address_to_string (ordered_compare));
 
-  if (sf != nullptr)
-    sf->qf->map_matching_symbols (this, name, domain, global,
-                                 callback, ordered_compare);
+  if (qf != nullptr)
+    qf->map_matching_symbols (this, name, domain, global,
+                             callback, ordered_compare);
 }
 
 void
                      host_address_to_string (&expansion_notify),
                      search_domain_name (kind));
 
-  if (sf != nullptr)
-    sf->qf->expand_symtabs_matching (this, file_matcher, lookup_name,
-                                    symbol_matcher, expansion_notify, kind);
+  if (qf != nullptr)
+    qf->expand_symtabs_matching (this, file_matcher, lookup_name,
+                                symbol_matcher, expansion_notify, kind);
 }
 
 struct compunit_symtab *
                      host_address_to_string (section),
                      warn_if_readin);
 
-  if (sf != nullptr)
-    retval
-      = sf->qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
-                                             warn_if_readin);
+  if (qf != nullptr)
+    retval = qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
+                                              warn_if_readin);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
                      host_address_to_string (data),
                      need_fullname);
 
-  if (sf != nullptr)
-    sf->qf->map_symbol_filenames (this, fun, data, need_fullname);
+  if (qf != nullptr)
+    qf->map_symbol_filenames (this, fun, data, need_fullname);
 }
 
 struct compunit_symtab *
                      hex_string (address));
 
   struct compunit_symtab *result = NULL;
-  if (sf != nullptr && sf->qf->find_compunit_symtab_by_address != NULL)
-    result = sf->qf->find_compunit_symtab_by_address (this, address);
+  if (qf != nullptr && qf->find_compunit_symtab_by_address != NULL)
+    result = qf->find_compunit_symtab_by_address (this, address);
 
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog,
 {
   enum language result = language_unknown;
 
-  if (sf != nullptr && sf->qf->lookup_global_symbol_language != nullptr)
-    result = sf->qf->lookup_global_symbol_language (this, name, domain,
-                                                   symbol_found_p);
+  if (qf != nullptr && qf->lookup_global_symbol_language != nullptr)
+    result = qf->lookup_global_symbol_language (this, name, domain,
+                                               symbol_found_p);
   else
     *symbol_found_p = false;
 
   debug_sym_read_linetable,
   debug_sym_relocate,
   &debug_sym_probe_fns,
-  nullptr
 };
 \f
 /* Install the debugging versions of the symfile functions for OBJFILE.
   COPY_SF_PTR (real_sf, debug_data, sym_relocate, debug_sym_relocate);
   if (real_sf->sym_probe_fns)
     debug_data->debug_sf.sym_probe_fns = &debug_sym_probe_fns;
-  debug_data->debug_sf.qf = real_sf->qf;
 
 #undef COPY_SF_PTR
 
 
   const int mainline = add_flags & SYMFILE_MAINLINE;
 
   objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+  objfile->qf = &psym_functions;
 
   if (objfile->sf == NULL)
     {
             based on whether .gdb_index is present, and we need it to
             start over.  PR symtab/15885  */
          objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+         objfile->qf = &psym_functions;
 
          build_objfile_section_table (objfile);
 
 
   /* If non-NULL, this objfile has probe support, and all the probe
      functions referred to here will be non-NULL.  */
   const struct sym_probe_fns *sym_probe_fns;
-
-  /* The "quick" (aka partial) symbol functions for this symbol
-     reader.  */
-  const struct quick_symbol_functions *qf;
 };
 
 extern section_addr_info
 
   aix_process_linenos,
   default_symfile_relocate,    /* Relocate a debug section.  */
   NULL,                                /* sym_probe_fns */
-  &psym_functions
 };
 
 /* Same as xcoff_get_n_import_files, but for core files.  */