Unbreak build for non-ELF ports
[deliverable/binutils-gdb.git] / gdb / elfread.c
index 31288a9b746ecccbae02df3889ad37cb26eb4a7f..7a41c263709839eebe5d8a47d9568f2b81812722 100644 (file)
 #include "location.h"
 #include "auxv.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
    psymtab reading.  It is destroyed at the completion of psymtab-reading.
    It's local to elf_symfile_read.  */
@@ -1211,11 +1216,25 @@ 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;
 
-      if (objfile_has_partial_symbols (objfile))
+      /* 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, &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
             partial symbols, because OBJF_PSYMTABS_READ has not been
@@ -1223,8 +1242,6 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
             when needed.  */
          objfile_set_sym_fns (objfile, &elf_sym_fns_lazy_psyms);
        }
-      else
-       objfile_set_sym_fns (objfile, &dwarf2_initialize_objfile (objfile));
     }
   /* If the file has its own symbol tables it has no separate debug
      info.  `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
This page took 0.023843 seconds and 4 git commands to generate.