* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / mipsread.c
1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993 Free Software
3 Foundation, Inc.
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.
6
7 This file is part of GDB.
8
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.
13
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.
18
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. */
22
23 /* Read symbols from an ECOFF file. Most of the work is done in
24 mdebugread.c. */
25
26 #include "defs.h"
27 #include "symtab.h"
28 #include "symfile.h"
29 #include "objfiles.h"
30 #include "buildsym.h"
31 #include "stabsread.h"
32 #include "gdb-stabs.h"
33
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. */
38
39 static void
40 mipscoff_new_init PARAMS ((struct objfile *));
41
42 static void
43 mipscoff_symfile_init PARAMS ((struct objfile *));
44
45 static void
46 mipscoff_symfile_read PARAMS ((struct objfile *, struct section_offsets *,
47 int));
48
49 static void
50 mipscoff_symfile_finish PARAMS ((struct objfile *));
51
52 static struct section_offsets *
53 mipscoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
54
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). */
58
59 extern CORE_ADDR sigtramp_address;
60
61 static void
62 mipscoff_new_init (ignore)
63 struct objfile *ignore;
64 {
65 sigtramp_address = 0;
66 stabsread_new_init ();
67 buildsym_new_init ();
68 }
69
70 /* Initialize to read a symbol file (nothing to do). */
71
72 static void
73 mipscoff_symfile_init (objfile)
74 struct objfile *objfile;
75 {
76 }
77
78 /* Read a symbol file from a file. */
79
80 static void
81 mipscoff_symfile_read (objfile, section_offsets, mainline)
82 struct objfile *objfile;
83 struct section_offsets *section_offsets;
84 int mainline;
85 {
86 bfd *abfd = objfile->obfd;
87 struct cleanup * back_to;
88
89 init_minimal_symbol_collection ();
90 back_to = make_cleanup (discard_minimal_symbols, 0);
91
92 /* Now that the executable file is positioned at symbol table,
93 process it and define symbols accordingly. */
94
95 if (ecoff_slurp_symbolic_info (abfd) == false)
96 error ("Error reading symbol table: %s", bfd_errmsg (bfd_error));
97
98 mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap,
99 &ecoff_data (abfd)->debug_info, section_offsets);
100
101 /* Install any minimal symbols that have been collected as the current
102 minimal symbols for this objfile. */
103
104 install_minimal_symbols (objfile);
105
106 do_cleanups (back_to);
107 }
108
109 /* Perform any local cleanups required when we are done with a
110 particular objfile. */
111
112 static void
113 mipscoff_symfile_finish (objfile)
114 struct objfile *objfile;
115 {
116 }
117
118 /* Fake up identical offsets for all sections. */
119
120 static struct section_offsets *
121 mipscoff_symfile_offsets (objfile, addr)
122 struct objfile *objfile;
123 CORE_ADDR addr;
124 {
125 struct section_offsets *section_offsets;
126 int i;
127
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)))));
134
135 for (i = 0; i < SECT_OFF_MAX; i++)
136 ANOFFSET (section_offsets, i) = addr;
137
138 return section_offsets;
139 }
140
141 /* Initialization */
142
143 static struct sym_fns ecoff_sym_fns =
144 {
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 */
152 };
153
154 void
155 _initialize_mipsread ()
156 {
157 add_symtab_fns (&ecoff_sym_fns);
158 }
This page took 0.031675 seconds and 4 git commands to generate.