Unbreak build for non-ELF ports
authorPedro Alves <palves@redhat.com>
Mon, 11 Dec 2017 13:24:32 +0000 (13:24 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 11 Dec 2017 14:41:32 +0000 (14:41 +0000)
commit3c0aa29aab3949363f8b23d062c2e0cb1ccf017a
tree2722efa4a210635dcd5a9534a80dc37753c6c05a
parentf2f9e7ecc1f02bfe5da83c38cf356ea96d428c6d
Unbreak build for non-ELF ports

As reported at
<https://sourceware.org/ml/gdb-patches/2017-12/msg00229.html>, this
commit:

~~~~
 commit abccd1e7b7a37385159610ca4e0bc2632a547e9a
 Author:     Jan Kratochvil <jan.kratochvil@redhat.com>
 AuthorDate: Fri Dec 8 22:44:11 2017 +0000

     Change dwarf2_initialize_objfile's return value

     dwarf2_initialize_objfile was returning boolean whether it is psymtabs
     or .gdb_index while now it needs to return also whether it is
     .debug_names.
~~~~

breaks non-ELF-target builds:

 dwarf2read.o: In function `dwarf2_initialize_objfile(objfile*)':
 /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6486:
 undefined reference to `elf_sym_fns_gdb_index'
 /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6490:
 undefined reference to `elf_sym_fns_debug_names'
 /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6495:
 undefined reference to `elf_sym_fns_lazy_psyms'
 collect2: error: ld returned 1 exit status
 Makefile:1920: recipe for target 'gdb' failed

because gdb/elfread.c is not included in the gdb build unless bfd also
includes elf support.

Fix this by reverting the patch mentioned above and at the same time
re-adding .debug_names support by adding a new output parameter to
dwarf2_initialize_objfile to indicate the index variant in use.  We
can reuse the new dw_index_kind enum in dwarf2read.c for that.

gdb/ChangeLog:
2017-12-11  Pedro Alves  <palves@redhat.com>

* defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index)
(elf_sym_fns_debug_names): Move to elfread.c.
* dwarf2read.c (dwarf2_initialize_objfile): Return a boolean
instead of a sym_fns and add 'index_kind' output parameter.  Fill
the latter in with the index variant kind if using an index.
(enum dw_index_kind): Moved to symfile.h.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names)
(elf_sym_fns_lazy_psyms): Move from defs.h.
(elf_symfile_read): Adjust to new dwarf2_initialize_objfile
interface.
* symfile.h (enum class dw_index_kind): New, moved from
dwarf2read.c.
(dwarf2_initialize_objfile): Change prototype.
gdb/ChangeLog
gdb/defs.h
gdb/dwarf2read.c
gdb/elfread.c
gdb/symfile.h