1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993 Free Software
4 Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work
5 by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* Read symbols from an ECOFF file. Most of the work is done in
31 #include "stabsread.h"
32 #include "gdb-stabs.h"
34 #include "coff/internal.h"
35 #include "coff/ecoff.h"
36 #include "libcoff.h" /* Private BFD COFF information. */
37 #include "libecoff.h" /* Private BFD ECOFF information. */
40 mipscoff_new_init
PARAMS ((struct objfile
*));
43 mipscoff_symfile_init
PARAMS ((struct objfile
*));
46 mipscoff_symfile_read
PARAMS ((struct objfile
*, struct section_offsets
*,
50 mipscoff_symfile_finish
PARAMS ((struct objfile
*));
52 static struct section_offsets
*
53 mipscoff_symfile_offsets
PARAMS ((struct objfile
*, CORE_ADDR
));
55 /* Initialize anything that needs initializing when a completely new
56 symbol file is specified (not just adding some symbols from another
57 file, e.g. a shared library). */
59 extern CORE_ADDR sigtramp_address
;
62 mipscoff_new_init (ignore
)
63 struct objfile
*ignore
;
66 stabsread_new_init ();
70 /* Initialize to read a symbol file (nothing to do). */
73 mipscoff_symfile_init (objfile
)
74 struct objfile
*objfile
;
78 /* Read a symbol file from a file. */
81 mipscoff_symfile_read (objfile
, section_offsets
, mainline
)
82 struct objfile
*objfile
;
83 struct section_offsets
*section_offsets
;
86 bfd
*abfd
= objfile
->obfd
;
87 struct cleanup
* back_to
;
89 init_minimal_symbol_collection ();
90 back_to
= make_cleanup (discard_minimal_symbols
, 0);
92 /* Now that the executable file is positioned at symbol table,
93 process it and define symbols accordingly. */
95 if (ecoff_slurp_symbolic_info (abfd
) == false)
96 error ("Error reading symbol table: %s", bfd_errmsg (bfd_error
));
98 mdebug_build_psymtabs (objfile
, &ecoff_backend (abfd
)->debug_swap
,
99 &ecoff_data (abfd
)->debug_info
, section_offsets
);
101 /* Install any minimal symbols that have been collected as the current
102 minimal symbols for this objfile. */
104 install_minimal_symbols (objfile
);
106 do_cleanups (back_to
);
109 /* Perform any local cleanups required when we are done with a
110 particular objfile. */
113 mipscoff_symfile_finish (objfile
)
114 struct objfile
*objfile
;
118 /* Fake up identical offsets for all sections. */
120 static struct section_offsets
*
121 mipscoff_symfile_offsets (objfile
, addr
)
122 struct objfile
*objfile
;
125 struct section_offsets
*section_offsets
;
128 objfile
->num_sections
= SECT_OFF_MAX
;
129 section_offsets
= ((struct section_offsets
*)
130 obstack_alloc (&objfile
->psymbol_obstack
,
131 (sizeof (struct section_offsets
)
132 + (sizeof (section_offsets
->offsets
)
133 * (SECT_OFF_MAX
- 1)))));
135 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
136 ANOFFSET (section_offsets
, i
) = addr
;
138 return section_offsets
;
143 static struct sym_fns ecoff_sym_fns
=
145 bfd_target_ecoff_flavour
,
146 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
147 mipscoff_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
148 mipscoff_symfile_read
, /* sym_read: read a symbol file into symtab */
149 mipscoff_symfile_finish
, /* sym_finish: finished with file, cleanup */
150 mipscoff_symfile_offsets
, /* sym_offsets: dummy FIXME til implem sym reloc */
151 NULL
/* next: pointer to next struct sym_fns */
155 _initialize_mipsread ()
157 add_symtab_fns (&ecoff_sym_fns
);