/* Read a symbol table in MIPS' format (Third-Eye).
- Copyright (C) 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1998, 1999, 2000, 2001, 2003, 2004, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work
by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Read symbols from an ECOFF file. Most of the work is done in
mdebugread.c. */
#include "defs.h"
-#include "gdb_string.h"
#include "bfd.h"
#include "symtab.h"
#include "objfiles.h"
#include "libcoff.h" /* Private BFD COFF information. */
#include "libecoff.h" /* Private BFD ECOFF information. */
#include "elf/common.h"
+#include "elf/internal.h"
#include "elf/mips.h"
+#include "psymtab.h"
+
static void
read_alphacoff_dynamic_symtab (struct section_offsets *,
struct objfile *objfile);
/* Read a symbol file from a file. */
static void
-mipscoff_symfile_read (struct objfile *objfile, int mainline)
+mipscoff_symfile_read (struct objfile *objfile, int symfile_flags)
{
bfd *abfd = objfile->obfd;
struct cleanup *back_to;
read_alphacoff_dynamic_symtab (objfile->section_offsets, objfile);
/* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile. */
+ minimal symbols for this objfile. */
install_minimal_symbols (objfile);
do_cleanups (back_to);
standard COFF section. The ELF format for the symbols differs from
the format defined in elf/external.h. It seems that a normal ELF
32-bit format is used, and the representation only changes because
- longs are 64-bit on the alpha. In addition, the handling of
+ longs are 64-bit on the alpha. In addition, the handling of
text/data section indices for symbols is different from the ELF
ABI. As the BFD linker currently does not support dynamic linking
on the alpha, there seems to be no reason to pollute BFD with
dyninfo_secsize = bfd_get_section_size (si.dyninfo_sect);
got_secsize = bfd_get_section_size (si.got_sect);
sym_secptr = xmalloc (sym_secsize);
- cleanups = make_cleanup (free, sym_secptr);
+ cleanups = make_cleanup (xfree, sym_secptr);
str_secptr = xmalloc (str_secsize);
- make_cleanup (free, str_secptr);
+ make_cleanup (xfree, str_secptr);
dyninfo_secptr = xmalloc (dyninfo_secsize);
- make_cleanup (free, dyninfo_secptr);
+ make_cleanup (xfree, dyninfo_secptr);
got_secptr = xmalloc (got_secsize);
- make_cleanup (free, got_secptr);
+ make_cleanup (xfree, got_secptr);
if (!bfd_get_section_contents (abfd, si.sym_sect, sym_secptr,
(file_ptr) 0, sym_secsize))
- return;
+ {
+ do_cleanups (cleanups);
+ return;
+ }
if (!bfd_get_section_contents (abfd, si.str_sect, str_secptr,
(file_ptr) 0, str_secsize))
- return;
+ {
+ do_cleanups (cleanups);
+ return;
+ }
if (!bfd_get_section_contents (abfd, si.dyninfo_sect, dyninfo_secptr,
(file_ptr) 0, dyninfo_secsize))
- return;
+ {
+ do_cleanups (cleanups);
+ return;
+ }
if (!bfd_get_section_contents (abfd, si.got_sect, got_secptr,
(file_ptr) 0, got_secsize))
- return;
+ {
+ do_cleanups (cleanups);
+ return;
+ }
- /* Find the number of local GOT entries and the index for the the
+ /* Find the number of local GOT entries and the index for the
first dynamic symbol in the GOT. */
for (dyninfo_p = dyninfo_secptr, dyninfo_end = dyninfo_p + dyninfo_secsize;
dyninfo_p < dyninfo_end;
}
}
if (dt_mips_local_gotno < 0 || dt_mips_gotsym < 0)
- return;
+ {
+ do_cleanups (cleanups);
+ return;
+ }
/* Scan all dynamic symbols and enter them into the minimal symbol
table if appropriate. */
sym_value = bfd_h_get_64 (abfd, (bfd_byte *) x_symp->st_value);
sym_info = bfd_h_get_8 (abfd, (bfd_byte *) x_symp->st_info);
sym_shndx = bfd_h_get_16 (abfd, (bfd_byte *) x_symp->st_shndx);
+ if (sym_shndx >= (SHN_LORESERVE & 0xffff))
+ sym_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff);
isglobal = (ELF_ST_BIND (sym_info) == STB_GLOBAL);
if (sym_shndx == SHN_UNDEF)
}
else
{
- /* Symbols defined in the executable itself. We only care
+ /* Symbols defined in the executable itself. We only care
about them if this is a stripped executable, otherwise
they have been retrieved from the normal symbol table
already. */
ms_type = mst_text;
else
ms_type = mst_file_text;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
}
else if (sym_shndx == SHN_MIPS_DATA)
{
ms_type = mst_data;
else
ms_type = mst_file_data;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
}
else if (sym_shndx == SHN_MIPS_ACOMMON)
{
ms_type = mst_bss;
else
ms_type = mst_file_bss;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
}
else if (sym_shndx == SHN_ABS)
{
/* Initialization. */
-static struct sym_fns ecoff_sym_fns =
+static const struct sym_fns ecoff_sym_fns =
{
- bfd_target_ecoff_flavour,
- mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
- mipscoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
- mipscoff_symfile_read, /* sym_read: read a symbol file into symtab */
- mipscoff_symfile_finish, /* sym_finish: finished with file, cleanup */
- default_symfile_offsets, /* sym_offsets: dummy FIXME til implem sym reloc */
- NULL /* next: pointer to next struct sym_fns */
+ mipscoff_new_init, /* init anything gbl to entire symtab */
+ mipscoff_symfile_init, /* read initial info, setup for sym_read() */
+ mipscoff_symfile_read, /* read a symbol file into symtab */
+ NULL, /* sym_read_psymbols */
+ mipscoff_symfile_finish, /* finished with file, cleanup */
+ default_symfile_offsets, /* dummy FIXME til implem sym reloc */
+ default_symfile_segments, /* Get segment information from a file. */
+ NULL,
+ default_symfile_relocate, /* Relocate a debug section. */
+ NULL, /* sym_probe_fns */
+ &psym_functions
};
/* Provide a prototype to silence -Wmissing-prototypes. */
void
_initialize_mipsread (void)
{
- add_symtab_fns (&ecoff_sym_fns);
+ add_symtab_fns (bfd_target_ecoff_flavour, &ecoff_sym_fns);
}