Remove some cleanups from search_minsyms_for_name
[deliverable/binutils-gdb.git] / gdb / elfread.c
index f2483025baa20dba0ecf1dbb1364b4c1d2663b02..260789062d03d501ff1a629dbd7de123512fc1b4 100644 (file)
@@ -1,6 +1,6 @@
 /* Read ELF (Executable and Linking Format) object files for GDB.
 
-   Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   Copyright (C) 1991-2018 Free Software Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.
 
@@ -50,6 +50,7 @@
 
 /* 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
@@ -237,7 +238,6 @@ elf_symtab_read (minimal_symbol_reader &reader,
   /* Name of the last file symbol.  This is either a constant string or is
      saved on the objfile's filename cache.  */
   const char *filesymname = "";
-  struct dbx_symfile_info *dbx = DBX_SYMFILE_INFO (objfile);
   int stripped = (bfd_get_symcount (objfile->obfd) == 0);
   int elf_make_msymbol_special_p
     = gdbarch_elf_make_msymbol_special_p (gdbarch);
@@ -1171,7 +1171,8 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   struct elfinfo ei;
 
   memset ((char *) &ei, 0, sizeof (ei));
-  bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei);
+  if (!(objfile->flags & OBJF_READNEVER))
+    bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei);
 
   elf_read_minimal_symbols (objfile, symfile_flags, &ei);
 
@@ -1215,13 +1216,24 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
   if (dwarf2_has_info (objfile, NULL))
     {
-      /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF debug
-        information present in OBJFILE.  If there is such debug info present
-        never use .gdb_index.  */
+      dw_index_kind index_kind;
 
+      /* elf_sym_fns_gdb_index cannot handle simultaneous non-DWARF
+        debug information present in OBJFILE.  If there is such debug
+        info present never use an index.  */
       if (!objfile_has_partial_symbols (objfile)
-         && dwarf2_initialize_objfile (objfile))
-       objfile_set_sym_fns (objfile, &elf_sym_fns_gdb_index);
+         && dwarf2_initialize_objfile (objfile, &index_kind))
+       {
+         switch (index_kind)
+           {
+           case dw_index_kind::GDB_INDEX:
+             objfile_set_sym_fns (objfile, &elf_sym_fns_gdb_index);
+             break;
+           case dw_index_kind::DEBUG_NAMES:
+             objfile_set_sym_fns (objfile, &elf_sym_fns_debug_names);
+             break;
+           }
+       }
       else
        {
          /* It is ok to do this even if the stabs reader made some
@@ -1247,17 +1259,16 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
           && objfile->separate_debug_objfile == NULL
           && objfile->separate_debug_objfile_backlink == NULL)
     {
-      gdb::unique_xmalloc_ptr<char> debugfile
-       (find_separate_debug_file_by_buildid (objfile));
+      std::string debugfile = find_separate_debug_file_by_buildid (objfile);
 
-      if (debugfile == NULL)
-       debugfile.reset (find_separate_debug_file_by_debuglink (objfile));
+      if (debugfile.empty ())
+       debugfile = find_separate_debug_file_by_debuglink (objfile);
 
-      if (debugfile != NULL)
+      if (!debugfile.empty ())
        {
-         gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.get ()));
+         gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.c_str ()));
 
-         symbol_file_add_separate (abfd.get (), debugfile.get (),
+         symbol_file_add_separate (abfd.get (), debugfile.c_str (),
                                    symfile_flags, objfile);
        }
     }
@@ -1408,6 +1419,23 @@ const struct sym_fns elf_sym_fns_gdb_index =
   &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. relocatin */
+  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.  */
 
 static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =
This page took 0.030446 seconds and 4 git commands to generate.