Commit | Line | Data |
---|---|---|
bd5635a1 | 1 | /* Read a symbol table in MIPS' format (Third-Eye). |
6c2e7392 PS |
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. | |
bd5635a1 RP |
6 | |
7 | This file is part of GDB. | |
8 | ||
b8c50f09 | 9 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 10 | it under the terms of the GNU General Public License as published by |
b8c50f09 JG |
11 | the Free Software Foundation; either version 2 of the License, or |
12 | (at your option) any later version. | |
bd5635a1 | 13 | |
b8c50f09 | 14 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
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 | |
b8c50f09 JG |
20 | along with this program; if not, write to the Free Software |
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 | 22 | |
3eaebb75 | 23 | /* This module provides three functions: mipscoff_symfile_init, |
817bc7b8 | 24 | which initializes to read a symbol file; mipscoff_new_init, which |
3eaebb75 SG |
25 | discards existing cached information when all symbols are being |
26 | discarded; and mipscoff_symfile_read, which reads a symbol table | |
27 | from a file. | |
28 | ||
29 | mipscoff_symfile_read only does the minimum work necessary for letting the | |
30 | user "name" things symbolically; it does not read the entire symtab. | |
31 | Instead, it reads the external and static symbols and puts them in partial | |
32 | symbol tables. When more extensive information is requested of a | |
33 | file, the corresponding partial symbol table is mutated into a full | |
34 | fledged symbol table by going back and reading the symbols | |
35 | for real. mipscoff_psymtab_to_symtab() is called indirectly through | |
d747e0af MT |
36 | a pointer in the psymtab to do this. |
37 | ||
38 | ECOFF symbol tables are mostly written in the byte order of the | |
39 | target machine. However, one section of the table (the auxiliary | |
40 | symbol information) is written in the host byte order. There is a | |
41 | bit in the other symbol info which describes which host byte order | |
42 | was used. ECOFF thereby takes the trophy from Intel `b.out' for | |
43 | the most brain-dead adaptation of a file format to byte order. | |
44 | ||
45 | This module can read all four of the known byte-order combinations, | |
6c2e7392 | 46 | on any type of host. */ |
d747e0af | 47 | |
bd5635a1 RP |
48 | #include "defs.h" |
49 | #include "symtab.h" | |
d747e0af | 50 | #include "gdbtypes.h" |
bd5635a1 RP |
51 | #include "gdbcore.h" |
52 | #include "symfile.h" | |
5e2e79f8 | 53 | #include "objfiles.h" |
7d9884b9 | 54 | #include "obstack.h" |
7e258d18 | 55 | #include "buildsym.h" |
dac4929a | 56 | #include "stabsread.h" |
51b80b00 | 57 | #include "complaints.h" |
817bc7b8 | 58 | |
ac8cf67d PS |
59 | /* These are needed if the tm.h file does not contain the necessary |
60 | mips specific definitions. */ | |
61 | ||
62 | #ifndef MIPS_EFI_SYMBOL_NAME | |
63 | #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__" | |
64 | #include "coff/sym.h" | |
65 | #include "coff/symconst.h" | |
66 | typedef struct mips_extra_func_info { | |
67 | long numargs; | |
68 | PDR pdr; | |
69 | } *mips_extra_func_info_t; | |
70 | #ifndef RA_REGNUM | |
71 | #define RA_REGNUM 0 | |
72 | #endif | |
73 | #ifndef FP0_REGNUM | |
74 | #define FP0_REGNUM 0 | |
75 | #endif | |
76 | #endif | |
77 | ||
817bc7b8 JG |
78 | #ifdef USG |
79 | #include <sys/types.h> | |
817bc7b8 JG |
80 | #endif |
81 | ||
7d9884b9 JG |
82 | #include <sys/param.h> |
83 | #include <sys/file.h> | |
84 | #include <sys/stat.h> | |
85f0a848 | 85 | #include <string.h> |
fa0bcaa3 | 86 | |
dac4929a SG |
87 | #include "gdb-stabs.h" |
88 | ||
6c2e7392 PS |
89 | #include "bfd.h" |
90 | ||
91 | #include "coff/internal.h" | |
817bc7b8 | 92 | #include "coff/mips.h" /* COFF-like aspects of ecoff files */ |
817bc7b8 | 93 | #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */ |
e10a3052 | 94 | |
6c2e7392 PS |
95 | /* FIXME: coff/internal.h and aout/aout64.h both define N_ABS. We |
96 | want the definition from aout/aout64.h. */ | |
97 | #undef N_ABS | |
6c2e7392 PS |
98 | |
99 | #include "libaout.h" /* Private BFD a.out information. */ | |
7e258d18 | 100 | #include "aout/aout64.h" |
817bc7b8 | 101 | #include "aout/stab_gnu.h" /* STABS information */ |
6c2e7392 PS |
102 | |
103 | /* FIXME: libcoff.h and libaout.h both define a couple of macros. We | |
104 | don't use them. */ | |
105 | #undef exec_hdr | |
106 | #undef obj_sym_filepos | |
107 | ||
108 | #include "libcoff.h" /* Private BFD COFF information. */ | |
109 | #include "libecoff.h" /* Private BFD ECOFF information. */ | |
110 | ||
85f0a848 FF |
111 | #include "expression.h" |
112 | #include "language.h" /* Needed inside partial-stab.h */ | |
bd5635a1 | 113 | |
6c2e7392 PS |
114 | /* Each partial symbol table entry contains a pointer to private data |
115 | for the read_symtab() function to use when expanding a partial | |
116 | symbol table entry to a full symbol table entry. | |
4a35d6e9 | 117 | |
6c2e7392 PS |
118 | For mipsread this structure contains the index of the FDR that this |
119 | psymtab represents and a pointer to the BFD that the psymtab was | |
120 | created from. */ | |
4a35d6e9 | 121 | |
d4ea2aba PB |
122 | #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private) |
123 | #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx) | |
6c2e7392 | 124 | #define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd) |
4a35d6e9 | 125 | |
5f7b2142 ILT |
126 | struct symloc |
127 | { | |
4a35d6e9 | 128 | int fdr_idx; |
6c2e7392 PS |
129 | bfd *cur_bfd; |
130 | EXTR *extern_tab; /* Pointer to external symbols for this file. */ | |
131 | int extern_count; /* Size of extern_tab. */ | |
132 | struct mips_pending **pending_list; | |
4a35d6e9 FF |
133 | }; |
134 | ||
bd5635a1 RP |
135 | /* Things we import explicitly from other modules */ |
136 | ||
5f7b2142 | 137 | extern int info_verbose; |
bd5635a1 | 138 | |
3eaebb75 | 139 | /* Various complaints about symbol reading that don't abort the process */ |
817bc7b8 JG |
140 | |
141 | struct complaint bad_file_number_complaint = | |
5f7b2142 | 142 | {"bad file number %d", 0, 0}; |
021959e2 | 143 | |
817bc7b8 | 144 | struct complaint index_complaint = |
5f7b2142 | 145 | {"bad aux index at symbol %s", 0, 0}; |
817bc7b8 JG |
146 | |
147 | struct complaint aux_index_complaint = | |
5f7b2142 | 148 | {"bad proc end in aux found from symbol %s", 0, 0}; |
817bc7b8 | 149 | |
6edd74ae | 150 | struct complaint block_index_complaint = |
5f7b2142 | 151 | {"bad aux index at block symbol %s", 0, 0}; |
6edd74ae | 152 | |
817bc7b8 | 153 | struct complaint unknown_ext_complaint = |
5f7b2142 | 154 | {"unknown external symbol %s", 0, 0}; |
bd5635a1 | 155 | |
817bc7b8 | 156 | struct complaint unknown_sym_complaint = |
5f7b2142 | 157 | {"unknown local symbol %s", 0, 0}; |
101f259c | 158 | |
817bc7b8 | 159 | struct complaint unknown_st_complaint = |
5f7b2142 | 160 | {"with type %d", 0, 0}; |
101f259c | 161 | |
817bc7b8 | 162 | struct complaint block_overflow_complaint = |
5f7b2142 | 163 | {"block containing %s overfilled", 0, 0}; |
3eaebb75 | 164 | |
817bc7b8 | 165 | struct complaint basic_type_complaint = |
5f7b2142 | 166 | {"cannot map MIPS basic type 0x%x", 0, 0}; |
3eaebb75 | 167 | |
817bc7b8 | 168 | struct complaint unknown_type_qual_complaint = |
5f7b2142 | 169 | {"unknown type qualifier 0x%x", 0, 0}; |
3eaebb75 | 170 | |
817bc7b8 | 171 | struct complaint array_bitsize_complaint = |
5f7b2142 | 172 | {"size of array target type not known, assuming %d bits", 0, 0}; |
3eaebb75 | 173 | |
817bc7b8 | 174 | struct complaint bad_tag_guess_complaint = |
5f7b2142 | 175 | {"guessed tag type of %s incorrectly", 0, 0}; |
817bc7b8 JG |
176 | |
177 | struct complaint block_member_complaint = | |
5f7b2142 | 178 | {"declaration block contains unhandled symbol type %d", 0, 0}; |
817bc7b8 JG |
179 | |
180 | struct complaint stEnd_complaint = | |
5f7b2142 | 181 | {"stEnd with storage class %d not handled", 0, 0}; |
817bc7b8 JG |
182 | |
183 | struct complaint unknown_mips_symtype_complaint = | |
5f7b2142 | 184 | {"unknown symbol type 0x%x", 0, 0}; |
817bc7b8 JG |
185 | |
186 | struct complaint stab_unknown_complaint = | |
5f7b2142 | 187 | {"unknown stabs symbol %s", 0, 0}; |
817bc7b8 JG |
188 | |
189 | struct complaint pdr_for_nonsymbol_complaint = | |
5f7b2142 | 190 | {"PDR for %s, but no symbol", 0, 0}; |
817bc7b8 JG |
191 | |
192 | struct complaint pdr_static_symbol_complaint = | |
5f7b2142 | 193 | {"can't handle PDR for static proc at 0x%x", 0, 0}; |
c55e6167 | 194 | |
e157305c PS |
195 | struct complaint bad_setjmp_pdr_complaint = |
196 | {"fixing bad setjmp PDR from libc", 0, 0}; | |
197 | ||
3eaebb75 SG |
198 | /* Macros and extra defs */ |
199 | ||
200 | /* Already-parsed symbols are marked specially */ | |
bd5635a1 RP |
201 | |
202 | #define stParsed stType | |
203 | ||
204 | /* Puns: hard to find whether -g was used and how */ | |
205 | ||
206 | #define MIN_GLEVEL GLEVEL_0 | |
207 | #define compare_glevel(a,b) \ | |
208 | (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \ | |
209 | ((b) == GLEVEL_3) ? -1 : (int)((b) - (a))) | |
e072c738 JG |
210 | \f |
211 | /* Things that really are local to this module */ | |
212 | ||
c4413e2c FF |
213 | /* Remember what we deduced to be the source language of this psymtab. */ |
214 | ||
215 | static enum language psymtab_language = language_unknown; | |
216 | ||
6c2e7392 | 217 | /* Current BFD. */ |
3eaebb75 | 218 | |
6c2e7392 | 219 | static bfd *cur_bfd; |
3eaebb75 | 220 | |
e072c738 JG |
221 | /* Pointer to current file decriptor record, and its index */ |
222 | ||
5f7b2142 ILT |
223 | static FDR *cur_fdr; |
224 | static int cur_fd; | |
e072c738 JG |
225 | |
226 | /* Index of current symbol */ | |
227 | ||
5f7b2142 | 228 | static int cur_sdx; |
e072c738 JG |
229 | |
230 | /* Note how much "debuggable" this image is. We would like | |
231 | to see at least one FDR with full symbols */ | |
232 | ||
233 | static max_gdbinfo; | |
234 | static max_glevel; | |
235 | ||
236 | /* When examining .o files, report on undefined symbols */ | |
237 | ||
238 | static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs; | |
239 | ||
7e258d18 PB |
240 | /* Pseudo symbol to use when putting stabs into the symbol table. */ |
241 | ||
c55e6167 | 242 | static char stabs_symbol[] = STABS_SYMBOL; |
7e258d18 | 243 | |
e072c738 JG |
244 | /* Extra builtin types */ |
245 | ||
246 | struct type *builtin_type_complex; | |
247 | struct type *builtin_type_double_complex; | |
248 | struct type *builtin_type_fixed_dec; | |
249 | struct type *builtin_type_float_dec; | |
250 | struct type *builtin_type_string; | |
251 | ||
3eaebb75 | 252 | /* Forward declarations */ |
e072c738 | 253 | |
d747e0af | 254 | static void |
dac4929a | 255 | read_mips_symtab PARAMS ((struct objfile *, struct section_offsets *)); |
84ffdec2 JG |
256 | |
257 | static void | |
6c2e7392 | 258 | read_the_mips_symtab PARAMS ((bfd *)); |
84ffdec2 JG |
259 | |
260 | static int | |
e10a3052 | 261 | upgrade_type PARAMS ((struct type **, int, union aux_ext *, int)); |
84ffdec2 JG |
262 | |
263 | static void | |
6c2e7392 | 264 | parse_partial_symbols PARAMS ((struct objfile *, |
dac4929a | 265 | struct section_offsets *)); |
d747e0af MT |
266 | |
267 | static int | |
e5578a31 SG |
268 | cross_ref PARAMS ((union aux_ext *, struct type **, enum type_code, char **, |
269 | int)); | |
84ffdec2 JG |
270 | |
271 | static void | |
272 | fixup_sigtramp PARAMS ((void)); | |
273 | ||
274 | static struct symbol * | |
275 | new_symbol PARAMS ((char *)); | |
276 | ||
277 | static struct type * | |
278 | new_type PARAMS ((char *)); | |
279 | ||
280 | static struct block * | |
281 | new_block PARAMS ((int)); | |
282 | ||
283 | static struct symtab * | |
284 | new_symtab PARAMS ((char *, int, int, struct objfile *)); | |
285 | ||
286 | static struct linetable * | |
287 | new_linetable PARAMS ((int)); | |
288 | ||
289 | static struct blockvector * | |
290 | new_bvect PARAMS ((int)); | |
291 | ||
292 | static struct type * | |
293 | parse_type PARAMS ((union aux_ext *, int *, int)); | |
294 | ||
295 | static struct symbol * | |
296 | mylookup_symbol PARAMS ((char *, struct block *, enum namespace, | |
297 | enum address_class)); | |
298 | ||
299 | static struct block * | |
300 | shrink_block PARAMS ((struct block *, struct symtab *)); | |
301 | ||
302 | static PTR | |
303 | xzalloc PARAMS ((unsigned int)); | |
d747e0af MT |
304 | |
305 | static void | |
84ffdec2 | 306 | sort_blocks PARAMS ((struct symtab *)); |
d747e0af MT |
307 | |
308 | static int | |
391ca579 | 309 | compare_blocks PARAMS ((const void *, const void *)); |
84ffdec2 JG |
310 | |
311 | static struct partial_symtab * | |
312 | new_psymtab PARAMS ((char *, struct objfile *)); | |
313 | ||
314 | #if 0 | |
315 | static struct partial_symtab * | |
316 | parse_fdr PARAMS ((int, int, struct objfile *)); | |
317 | #endif | |
d747e0af MT |
318 | |
319 | static void | |
84ffdec2 | 320 | psymtab_to_symtab_1 PARAMS ((struct partial_symtab *, char *)); |
c55e6167 | 321 | |
84ffdec2 JG |
322 | static void |
323 | add_block PARAMS ((struct block *, struct symtab *)); | |
324 | ||
325 | static void | |
326 | add_symbol PARAMS ((struct symbol *, struct block *)); | |
327 | ||
328 | static int | |
329 | add_line PARAMS ((struct linetable *, int, CORE_ADDR, int)); | |
330 | ||
331 | static struct linetable * | |
332 | shrink_linetable PARAMS ((struct linetable *)); | |
333 | ||
334 | static char * | |
335 | mips_next_symbol_text PARAMS ((void)); | |
bd5635a1 RP |
336 | \f |
337 | /* Things we export to other modules */ | |
338 | ||
bd5635a1 | 339 | /* Address bounds for the signal trampoline in inferior, if any */ |
101f259c | 340 | /* FIXME: Nothing really seems to use this. Why is it here? */ |
bd5635a1 RP |
341 | |
342 | CORE_ADDR sigtramp_address, sigtramp_end; | |
343 | ||
4ad1963e | 344 | static void |
84ffdec2 JG |
345 | mipscoff_new_init (ignore) |
346 | struct objfile *ignore; | |
bd5635a1 | 347 | { |
e7ff735c | 348 | sigtramp_address = 0; |
0b0d6c3f PS |
349 | stabsread_new_init (); |
350 | buildsym_new_init (); | |
bd5635a1 RP |
351 | } |
352 | ||
4ad1963e | 353 | static void |
80d68b1d FF |
354 | mipscoff_symfile_init (objfile) |
355 | struct objfile *objfile; | |
bd5635a1 | 356 | { |
5f7b2142 | 357 | if (objfile->sym_private != NULL) |
80d68b1d | 358 | { |
5f7b2142 | 359 | mfree (objfile->md, objfile->sym_private); |
80d68b1d | 360 | } |
5f7b2142 | 361 | objfile->sym_private = NULL; |
bd5635a1 RP |
362 | } |
363 | ||
4ad1963e | 364 | static void |
dac4929a | 365 | mipscoff_symfile_read (objfile, section_offsets, mainline) |
80d68b1d | 366 | struct objfile *objfile; |
dac4929a | 367 | struct section_offsets *section_offsets; |
bd5635a1 RP |
368 | int mainline; |
369 | { | |
021959e2 JG |
370 | init_minimal_symbol_collection (); |
371 | make_cleanup (discard_minimal_symbols, 0); | |
bd5635a1 RP |
372 | |
373 | /* Now that the executable file is positioned at symbol table, | |
374 | process it and define symbols accordingly. */ | |
375 | ||
5f7b2142 | 376 | read_mips_symtab (objfile, section_offsets); |
bd5635a1 | 377 | |
021959e2 JG |
378 | /* Install any minimal symbols that have been collected as the current |
379 | minimal symbols for this objfile. */ | |
bd5635a1 | 380 | |
80d68b1d | 381 | install_minimal_symbols (objfile); |
bd5635a1 | 382 | } |
817bc7b8 | 383 | |
80d68b1d FF |
384 | /* Perform any local cleanups required when we are done with a particular |
385 | objfile. I.E, we are in the process of discarding all symbol information | |
386 | for an objfile, freeing up all memory held for it, and unlinking the | |
387 | objfile struct from the global list of known objfiles. */ | |
388 | ||
389 | static void | |
390 | mipscoff_symfile_finish (objfile) | |
391 | struct objfile *objfile; | |
392 | { | |
5f7b2142 | 393 | if (objfile->sym_private != NULL) |
80d68b1d | 394 | { |
5f7b2142 | 395 | mfree (objfile->md, objfile->sym_private); |
80d68b1d FF |
396 | } |
397 | ||
6c2e7392 | 398 | cur_bfd = 0; |
80d68b1d FF |
399 | } |
400 | ||
d747e0af | 401 | /* Allocate zeroed memory */ |
bd5635a1 | 402 | |
84ffdec2 | 403 | static PTR |
5f7b2142 | 404 | xzalloc (size) |
e10a3052 | 405 | unsigned int size; |
bd5635a1 | 406 | { |
51b57ded | 407 | PTR p = xmalloc (size); |
bd5635a1 | 408 | |
4ed3a9ea | 409 | memset (p, 0, size); |
51b57ded | 410 | return p; |
bd5635a1 RP |
411 | } |
412 | ||
413 | /* Exported procedure: Builds a symtab from the PST partial one. | |
414 | Restores the environment in effect when PST was created, delegates | |
415 | most of the work to an ancillary procedure, and sorts | |
416 | and reorders the symtab list at the end */ | |
417 | ||
3eaebb75 | 418 | static void |
5f7b2142 ILT |
419 | mipscoff_psymtab_to_symtab (pst) |
420 | struct partial_symtab *pst; | |
bd5635a1 | 421 | { |
bd5635a1 | 422 | |
5f7b2142 ILT |
423 | if (!pst) |
424 | return; | |
bd5635a1 | 425 | |
5f7b2142 ILT |
426 | if (info_verbose) |
427 | { | |
428 | printf_filtered ("Reading in symbols for %s...", pst->filename); | |
429 | fflush (stdout); | |
430 | } | |
bd5635a1 | 431 | |
5f7b2142 | 432 | next_symbol_text_func = mips_next_symbol_text; |
c55e6167 | 433 | |
5f7b2142 | 434 | psymtab_to_symtab_1 (pst, pst->filename); |
bd5635a1 | 435 | |
5f7b2142 ILT |
436 | /* Match with global symbols. This only needs to be done once, |
437 | after all of the symtabs and dependencies have been read in. */ | |
438 | scan_file_globals (pst->objfile); | |
bd5635a1 | 439 | |
5f7b2142 ILT |
440 | if (info_verbose) |
441 | printf_filtered ("done.\n"); | |
bd5635a1 RP |
442 | } |
443 | ||
444 | /* Exported procedure: Is PC in the signal trampoline code */ | |
445 | ||
b8c50f09 | 446 | int |
5f7b2142 ILT |
447 | in_sigtramp (pc, ignore) |
448 | CORE_ADDR pc; | |
449 | char *ignore; /* function name */ | |
bd5635a1 | 450 | { |
5f7b2142 ILT |
451 | if (sigtramp_address == 0) |
452 | fixup_sigtramp (); | |
453 | return (pc >= sigtramp_address && pc < sigtramp_end); | |
bd5635a1 | 454 | } |
bd5635a1 RP |
455 | \f |
456 | /* File-level interface functions */ | |
457 | ||
6c2e7392 | 458 | /* Read the symtab information from file ABFD into memory. */ |
d747e0af MT |
459 | |
460 | static void | |
6c2e7392 | 461 | read_the_mips_symtab (abfd) |
5f7b2142 | 462 | bfd *abfd; |
bd5635a1 | 463 | { |
6c2e7392 PS |
464 | if (ecoff_slurp_symbolic_info (abfd) == false) |
465 | error ("Error reading symbol table: %s", bfd_errmsg (bfd_error)); | |
bd5635a1 RP |
466 | } |
467 | ||
bd5635a1 RP |
468 | /* Find a file descriptor given its index RF relative to a file CF */ |
469 | ||
3eaebb75 SG |
470 | static FDR * |
471 | get_rfd (cf, rf) | |
5f7b2142 | 472 | int cf, rf; |
bd5635a1 | 473 | { |
6c2e7392 | 474 | FDR *fdrs; |
5f7b2142 | 475 | register FDR *f; |
6c2e7392 | 476 | RFDT rfd; |
5f7b2142 | 477 | |
6c2e7392 PS |
478 | fdrs = ecoff_data (cur_bfd)->fdr; |
479 | f = fdrs + cf; | |
5f7b2142 ILT |
480 | /* Object files do not have the RFD table, all refs are absolute */ |
481 | if (f->rfdBase == 0) | |
6c2e7392 PS |
482 | return fdrs + rf; |
483 | ecoff_swap_rfd_in (cur_bfd, | |
484 | ecoff_data (cur_bfd)->external_rfd + f->rfdBase + rf, | |
485 | &rfd); | |
486 | return fdrs + rfd; | |
bd5635a1 RP |
487 | } |
488 | ||
489 | /* Return a safer print NAME for a file descriptor */ | |
490 | ||
3eaebb75 | 491 | static char * |
6c2e7392 PS |
492 | fdr_name (f) |
493 | FDR *f; | |
bd5635a1 | 494 | { |
6c2e7392 | 495 | if (f->rss == -1) |
5f7b2142 | 496 | return "<stripped file>"; |
6c2e7392 | 497 | if (f->rss == 0) |
5f7b2142 | 498 | return "<NFY>"; |
6c2e7392 | 499 | return ecoff_data (cur_bfd)->ss + f->issBase + f->rss; |
bd5635a1 RP |
500 | } |
501 | ||
502 | ||
dac4929a SG |
503 | /* Read in and parse the symtab of the file OBJFILE. Symbols from |
504 | different sections are relocated via the SECTION_OFFSETS. */ | |
bd5635a1 | 505 | |
d747e0af | 506 | static void |
dac4929a | 507 | read_mips_symtab (objfile, section_offsets) |
5f7b2142 ILT |
508 | struct objfile *objfile; |
509 | struct section_offsets *section_offsets; | |
bd5635a1 | 510 | { |
6c2e7392 | 511 | cur_bfd = objfile->obfd; |
bd5635a1 | 512 | |
6c2e7392 | 513 | read_the_mips_symtab (objfile->obfd); |
bd5635a1 | 514 | |
6c2e7392 | 515 | parse_partial_symbols (objfile, section_offsets); |
bd5635a1 | 516 | |
7e258d18 | 517 | #if 0 |
6c2e7392 PS |
518 | /* Check to make sure file was compiled with -g. If not, warn the |
519 | user of this limitation. */ | |
5f7b2142 ILT |
520 | if (compare_glevel (max_glevel, GLEVEL_2) < 0) |
521 | { | |
522 | if (max_gdbinfo == 0) | |
6c2e7392 | 523 | printf ("\n%s not compiled with -g, debugging support is limited.\n", |
5f7b2142 | 524 | objfile->name); |
6c2e7392 | 525 | printf ("You should compile with -g2 or -g3 for best debugging support.\n"); |
5f7b2142 ILT |
526 | fflush (stdout); |
527 | } | |
7e258d18 | 528 | #endif |
bd5635a1 | 529 | } |
bd5635a1 RP |
530 | \f |
531 | /* Local utilities */ | |
532 | ||
bd5635a1 RP |
533 | /* Map of FDR indexes to partial symtabs */ |
534 | ||
5f7b2142 ILT |
535 | struct pst_map |
536 | { | |
537 | struct partial_symtab *pst; /* the psymtab proper */ | |
538 | int n_globals; /* exported globals (external symbols) */ | |
539 | int globals_offset; /* cumulative */ | |
d4ea2aba | 540 | }; |
bd5635a1 RP |
541 | |
542 | ||
543 | /* Utility stack, used to nest procedures and blocks properly. | |
544 | It is a doubly linked list, to avoid too many alloc/free. | |
545 | Since we might need it quite a few times it is NOT deallocated | |
546 | after use. */ | |
547 | ||
5f7b2142 ILT |
548 | static struct parse_stack |
549 | { | |
550 | struct parse_stack *next, *prev; | |
551 | struct symtab *cur_st; /* Current symtab. */ | |
552 | struct block *cur_block; /* Block in it. */ | |
553 | int blocktype; /* What are we parsing. */ | |
554 | int maxsyms; /* Max symbols in this block. */ | |
555 | struct type *cur_type; /* Type we parse fields for. */ | |
556 | int cur_field; /* Field number in cur_type. */ | |
557 | int procadr; /* Start addres of this procedure */ | |
558 | int numargs; /* Its argument count */ | |
6c2e7392 PS |
559 | } |
560 | ||
561 | *top_stack; /* Top stack ptr */ | |
bd5635a1 RP |
562 | |
563 | ||
564 | /* Enter a new lexical context */ | |
565 | ||
4ad1963e | 566 | static void |
5f7b2142 | 567 | push_parse_stack () |
bd5635a1 | 568 | { |
5f7b2142 ILT |
569 | struct parse_stack *new; |
570 | ||
571 | /* Reuse frames if possible */ | |
572 | if (top_stack && top_stack->prev) | |
573 | new = top_stack->prev; | |
574 | else | |
575 | new = (struct parse_stack *) xzalloc (sizeof (struct parse_stack)); | |
576 | /* Initialize new frame with previous content */ | |
577 | if (top_stack) | |
578 | { | |
579 | register struct parse_stack *prev = new->prev; | |
bd5635a1 | 580 | |
5f7b2142 ILT |
581 | *new = *top_stack; |
582 | top_stack->prev = new; | |
583 | new->prev = prev; | |
584 | new->next = top_stack; | |
585 | } | |
586 | top_stack = new; | |
bd5635a1 RP |
587 | } |
588 | ||
589 | /* Exit a lexical context */ | |
590 | ||
4ad1963e | 591 | static void |
5f7b2142 | 592 | pop_parse_stack () |
bd5635a1 | 593 | { |
5f7b2142 ILT |
594 | if (!top_stack) |
595 | return; | |
596 | if (top_stack->next) | |
597 | top_stack = top_stack->next; | |
bd5635a1 RP |
598 | } |
599 | ||
600 | ||
601 | /* Cross-references might be to things we haven't looked at | |
602 | yet, e.g. type references. To avoid too many type | |
603 | duplications we keep a quick fixup table, an array | |
604 | of lists of references indexed by file descriptor */ | |
605 | ||
5f7b2142 ILT |
606 | static struct mips_pending |
607 | { | |
608 | struct mips_pending *next; /* link */ | |
6c2e7392 | 609 | struct sym_ext *s; /* the symbol */ |
5f7b2142 | 610 | struct type *t; /* its partial type descriptor */ |
bd5635a1 RP |
611 | } **pending_list; |
612 | ||
613 | ||
614 | /* Check whether we already saw symbol SH in file FH as undefined */ | |
615 | ||
4ad1963e | 616 | static struct mips_pending * |
5f7b2142 ILT |
617 | is_pending_symbol (fh, sh) |
618 | FDR *fh; | |
6c2e7392 | 619 | struct sym_ext *sh; |
bd5635a1 | 620 | { |
6c2e7392 | 621 | int f_idx = fh - ecoff_data (cur_bfd)->fdr; |
5f7b2142 ILT |
622 | register struct mips_pending *p; |
623 | ||
624 | /* Linear search is ok, list is typically no more than 10 deep */ | |
625 | for (p = pending_list[f_idx]; p; p = p->next) | |
626 | if (p->s == sh) | |
627 | break; | |
628 | return p; | |
bd5635a1 RP |
629 | } |
630 | ||
bd5635a1 RP |
631 | /* Add a new undef symbol SH of type T */ |
632 | ||
4ad1963e | 633 | static void |
5f7b2142 ILT |
634 | add_pending (fh, sh, t) |
635 | FDR *fh; | |
6c2e7392 | 636 | struct sym_ext *sh; |
5f7b2142 | 637 | struct type *t; |
bd5635a1 | 638 | { |
6c2e7392 | 639 | int f_idx = fh - ecoff_data (cur_bfd)->fdr; |
5f7b2142 ILT |
640 | struct mips_pending *p = is_pending_symbol (fh, sh); |
641 | ||
642 | /* Make sure we do not make duplicates */ | |
643 | if (!p) | |
644 | { | |
645 | p = (struct mips_pending *) xmalloc (sizeof (*p)); | |
646 | p->s = sh; | |
647 | p->t = t; | |
648 | p->next = pending_list[f_idx]; | |
649 | pending_list[f_idx] = p; | |
650 | } | |
bd5635a1 RP |
651 | } |
652 | ||
653 | /* Throw away undef entries when done with file index F_IDX */ | |
84ffdec2 | 654 | /* FIXME -- storage leak. This is never called!!! --gnu */ |
bd5635a1 | 655 | |
51b57ded FF |
656 | #if 0 |
657 | ||
4ad1963e | 658 | static void |
5f7b2142 ILT |
659 | free_pending (f_idx) |
660 | int f_idx; | |
bd5635a1 | 661 | { |
5f7b2142 | 662 | register struct mips_pending *p, *q; |
bd5635a1 | 663 | |
5f7b2142 ILT |
664 | for (p = pending_list[f_idx]; p; p = q) |
665 | { | |
666 | q = p->next; | |
667 | free ((PTR) p); | |
668 | } | |
669 | pending_list[f_idx] = 0; | |
bd5635a1 RP |
670 | } |
671 | ||
51b57ded FF |
672 | #endif |
673 | ||
bd5635a1 | 674 | \f |
5f7b2142 | 675 | |
bd5635a1 RP |
676 | /* Parsing Routines proper. */ |
677 | ||
678 | /* Parse a single symbol. Mostly just make up a GDB symbol for it. | |
679 | For blocks, procedures and types we open a new lexical context. | |
6c2e7392 PS |
680 | This is basically just a big switch on the symbol's type. Argument |
681 | AX is the base pointer of aux symbols for this file (fh->iauxBase). | |
682 | EXT_SH points to the unswapped symbol, which is needed for struct, | |
683 | union, etc., types; it is NULL for an EXTR. BIGEND says whether | |
684 | aux symbols are big-endian or little-endian. Return count of | |
685 | SYMR's handled (normally one). | |
686 | ||
687 | FIXME: This modifies the symbol, but the only way we have to save | |
688 | the modified information is to stuff it back into the BFD data. */ | |
bd5635a1 | 689 | |
7e258d18 | 690 | static int |
6c2e7392 | 691 | parse_symbol (sh, ax, ext_sh, bigend) |
5f7b2142 ILT |
692 | SYMR *sh; |
693 | union aux_ext *ax; | |
6c2e7392 | 694 | struct sym_ext *ext_sh; |
5f7b2142 | 695 | int bigend; |
bd5635a1 | 696 | { |
5f7b2142 ILT |
697 | char *name; |
698 | struct symbol *s; | |
699 | struct block *b; | |
6c2e7392 | 700 | struct mips_pending *pend; |
5f7b2142 ILT |
701 | struct type *t; |
702 | struct field *f; | |
703 | int count = 1; | |
5f7b2142 ILT |
704 | enum address_class class; |
705 | TIR tir; | |
706 | ||
6c2e7392 PS |
707 | if (ext_sh == (struct sym_ext *) NULL) |
708 | name = ecoff_data (cur_bfd)->ssext + sh->iss; | |
709 | else | |
710 | name = ecoff_data (cur_bfd)->ss + cur_fdr->issBase + sh->iss; | |
711 | ||
5f7b2142 ILT |
712 | switch (sh->st) |
713 | { | |
5f7b2142 ILT |
714 | case stNil: |
715 | break; | |
716 | ||
717 | case stGlobal: /* external symbol, goes into global block */ | |
718 | class = LOC_STATIC; | |
719 | b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st), | |
720 | GLOBAL_BLOCK); | |
6c2e7392 | 721 | s = new_symbol (name); |
5f7b2142 ILT |
722 | SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; |
723 | goto data; | |
724 | ||
725 | case stStatic: /* static data, goes into current block. */ | |
726 | class = LOC_STATIC; | |
727 | b = top_stack->cur_block; | |
6c2e7392 | 728 | s = new_symbol (name); |
e7ff735c JK |
729 | if (sh->sc == scCommon) |
730 | { | |
731 | /* It is a FORTRAN common block. At least for SGI Fortran the | |
732 | address is not in the symbol; we need to fix it later in | |
733 | scan_file_globals. */ | |
734 | int bucket = hashname (SYMBOL_NAME (s)); | |
735 | SYMBOL_VALUE_CHAIN (s) = global_sym_chain[bucket]; | |
736 | global_sym_chain[bucket] = s; | |
737 | } | |
738 | else | |
739 | SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; | |
5f7b2142 ILT |
740 | goto data; |
741 | ||
742 | case stLocal: /* local variable, goes into current block */ | |
743 | if (sh->sc == scRegister) | |
744 | { | |
745 | class = LOC_REGISTER; | |
746 | if (sh->value > 31) | |
747 | sh->value += FP0_REGNUM - 32; | |
748 | } | |
749 | else | |
750 | class = LOC_LOCAL; | |
751 | b = top_stack->cur_block; | |
6c2e7392 | 752 | s = new_symbol (name); |
5f7b2142 ILT |
753 | SYMBOL_VALUE (s) = sh->value; |
754 | ||
755 | data: /* Common code for symbols describing data */ | |
756 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; | |
757 | SYMBOL_CLASS (s) = class; | |
758 | add_symbol (s, b); | |
759 | ||
760 | /* Type could be missing in a number of cases */ | |
761 | if (sh->sc == scUndefined || sh->sc == scNil || | |
762 | sh->index == 0xfffff) | |
763 | SYMBOL_TYPE (s) = builtin_type_int; /* undefined? */ | |
764 | else | |
765 | SYMBOL_TYPE (s) = parse_type (ax + sh->index, 0, bigend); | |
766 | /* Value of a data symbol is its memory address */ | |
767 | break; | |
768 | ||
769 | case stParam: /* arg to procedure, goes into current block */ | |
770 | max_gdbinfo++; | |
771 | top_stack->numargs++; | |
772 | ||
5f7b2142 ILT |
773 | /* Special GNU C++ name. */ |
774 | if (name[0] == CPLUS_MARKER && name[1] == 't' && name[2] == 0) | |
775 | name = "this"; /* FIXME, not alloc'd in obstack */ | |
776 | s = new_symbol (name); | |
777 | ||
778 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; | |
e7ff735c | 779 | switch (sh->sc) |
5f7b2142 | 780 | { |
e7ff735c JK |
781 | case scRegister: |
782 | /* Pass by value in register. */ | |
783 | SYMBOL_CLASS(s) = LOC_REGPARM; | |
5f7b2142 | 784 | if (sh->value > 31) |
e7ff735c JK |
785 | sh->value += FP0_REGNUM-32; |
786 | break; | |
787 | case scVar: | |
788 | /* Pass by reference on stack. */ | |
789 | SYMBOL_CLASS(s) = LOC_REF_ARG; | |
790 | break; | |
791 | case scVarRegister: | |
792 | /* Pass by reference in register. */ | |
793 | SYMBOL_CLASS(s) = LOC_REGPARM_ADDR; | |
794 | break; | |
795 | default: | |
796 | /* Pass by value on stack. */ | |
797 | SYMBOL_CLASS(s) = LOC_ARG; | |
798 | break; | |
5f7b2142 | 799 | } |
5f7b2142 ILT |
800 | SYMBOL_VALUE (s) = sh->value; |
801 | SYMBOL_TYPE (s) = parse_type (ax + sh->index, 0, bigend); | |
802 | add_symbol (s, top_stack->cur_block); | |
0c4d2cc2 | 803 | #if 0 |
5f7b2142 ILT |
804 | /* FIXME: This has not been tested. See dbxread.c */ |
805 | /* Add the type of this parameter to the function/procedure | |
0c4d2cc2 | 806 | type of this block. */ |
5f7b2142 | 807 | add_param_to_type (&top_stack->cur_block->function->type, s); |
0c4d2cc2 | 808 | #endif |
5f7b2142 ILT |
809 | break; |
810 | ||
811 | case stLabel: /* label, goes into current block */ | |
6c2e7392 | 812 | s = new_symbol (name); |
5f7b2142 ILT |
813 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; /* so that it can be used */ |
814 | SYMBOL_CLASS (s) = LOC_LABEL; /* but not misused */ | |
815 | SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; | |
816 | SYMBOL_TYPE (s) = builtin_type_int; | |
817 | add_symbol (s, top_stack->cur_block); | |
818 | break; | |
819 | ||
1c8961dd JK |
820 | case stStaticProc: |
821 | /* I believe this is used only for file-local functions. | |
822 | The comment in symconst.h ("load time only static procs") isn't | |
823 | particularly clear on this point. */ | |
824 | prim_record_minimal_symbol (name, sh->value, mst_file_text); | |
825 | /* FALLTHROUGH */ | |
826 | ||
5f7b2142 | 827 | case stProc: /* Procedure, usually goes into global block */ |
6c2e7392 | 828 | s = new_symbol (name); |
5f7b2142 ILT |
829 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; |
830 | SYMBOL_CLASS (s) = LOC_BLOCK; | |
831 | /* Type of the return value */ | |
832 | if (sh->sc == scUndefined || sh->sc == scNil) | |
833 | t = builtin_type_int; | |
834 | else | |
835 | t = parse_type (ax + sh->index + 1, 0, bigend); | |
836 | b = top_stack->cur_block; | |
837 | if (sh->st == stProc) | |
838 | { | |
839 | struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); | |
840 | /* The next test should normally be true, | |
0c4d2cc2 JG |
841 | but provides a hook for nested functions |
842 | (which we don't want to make global). */ | |
5f7b2142 ILT |
843 | if (b == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) |
844 | b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); | |
845 | } | |
846 | add_symbol (s, b); | |
bd5635a1 | 847 | |
5f7b2142 | 848 | /* Make a type for the procedure itself */ |
0c4d2cc2 | 849 | #if 0 |
5f7b2142 ILT |
850 | /* FIXME: This has not been tested yet! See dbxread.c */ |
851 | /* Generate a template for the type of this function. The | |
852 | types of the arguments will be added as we read the symbol | |
853 | table. */ | |
854 | bcopy (SYMBOL_TYPE (s), lookup_function_type (t), sizeof (struct type)); | |
0c4d2cc2 | 855 | #else |
5f7b2142 | 856 | SYMBOL_TYPE (s) = lookup_function_type (t); |
0c4d2cc2 | 857 | #endif |
bd5635a1 | 858 | |
5f7b2142 ILT |
859 | /* Create and enter a new lexical context */ |
860 | b = new_block (top_stack->maxsyms); | |
861 | SYMBOL_BLOCK_VALUE (s) = b; | |
862 | BLOCK_FUNCTION (b) = s; | |
863 | BLOCK_START (b) = BLOCK_END (b) = sh->value; | |
864 | BLOCK_SUPERBLOCK (b) = top_stack->cur_block; | |
865 | add_block (b, top_stack->cur_st); | |
866 | ||
867 | /* Not if we only have partial info */ | |
868 | if (sh->sc == scUndefined || sh->sc == scNil) | |
869 | break; | |
870 | ||
871 | push_parse_stack (); | |
872 | top_stack->cur_block = b; | |
873 | top_stack->blocktype = sh->st; | |
874 | top_stack->cur_type = SYMBOL_TYPE (s); | |
875 | top_stack->cur_field = -1; | |
876 | top_stack->procadr = sh->value; | |
877 | top_stack->numargs = 0; | |
878 | ||
879 | sh->value = (long) SYMBOL_TYPE (s); | |
880 | break; | |
881 | ||
882 | /* Beginning of code for structure, union, and enum definitions. | |
817bc7b8 | 883 | They all share a common set of local variables, defined here. */ |
5f7b2142 ILT |
884 | { |
885 | enum type_code type_code; | |
6c2e7392 | 886 | struct sym_ext *ext_tsym; |
5f7b2142 ILT |
887 | int nfields; |
888 | long max_value; | |
889 | struct field *f; | |
890 | ||
891 | case stStruct: /* Start a block defining a struct type */ | |
892 | type_code = TYPE_CODE_STRUCT; | |
893 | goto structured_common; | |
894 | ||
895 | case stUnion: /* Start a block defining a union type */ | |
896 | type_code = TYPE_CODE_UNION; | |
897 | goto structured_common; | |
898 | ||
899 | case stEnum: /* Start a block defining an enum type */ | |
900 | type_code = TYPE_CODE_ENUM; | |
901 | goto structured_common; | |
902 | ||
903 | case stBlock: /* Either a lexical block, or some type */ | |
e7ff735c | 904 | if (sh->sc != scInfo && sh->sc != scCommon) |
5f7b2142 ILT |
905 | goto case_stBlock_code; /* Lexical block */ |
906 | ||
907 | type_code = TYPE_CODE_UNDEF; /* We have a type. */ | |
908 | ||
909 | /* Common code for handling struct, union, enum, and/or as-yet- | |
910 | unknown-type blocks of info about structured data. `type_code' | |
911 | has been set to the proper TYPE_CODE, if we know it. */ | |
912 | structured_common: | |
913 | push_parse_stack (); | |
914 | top_stack->blocktype = stBlock; | |
915 | ||
6c2e7392 | 916 | s = new_symbol (name); |
5f7b2142 ILT |
917 | SYMBOL_NAMESPACE (s) = STRUCT_NAMESPACE; |
918 | SYMBOL_CLASS (s) = LOC_TYPEDEF; | |
919 | SYMBOL_VALUE (s) = 0; | |
920 | add_symbol (s, top_stack->cur_block); | |
921 | ||
922 | /* First count the number of fields and the highest value. */ | |
923 | nfields = 0; | |
924 | max_value = 0; | |
6c2e7392 | 925 | for (ext_tsym = ext_sh + 1; ; ext_tsym++) |
5f7b2142 | 926 | { |
6c2e7392 PS |
927 | SYMR tsym; |
928 | ||
929 | ecoff_swap_sym_in (cur_bfd, ext_tsym, &tsym); | |
930 | ||
1c8961dd | 931 | switch (tsym.st) |
5f7b2142 | 932 | { |
1c8961dd JK |
933 | case stEnd: |
934 | goto end_of_fields; | |
935 | ||
936 | case stMember: | |
5f7b2142 ILT |
937 | if (nfields == 0 && type_code == TYPE_CODE_UNDEF) |
938 | /* If the type of the member is Nil (or Void), | |
939 | without qualifiers, assume the tag is an | |
940 | enumeration. */ | |
6c2e7392 | 941 | if (tsym.index == indexNil) |
5f7b2142 ILT |
942 | type_code = TYPE_CODE_ENUM; |
943 | else | |
944 | { | |
945 | ecoff_swap_tir_in (bigend, | |
6c2e7392 | 946 | &ax[tsym.index].a_ti, |
5f7b2142 ILT |
947 | &tir); |
948 | if ((tir.bt == btNil || tir.bt == btVoid) | |
949 | && tir.tq0 == tqNil) | |
950 | type_code = TYPE_CODE_ENUM; | |
817bc7b8 | 951 | } |
5f7b2142 | 952 | nfields++; |
6c2e7392 PS |
953 | if (tsym.value > max_value) |
954 | max_value = tsym.value; | |
1c8961dd JK |
955 | break; |
956 | ||
38bbfd37 JK |
957 | #if 0 |
958 | /* This does not fix the bug which it intended to fix, | |
959 | and makes GDB hang when reading its own symbol table on | |
960 | the SGI, when compiled with the SGI compiler. */ | |
1c8961dd JK |
961 | case stTypedef: |
962 | case stConstant: | |
963 | case stStaticProc: | |
964 | complain (&block_member_complaint, tsym.st); | |
965 | /* These are said to show up in cfront-generated programs. | |
966 | Apparently processing them like the following prevents | |
967 | core dumps. */ | |
968 | /* FALLTHROUGH */ | |
38bbfd37 | 969 | #endif |
1c8961dd JK |
970 | |
971 | case stBlock: | |
972 | case stUnion: | |
973 | case stEnum: | |
974 | case stStruct: | |
975 | case stParsed: | |
976 | { | |
977 | #if 0 | |
978 | /* This is a no-op; is it trying to tell us something | |
979 | we should be checking? */ | |
980 | if (tsym.sc == scVariant); /*UNIMPLEMENTED*/ | |
981 | #endif | |
982 | if (tsym.index != 0) | |
983 | { | |
984 | /* This is something like a struct within a | |
985 | struct. Skip over the fields of the inner | |
986 | struct. The -1 is because the for loop will | |
987 | increment ext_tsym. */ | |
988 | ext_tsym = (ecoff_data (cur_bfd)->external_sym | |
989 | + cur_fdr->isymBase | |
990 | + tsym.index | |
991 | - 1); | |
992 | } | |
993 | } | |
994 | break; | |
995 | ||
996 | default: | |
997 | complain (&block_member_complaint, tsym.st); | |
5f7b2142 | 998 | } |
5f7b2142 | 999 | } |
1c8961dd | 1000 | end_of_fields:; |
5f7b2142 ILT |
1001 | |
1002 | /* In an stBlock, there is no way to distinguish structs, | |
1003 | unions, and enums at this point. This is a bug in the | |
1004 | original design (that has been fixed with the recent | |
1005 | addition of the stStruct, stUnion, and stEnum symbol | |
1006 | types.) The way you can tell is if/when you see a variable | |
1007 | or field of that type. In that case the variable's type | |
1008 | (in the AUX table) says if the type is struct, union, or | |
1009 | enum, and points back to the stBlock here. So you can | |
1010 | patch the tag kind up later - but only if there actually is | |
1011 | a variable or field of that type. | |
1012 | ||
1013 | So until we know for sure, we will guess at this point. | |
1014 | The heuristic is: | |
1015 | If the first member has index==indexNil or a void type, | |
1016 | assume we have an enumeration. | |
1017 | Otherwise, if there is more than one member, and all | |
1018 | the members have offset 0, assume we have a union. | |
1019 | Otherwise, assume we have a struct. | |
1020 | ||
1021 | The heuristic could guess wrong in the case of of an | |
1022 | enumeration with no members or a union with one (or zero) | |
1023 | members, or when all except the last field of a struct have | |
1024 | width zero. These are uncommon and/or illegal situations, | |
1025 | and in any case guessing wrong probably doesn't matter | |
1026 | much. | |
1027 | ||
1028 | But if we later do find out we were wrong, we fixup the tag | |
1029 | kind. Members of an enumeration must be handled | |
1030 | differently from struct/union fields, and that is harder to | |
1031 | patch up, but luckily we shouldn't need to. (If there are | |
1032 | any enumeration members, we can tell for sure it's an enum | |
1033 | here.) */ | |
1034 | ||
1035 | if (type_code == TYPE_CODE_UNDEF) | |
1036 | if (nfields > 1 && max_value == 0) | |
1037 | type_code = TYPE_CODE_UNION; | |
1038 | else | |
1039 | type_code = TYPE_CODE_STRUCT; | |
1040 | ||
1041 | /* If this type was expected, use its partial definition */ | |
6c2e7392 PS |
1042 | pend = is_pending_symbol (cur_fdr, ext_sh); |
1043 | if (pend != (struct mips_pending *) NULL) | |
1044 | t = pend->t; | |
5f7b2142 | 1045 | else |
e7ff735c | 1046 | t = new_type (NULL); |
5f7b2142 | 1047 | |
e7ff735c JK |
1048 | TYPE_TAG_NAME (t) = obconcat (¤t_objfile->symbol_obstack, |
1049 | "", "", name); | |
5f7b2142 ILT |
1050 | TYPE_CODE (t) = type_code; |
1051 | TYPE_LENGTH (t) = sh->value; | |
1052 | TYPE_NFIELDS (t) = nfields; | |
6c2e7392 PS |
1053 | TYPE_FIELDS (t) = f = ((struct field *) |
1054 | TYPE_ALLOC (t, | |
1055 | nfields * sizeof (struct field))); | |
5f7b2142 ILT |
1056 | |
1057 | if (type_code == TYPE_CODE_ENUM) | |
1058 | { | |
1059 | /* This is a non-empty enum. */ | |
6c2e7392 | 1060 | for (ext_tsym = ext_sh + 1; ; ext_tsym++) |
5f7b2142 | 1061 | { |
6c2e7392 | 1062 | SYMR tsym; |
5f7b2142 | 1063 | struct symbol *enum_sym; |
6c2e7392 PS |
1064 | |
1065 | ecoff_swap_sym_in (cur_bfd, ext_tsym, &tsym); | |
1066 | ||
1067 | if (tsym.st != stMember) | |
1068 | break; | |
1069 | ||
1070 | f->bitpos = tsym.value; | |
5f7b2142 | 1071 | f->type = t; |
6c2e7392 PS |
1072 | f->name = (ecoff_data (cur_bfd)->ss |
1073 | + cur_fdr->issBase | |
1074 | + tsym.iss); | |
5f7b2142 ILT |
1075 | f->bitsize = 0; |
1076 | ||
1077 | enum_sym = ((struct symbol *) | |
817bc7b8 | 1078 | obstack_alloc (¤t_objfile->symbol_obstack, |
5f7b2142 ILT |
1079 | sizeof (struct symbol))); |
1080 | memset ((PTR) enum_sym, 0, sizeof (struct symbol)); | |
1081 | SYMBOL_NAME (enum_sym) = f->name; | |
1082 | SYMBOL_CLASS (enum_sym) = LOC_CONST; | |
1083 | SYMBOL_TYPE (enum_sym) = t; | |
1084 | SYMBOL_NAMESPACE (enum_sym) = VAR_NAMESPACE; | |
6c2e7392 | 1085 | SYMBOL_VALUE (enum_sym) = tsym.value; |
5f7b2142 ILT |
1086 | add_symbol (enum_sym, top_stack->cur_block); |
1087 | ||
1088 | /* Skip the stMembers that we've handled. */ | |
1089 | count++; | |
1090 | f++; | |
1091 | } | |
1092 | } | |
1093 | SYMBOL_TYPE (s) = t; | |
1094 | /* make this the current type */ | |
1095 | top_stack->cur_type = t; | |
1096 | top_stack->cur_field = 0; | |
1097 | /* Mark that symbol has a type, and say which one */ | |
1098 | sh->value = (long) t; | |
1099 | break; | |
1100 | ||
1101 | /* End of local variables shared by struct, union, enum, and | |
1102 | block (as yet unknown struct/union/enum) processing. */ | |
1103 | } | |
817bc7b8 | 1104 | |
5f7b2142 ILT |
1105 | case_stBlock_code: |
1106 | /* beginnning of (code) block. Value of symbol | |
1107 | is the displacement from procedure start */ | |
1108 | push_parse_stack (); | |
1109 | top_stack->blocktype = stBlock; | |
1110 | b = new_block (top_stack->maxsyms); | |
1111 | BLOCK_START (b) = sh->value + top_stack->procadr; | |
1112 | BLOCK_SUPERBLOCK (b) = top_stack->cur_block; | |
1113 | top_stack->cur_block = b; | |
1114 | add_block (b, top_stack->cur_st); | |
1115 | break; | |
1116 | ||
1117 | case stEnd: /* end (of anything) */ | |
e7ff735c | 1118 | if (sh->sc == scInfo || sh->sc == scCommon) |
5f7b2142 ILT |
1119 | { |
1120 | /* Finished with type */ | |
1121 | top_stack->cur_type = 0; | |
1122 | } | |
6c2e7392 PS |
1123 | else if (sh->sc == scText && |
1124 | (top_stack->blocktype == stProc || | |
1125 | top_stack->blocktype == stStaticProc)) | |
5f7b2142 ILT |
1126 | { |
1127 | /* Finished with procedure */ | |
1128 | struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); | |
1129 | struct mips_extra_func_info *e; | |
1130 | struct block *b; | |
1131 | int i; | |
1132 | ||
1133 | BLOCK_END (top_stack->cur_block) += sh->value; /* size */ | |
1134 | ||
1135 | /* Make up special symbol to contain procedure specific info */ | |
1136 | s = new_symbol (MIPS_EFI_SYMBOL_NAME); | |
1137 | SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; | |
1138 | SYMBOL_CLASS (s) = LOC_CONST; | |
1139 | SYMBOL_TYPE (s) = builtin_type_void; | |
1140 | e = ((struct mips_extra_func_info *) | |
1141 | obstack_alloc (¤t_objfile->symbol_obstack, | |
1142 | sizeof (struct mips_extra_func_info))); | |
1143 | SYMBOL_VALUE (s) = (int) e; | |
1144 | e->numargs = top_stack->numargs; | |
1145 | add_symbol (s, top_stack->cur_block); | |
1146 | ||
1147 | /* Reallocate symbols, saving memory */ | |
1148 | b = shrink_block (top_stack->cur_block, top_stack->cur_st); | |
1149 | ||
1150 | /* f77 emits proc-level with address bounds==[0,0], | |
6c2e7392 | 1151 | So look for such child blocks, and patch them. */ |
5f7b2142 ILT |
1152 | for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++) |
1153 | { | |
1154 | struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i); | |
1155 | if (BLOCK_SUPERBLOCK (b_bad) == b | |
1156 | && BLOCK_START (b_bad) == top_stack->procadr | |
1157 | && BLOCK_END (b_bad) == top_stack->procadr) | |
1158 | { | |
1159 | BLOCK_START (b_bad) = BLOCK_START (b); | |
1160 | BLOCK_END (b_bad) = BLOCK_END (b); | |
1161 | } | |
1162 | } | |
1163 | } | |
1164 | else if (sh->sc == scText && top_stack->blocktype == stBlock) | |
1165 | { | |
6c2e7392 PS |
1166 | /* End of (code) block. The value of the symbol is the |
1167 | displacement from the procedure`s start address of the | |
1168 | end of this block. */ | |
5f7b2142 ILT |
1169 | BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr; |
1170 | shrink_block (top_stack->cur_block, top_stack->cur_st); | |
1171 | } | |
1172 | else if (sh->sc == scText && top_stack->blocktype == stFile) | |
1173 | { | |
1174 | /* End of file. Pop parse stack and ignore. Higher | |
6c2e7392 | 1175 | level code deals with this. */ |
5f7b2142 | 1176 | ; |
bd5635a1 | 1177 | } |
5f7b2142 ILT |
1178 | else |
1179 | complain (&stEnd_complaint, sh->sc); | |
1180 | ||
1181 | pop_parse_stack (); /* restore previous lexical context */ | |
1182 | break; | |
1183 | ||
1184 | case stMember: /* member of struct or union */ | |
1185 | f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++]; | |
6c2e7392 | 1186 | f->name = name; |
5f7b2142 ILT |
1187 | f->bitpos = sh->value; |
1188 | f->bitsize = 0; | |
1189 | f->type = parse_type (ax + sh->index, &f->bitsize, bigend); | |
1190 | break; | |
1191 | ||
1192 | case stTypedef: /* type definition */ | |
6c2e7392 | 1193 | s = new_symbol (name); |
5f7b2142 ILT |
1194 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; |
1195 | SYMBOL_CLASS (s) = LOC_TYPEDEF; | |
1196 | SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block; | |
1197 | add_symbol (s, top_stack->cur_block); | |
1198 | SYMBOL_TYPE (s) = parse_type (ax + sh->index, 0, bigend); | |
1199 | sh->value = (long) SYMBOL_TYPE (s); | |
1200 | break; | |
1201 | ||
1202 | case stFile: /* file name */ | |
1203 | push_parse_stack (); | |
1204 | top_stack->blocktype = sh->st; | |
1205 | break; | |
1206 | ||
1207 | /* I`ve never seen these for C */ | |
1208 | case stRegReloc: | |
1209 | break; /* register relocation */ | |
1210 | case stForward: | |
1211 | break; /* forwarding address */ | |
1212 | case stConstant: | |
1213 | break; /* constant */ | |
1214 | default: | |
1215 | complain (&unknown_mips_symtype_complaint, sh->st); | |
1216 | break; | |
1217 | } | |
6c2e7392 | 1218 | |
5f7b2142 | 1219 | sh->st = stParsed; |
6c2e7392 | 1220 | |
5f7b2142 | 1221 | return count; |
bd5635a1 RP |
1222 | } |
1223 | ||
d747e0af MT |
1224 | /* Parse the type information provided in the raw AX entries for |
1225 | the symbol SH. Return the bitfield size in BS, in case. | |
1226 | We must byte-swap the AX entries before we use them; BIGEND says whether | |
1227 | they are big-endian or little-endian (from fh->fBigendian). */ | |
bd5635a1 | 1228 | |
84ffdec2 | 1229 | static struct type * |
5f7b2142 ILT |
1230 | parse_type (ax, bs, bigend) |
1231 | union aux_ext *ax; | |
1232 | int *bs; | |
1233 | int bigend; | |
bd5635a1 | 1234 | { |
5f7b2142 ILT |
1235 | /* Null entries in this map are treated specially */ |
1236 | static struct type **map_bt[] = | |
1237 | { | |
1238 | &builtin_type_void, /* btNil */ | |
1239 | 0, /* btAdr */ | |
1240 | &builtin_type_char, /* btChar */ | |
1241 | &builtin_type_unsigned_char,/* btUChar */ | |
1242 | &builtin_type_short, /* btShort */ | |
1243 | &builtin_type_unsigned_short, /* btUShort */ | |
1244 | &builtin_type_int, /* btInt */ | |
1245 | &builtin_type_unsigned_int, /* btUInt */ | |
1246 | &builtin_type_long, /* btLong */ | |
1247 | &builtin_type_unsigned_long,/* btULong */ | |
1248 | &builtin_type_float, /* btFloat */ | |
1249 | &builtin_type_double, /* btDouble */ | |
1250 | 0, /* btStruct */ | |
1251 | 0, /* btUnion */ | |
1252 | 0, /* btEnum */ | |
1253 | 0, /* btTypedef */ | |
1254 | 0, /* btRange */ | |
1255 | 0, /* btSet */ | |
1256 | &builtin_type_complex, /* btComplex */ | |
1257 | &builtin_type_double_complex, /* btDComplex */ | |
1258 | 0, /* btIndirect */ | |
1259 | &builtin_type_fixed_dec, /* btFixedDec */ | |
1260 | &builtin_type_float_dec, /* btFloatDec */ | |
1261 | &builtin_type_string, /* btString */ | |
1262 | 0, /* btBit */ | |
1263 | 0, /* btPicture */ | |
1264 | &builtin_type_void, /* btVoid */ | |
1265 | &builtin_type_long_long, /* btLongLong */ | |
1266 | &builtin_type_unsigned_long_long, /* btULongLong */ | |
1267 | }; | |
1268 | ||
1269 | TIR t[1]; | |
1270 | struct type *tp = 0; | |
1271 | char *fmt; | |
1272 | union aux_ext *tax; | |
6c2e7392 | 1273 | enum type_code type_code = TYPE_CODE_UNDEF; |
5f7b2142 ILT |
1274 | |
1275 | /* Use aux as a type information record, map its basic type. */ | |
1276 | tax = ax; | |
1277 | ecoff_swap_tir_in (bigend, &tax->a_ti, t); | |
1278 | if (t->bt > (sizeof (map_bt) / sizeof (*map_bt))) | |
1279 | { | |
1280 | complain (&basic_type_complaint, t->bt); | |
1281 | return builtin_type_int; | |
1282 | } | |
1283 | if (map_bt[t->bt]) | |
1284 | { | |
1285 | tp = *map_bt[t->bt]; | |
5f7b2142 ILT |
1286 | } |
1287 | else | |
1288 | { | |
1289 | tp = NULL; | |
1290 | /* Cannot use builtin types -- build our own */ | |
1291 | switch (t->bt) | |
bd5635a1 | 1292 | { |
5f7b2142 ILT |
1293 | case btAdr: |
1294 | tp = lookup_pointer_type (builtin_type_void); | |
5f7b2142 ILT |
1295 | break; |
1296 | case btStruct: | |
1297 | type_code = TYPE_CODE_STRUCT; | |
5f7b2142 ILT |
1298 | break; |
1299 | case btUnion: | |
1300 | type_code = TYPE_CODE_UNION; | |
5f7b2142 ILT |
1301 | break; |
1302 | case btEnum: | |
1303 | type_code = TYPE_CODE_ENUM; | |
5f7b2142 ILT |
1304 | break; |
1305 | case btRange: | |
1306 | type_code = TYPE_CODE_RANGE; | |
5f7b2142 ILT |
1307 | break; |
1308 | case btSet: | |
1309 | type_code = TYPE_CODE_SET; | |
5f7b2142 ILT |
1310 | break; |
1311 | case btTypedef: | |
1312 | default: | |
1313 | complain (&basic_type_complaint, t->bt); | |
1314 | return builtin_type_int; | |
bd5635a1 | 1315 | } |
5f7b2142 | 1316 | } |
bd5635a1 | 1317 | |
5f7b2142 ILT |
1318 | /* Skip over any further type qualifiers (FIXME). */ |
1319 | if (t->continued) | |
1320 | { | |
1321 | /* This is the way it would work if the compiler worked */ | |
1322 | TIR t1[1]; | |
1323 | do | |
1324 | { | |
1325 | ax++; | |
6c2e7392 | 1326 | ecoff_swap_tir_in (bigend, &ax->a_ti, t1); |
bd5635a1 | 1327 | } |
5f7b2142 ILT |
1328 | while (t1->continued); |
1329 | } | |
bd5635a1 | 1330 | |
5f7b2142 ILT |
1331 | /* Move on to next aux */ |
1332 | ax++; | |
d747e0af | 1333 | |
5f7b2142 ILT |
1334 | if (t->fBitfield) |
1335 | { | |
1336 | *bs = AUX_GET_WIDTH (bigend, ax); | |
1337 | ax++; | |
1338 | } | |
bd5635a1 | 1339 | |
5f7b2142 ILT |
1340 | /* All these types really point to some (common) MIPS type |
1341 | definition, and only the type-qualifiers fully identify | |
1342 | them. We'll make the same effort at sharing. */ | |
e7ff735c | 1343 | if (t->bt == btStruct || |
5f7b2142 ILT |
1344 | t->bt == btUnion || |
1345 | t->bt == btEnum || | |
e7ff735c JK |
1346 | |
1347 | /* btSet (I think) implies that the name is a tag name, not a typedef | |
1348 | name. This apparently is a MIPS extension for C sets. */ | |
5f7b2142 ILT |
1349 | t->bt == btSet) |
1350 | { | |
e7ff735c JK |
1351 | char *name; |
1352 | ||
1353 | /* Try to cross reference this type */ | |
1354 | ax += cross_ref (ax, &tp, type_code, &name, bigend); | |
1355 | /* reading .o file ? */ | |
1356 | if (tp == (struct type *) NULL) | |
1357 | tp = init_type (type_code, 0, 0, (char *) NULL, | |
1358 | (struct objfile *) NULL); | |
1359 | ||
1360 | /* Usually, TYPE_CODE(tp) is already type_code. The main | |
1361 | exception is if we guessed wrong re struct/union/enum. */ | |
1362 | if (TYPE_CODE (tp) != type_code) | |
1363 | { | |
1364 | complain (&bad_tag_guess_complaint, name); | |
1365 | TYPE_CODE (tp) = type_code; | |
1366 | } | |
b31ca3de PS |
1367 | /* Do not set the tag name if it is a compiler generated tag name |
1368 | (.Fxx or .xxfake) for unnamed struct/union/enums. */ | |
1369 | if (name[0] == '.') | |
1370 | TYPE_TAG_NAME (tp) = NULL; | |
1371 | else if (TYPE_TAG_NAME (tp) == NULL || !STREQ (TYPE_TAG_NAME (tp), name)) | |
e7ff735c JK |
1372 | TYPE_TAG_NAME (tp) = obsavestring (name, strlen (name), |
1373 | ¤t_objfile->type_obstack); | |
1374 | } | |
1375 | ||
1376 | /* All these types really point to some (common) MIPS type | |
1377 | definition, and only the type-qualifiers fully identify | |
1378 | them. We'll make the same effort at sharing. */ | |
1379 | if (t->bt == btIndirect || | |
1380 | t->bt == btRange) | |
1381 | { | |
1382 | char *name; | |
5f7b2142 ILT |
1383 | |
1384 | /* Try to cross reference this type */ | |
e7ff735c | 1385 | ax += cross_ref (ax, &tp, type_code, &name, bigend); |
5f7b2142 | 1386 | /* reading .o file ? */ |
6c2e7392 | 1387 | if (tp == (struct type *) NULL) |
5f7b2142 ILT |
1388 | tp = init_type (type_code, 0, 0, (char *) NULL, |
1389 | (struct objfile *) NULL); | |
5f7b2142 ILT |
1390 | |
1391 | /* Usually, TYPE_CODE(tp) is already type_code. The main | |
1392 | exception is if we guessed wrong re struct/union/enum. */ | |
1393 | if (TYPE_CODE (tp) != type_code) | |
1394 | { | |
1395 | complain (&bad_tag_guess_complaint, name); | |
1396 | TYPE_CODE (tp) = type_code; | |
bd5635a1 | 1397 | } |
5f7b2142 ILT |
1398 | if (TYPE_NAME (tp) == NULL || !STREQ (TYPE_NAME (tp), name)) |
1399 | TYPE_NAME (tp) = obsavestring (name, strlen (name), | |
1400 | ¤t_objfile->type_obstack); | |
1401 | } | |
bd5635a1 | 1402 | |
5f7b2142 ILT |
1403 | /* Deal with range types */ |
1404 | if (t->bt == btRange) | |
1405 | { | |
1406 | TYPE_NFIELDS (tp) = 2; | |
1407 | TYPE_FIELDS (tp) = ((struct field *) | |
1408 | TYPE_ALLOC (tp, 2 * sizeof (struct field))); | |
1409 | TYPE_FIELD_NAME (tp, 0) = obsavestring ("Low", strlen ("Low"), | |
1410 | ¤t_objfile->type_obstack); | |
1411 | TYPE_FIELD_BITPOS (tp, 0) = AUX_GET_DNLOW (bigend, ax); | |
1412 | ax++; | |
1413 | TYPE_FIELD_NAME (tp, 1) = obsavestring ("High", strlen ("High"), | |
1414 | ¤t_objfile->type_obstack); | |
1415 | TYPE_FIELD_BITPOS (tp, 1) = AUX_GET_DNHIGH (bigend, ax); | |
1416 | ax++; | |
1417 | } | |
bd5635a1 | 1418 | |
5f7b2142 | 1419 | /* Parse all the type qualifiers now. If there are more |
6c2e7392 | 1420 | than 6 the game will continue in the next aux */ |
bd5635a1 RP |
1421 | |
1422 | #define PARSE_TQ(tq) \ | |
d747e0af | 1423 | if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend); |
bd5635a1 | 1424 | |
5f7b2142 ILT |
1425 | again:PARSE_TQ (tq0); |
1426 | PARSE_TQ (tq1); | |
1427 | PARSE_TQ (tq2); | |
1428 | PARSE_TQ (tq3); | |
1429 | PARSE_TQ (tq4); | |
1430 | PARSE_TQ (tq5); | |
bd5635a1 RP |
1431 | #undef PARSE_TQ |
1432 | ||
5f7b2142 ILT |
1433 | if (t->continued) |
1434 | { | |
1435 | tax++; | |
1436 | ecoff_swap_tir_in (bigend, &tax->a_ti, t); | |
1437 | goto again; | |
1438 | } | |
1439 | return tp; | |
bd5635a1 RP |
1440 | } |
1441 | ||
1442 | /* Make up a complex type from a basic one. Type is passed by | |
1443 | reference in TPP and side-effected as necessary. The type | |
1444 | qualifier TQ says how to handle the aux symbols at AX for | |
d747e0af MT |
1445 | the symbol SX we are currently analyzing. BIGEND says whether |
1446 | aux symbols are big-endian or little-endian. | |
bd5635a1 RP |
1447 | Returns the number of aux symbols we parsed. */ |
1448 | ||
3eaebb75 | 1449 | static int |
5f7b2142 ILT |
1450 | upgrade_type (tpp, tq, ax, bigend) |
1451 | struct type **tpp; | |
1452 | int tq; | |
1453 | union aux_ext *ax; | |
1454 | int bigend; | |
bd5635a1 | 1455 | { |
5f7b2142 ILT |
1456 | int off; |
1457 | struct type *t; | |
1458 | ||
1459 | /* Used in array processing */ | |
1460 | int rf, id; | |
1461 | FDR *fh; | |
1462 | struct type *range; | |
1463 | struct type *indx; | |
1464 | int lower, upper; | |
1465 | RNDXR rndx; | |
1466 | ||
1467 | switch (tq) | |
1468 | { | |
1469 | case tqPtr: | |
1470 | t = lookup_pointer_type (*tpp); | |
1471 | *tpp = t; | |
1472 | return 0; | |
1473 | ||
1474 | case tqProc: | |
1475 | t = lookup_function_type (*tpp); | |
1476 | *tpp = t; | |
1477 | return 0; | |
1478 | ||
1479 | case tqArray: | |
1480 | off = 0; | |
1481 | ||
1482 | /* Determine and record the domain type (type of index) */ | |
6c2e7392 | 1483 | ecoff_swap_rndx_in (bigend, &ax->a_rndx, &rndx); |
5f7b2142 ILT |
1484 | id = rndx.index; |
1485 | rf = rndx.rfd; | |
1486 | if (rf == 0xfff) | |
1487 | { | |
1488 | ax++; | |
1489 | rf = AUX_GET_ISYM (bigend, ax); | |
1490 | off++; | |
1491 | } | |
1492 | fh = get_rfd (cur_fd, rf); | |
1493 | ||
6c2e7392 PS |
1494 | indx = parse_type ((ecoff_data (cur_bfd)->external_aux |
1495 | + fh->iauxBase | |
1496 | + id), | |
5f7b2142 ILT |
1497 | (int *) NULL, bigend); |
1498 | ||
1499 | /* Get the bounds, and create the array type. */ | |
1500 | ax++; | |
1501 | lower = AUX_GET_DNLOW (bigend, ax); | |
1502 | ax++; | |
1503 | upper = AUX_GET_DNHIGH (bigend, ax); | |
1504 | ax++; | |
1505 | rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */ | |
1506 | ||
1507 | range = create_range_type ((struct type *) NULL, indx, | |
1508 | lower, upper); | |
1509 | ||
1510 | t = create_array_type ((struct type *) NULL, *tpp, range); | |
1511 | ||
1512 | /* Check whether supplied array element bit size matches | |
1513 | the known size of the element type. If this complaint | |
1514 | ends up not happening, we can remove this code. It's | |
1515 | here because we aren't sure we understand this *&%&$ | |
1516 | symbol format. */ | |
1517 | id = TYPE_LENGTH (TYPE_TARGET_TYPE (t)) << 3; /* bitsize */ | |
1518 | if (id == 0) | |
1519 | { | |
1520 | /* Most likely an undefined type */ | |
1521 | id = rf; | |
1522 | TYPE_LENGTH (TYPE_TARGET_TYPE (t)) = id >> 3; | |
1523 | } | |
1524 | if (id != rf) | |
1525 | complain (&array_bitsize_complaint, rf); | |
3eaebb75 | 1526 | |
5f7b2142 ILT |
1527 | *tpp = t; |
1528 | return 4 + off; | |
bd5635a1 | 1529 | |
5f7b2142 ILT |
1530 | case tqVol: |
1531 | /* Volatile -- currently ignored */ | |
1532 | return 0; | |
3eaebb75 | 1533 | |
5f7b2142 ILT |
1534 | case tqConst: |
1535 | /* Const -- currently ignored */ | |
1536 | return 0; | |
817bc7b8 | 1537 | |
5f7b2142 ILT |
1538 | default: |
1539 | complain (&unknown_type_qual_complaint, tq); | |
1540 | return 0; | |
1541 | } | |
bd5635a1 RP |
1542 | } |
1543 | ||
1544 | ||
6c2e7392 PS |
1545 | /* Parse a procedure descriptor record PR. Note that the procedure is |
1546 | parsed _after_ the local symbols, now we just insert the extra | |
1547 | information we need into a MIPS_EFI_SYMBOL_NAME symbol that has | |
1548 | already been placed in the procedure's main block. Note also that | |
1549 | images that have been partially stripped (ld -x) have been deprived | |
1550 | of local symbols, and we have to cope with them here. FIRST_OFF is | |
1551 | the offset of the first procedure for this FDR; we adjust the | |
b5d4d6d7 JK |
1552 | address by this amount, but I don't know why. SEARCH_SYMTAB is the symtab |
1553 | to look for the function which contains the MIPS_EFI_SYMBOL_NAME symbol | |
1554 | in question, or NULL to use top_stack->cur_block. */ | |
9adb88b7 | 1555 | |
b5d4d6d7 | 1556 | static void parse_procedure PARAMS ((PDR *, struct symtab *, unsigned long)); |
bd5635a1 | 1557 | |
d1bb1d41 | 1558 | static void |
b5d4d6d7 | 1559 | parse_procedure (pr, search_symtab, first_off) |
5f7b2142 | 1560 | PDR *pr; |
b5d4d6d7 | 1561 | struct symtab *search_symtab; |
6c2e7392 | 1562 | unsigned long first_off; |
bd5635a1 | 1563 | { |
b5d4d6d7 | 1564 | struct symbol *s, *i; |
5f7b2142 ILT |
1565 | struct block *b; |
1566 | struct mips_extra_func_info *e; | |
1567 | char *sh_name; | |
1568 | ||
6c2e7392 PS |
1569 | /* Simple rule to find files linked "-x" */ |
1570 | if (cur_fdr->rss == -1) | |
5f7b2142 | 1571 | { |
6c2e7392 PS |
1572 | if (pr->isym == -1) |
1573 | { | |
1574 | /* Static procedure at address pr->adr. Sigh. */ | |
1575 | complain (&pdr_static_symbol_complaint, pr->adr); | |
1576 | return; | |
1577 | } | |
1578 | else | |
1579 | { | |
1580 | /* external */ | |
1581 | EXTR she; | |
1582 | ||
1583 | ecoff_swap_ext_in (cur_bfd, | |
1584 | ecoff_data (cur_bfd)->external_ext + pr->isym, | |
1585 | &she); | |
1586 | sh_name = ecoff_data (cur_bfd)->ssext + she.asym.iss; | |
1587 | } | |
5f7b2142 | 1588 | } |
6c2e7392 PS |
1589 | else |
1590 | { | |
1591 | /* Full symbols */ | |
1592 | SYMR sh; | |
1593 | ||
1594 | ecoff_swap_sym_in (cur_bfd, | |
1595 | (ecoff_data (cur_bfd)->external_sym | |
1596 | + cur_fdr->isymBase | |
1597 | + pr->isym), | |
1598 | &sh); | |
1599 | sh_name = ecoff_data (cur_bfd)->ss + cur_fdr->issBase + sh.iss; | |
1600 | } | |
1601 | ||
b5d4d6d7 | 1602 | if (search_symtab != NULL) |
6c2e7392 | 1603 | { |
b5d4d6d7 JK |
1604 | #if 0 |
1605 | /* This loses both in the case mentioned (want a static, find a global), | |
1606 | but also if we are looking up a non-mangled name which happens to | |
1607 | match the name of a mangled function. */ | |
1608 | /* We have to save the cur_fdr across the call to lookup_symbol. | |
1609 | If the pdr is for a static function and if a global function with | |
1610 | the same name exists, lookup_symbol will eventually read in the symtab | |
1611 | for the global function and clobber cur_fdr. */ | |
1612 | FDR *save_cur_fdr = cur_fdr; | |
1613 | s = lookup_symbol (sh_name, NULL, VAR_NAMESPACE, 0, NULL); | |
1614 | cur_fdr = save_cur_fdr; | |
1615 | #else | |
1616 | s = mylookup_symbol | |
1617 | (sh_name, | |
1618 | BLOCKVECTOR_BLOCK (BLOCKVECTOR (search_symtab), STATIC_BLOCK), | |
1619 | VAR_NAMESPACE, | |
1620 | LOC_BLOCK); | |
1621 | #endif | |
1622 | } | |
1623 | else | |
1624 | s = mylookup_symbol (sh_name, top_stack->cur_block, | |
1625 | VAR_NAMESPACE, LOC_BLOCK); | |
9adb88b7 | 1626 | |
b5d4d6d7 JK |
1627 | if (s != 0) |
1628 | { | |
1629 | b = SYMBOL_BLOCK_VALUE (s); | |
1630 | } | |
1631 | else | |
1632 | { | |
1633 | complain (&pdr_for_nonsymbol_complaint, sh_name); | |
b303297a | 1634 | #if 1 |
b5d4d6d7 | 1635 | return; |
dac4929a | 1636 | #else |
817bc7b8 | 1637 | /* FIXME -- delete. We can't do symbol allocation now; it's all done. */ |
b5d4d6d7 JK |
1638 | s = new_symbol (sh_name); |
1639 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; | |
1640 | SYMBOL_CLASS (s) = LOC_BLOCK; | |
1641 | /* Donno its type, hope int is ok */ | |
1642 | SYMBOL_TYPE (s) = lookup_function_type (builtin_type_int); | |
1643 | add_symbol (s, top_stack->cur_block); | |
1644 | /* Wont have symbols for this one */ | |
1645 | b = new_block (2); | |
1646 | SYMBOL_BLOCK_VALUE (s) = b; | |
1647 | BLOCK_FUNCTION (b) = s; | |
1648 | BLOCK_START (b) = pr->adr; | |
1649 | /* BOUND used to be the end of procedure's text, but the | |
1650 | argument is no longer passed in. */ | |
1651 | BLOCK_END (b) = bound; | |
1652 | BLOCK_SUPERBLOCK (b) = top_stack->cur_block; | |
1653 | add_block (b, top_stack->cur_st); | |
817bc7b8 | 1654 | #endif |
9adb88b7 | 1655 | } |
d1bb1d41 | 1656 | |
b5d4d6d7 JK |
1657 | i = mylookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE, LOC_CONST); |
1658 | ||
1659 | if (i) | |
5f7b2142 | 1660 | { |
b5d4d6d7 | 1661 | e = (struct mips_extra_func_info *) SYMBOL_VALUE (i); |
5f7b2142 ILT |
1662 | e->pdr = *pr; |
1663 | e->pdr.isym = (long) s; | |
6c2e7392 | 1664 | e->pdr.adr += cur_fdr->adr - first_off; |
e157305c PS |
1665 | |
1666 | /* Correct incorrect setjmp procedure descriptor from the library | |
1667 | to make backtrace through setjmp work. */ | |
1668 | if (e->pdr.pcreg == 0 && strcmp (sh_name, "setjmp") == 0) | |
1669 | { | |
1670 | complain (&bad_setjmp_pdr_complaint, 0); | |
1671 | e->pdr.pcreg = RA_REGNUM; | |
1672 | e->pdr.regmask = 0x80000000; | |
1673 | e->pdr.regoffset = -4; | |
1674 | } | |
5f7b2142 | 1675 | } |
bd5635a1 RP |
1676 | } |
1677 | ||
1678 | /* Parse the external symbol ES. Just call parse_symbol() after | |
1679 | making sure we know where the aux are for it. For procedures, | |
1680 | parsing of the PDRs has already provided all the needed | |
1681 | information, we only parse them if SKIP_PROCEDURES is false, | |
101f259c | 1682 | and only if this causes no symbol duplication. |
d747e0af | 1683 | BIGEND says whether aux entries are big-endian or little-endian. |
101f259c JG |
1684 | |
1685 | This routine clobbers top_stack->cur_block and ->cur_st. */ | |
bd5635a1 | 1686 | |
4ad1963e | 1687 | static void |
5f7b2142 ILT |
1688 | parse_external (es, skip_procedures, bigend) |
1689 | EXTR *es; | |
1690 | int skip_procedures; | |
1691 | int bigend; | |
bd5635a1 | 1692 | { |
5f7b2142 | 1693 | union aux_ext *ax; |
bd5635a1 | 1694 | |
5f7b2142 ILT |
1695 | if (es->ifd != ifdNil) |
1696 | { | |
1697 | cur_fd = es->ifd; | |
6c2e7392 PS |
1698 | cur_fdr = ecoff_data (cur_bfd)->fdr + cur_fd; |
1699 | ax = ecoff_data (cur_bfd)->external_aux + cur_fdr->iauxBase; | |
5f7b2142 ILT |
1700 | } |
1701 | else | |
1702 | { | |
6c2e7392 | 1703 | cur_fdr = ecoff_data (cur_bfd)->fdr; |
5f7b2142 ILT |
1704 | ax = 0; |
1705 | } | |
bd5635a1 | 1706 | |
5f7b2142 ILT |
1707 | /* Reading .o files */ |
1708 | if (es->asym.sc == scUndefined || es->asym.sc == scNil) | |
1709 | { | |
1710 | char *what; | |
1711 | switch (es->asym.st) | |
1712 | { | |
1713 | case stStaticProc: | |
bd5635a1 | 1714 | case stProc: |
5f7b2142 ILT |
1715 | what = "procedure"; |
1716 | n_undef_procs++; | |
1717 | break; | |
bd5635a1 | 1718 | case stGlobal: |
5f7b2142 ILT |
1719 | what = "variable"; |
1720 | n_undef_vars++; | |
1721 | break; | |
bd5635a1 | 1722 | case stLabel: |
5f7b2142 ILT |
1723 | what = "label"; |
1724 | n_undef_labels++; | |
1725 | break; | |
1726 | default: | |
1727 | what = "symbol"; | |
1728 | break; | |
1729 | } | |
1730 | n_undef_symbols++; | |
1731 | /* FIXME: Turn this into a complaint? */ | |
1732 | if (info_verbose) | |
1733 | printf_filtered ("Warning: %s `%s' is undefined (in %s)\n", | |
6c2e7392 PS |
1734 | what, |
1735 | ecoff_data (cur_bfd)->ssext + es->asym.iss, | |
1736 | fdr_name (cur_fdr)); | |
5f7b2142 ILT |
1737 | return; |
1738 | } | |
1739 | ||
1740 | switch (es->asym.st) | |
1741 | { | |
1742 | case stProc: | |
1743 | /* If we have full symbols we do not need more */ | |
1744 | if (skip_procedures) | |
1745 | return; | |
6c2e7392 PS |
1746 | if (mylookup_symbol (ecoff_data (cur_bfd)->ssext + es->asym.iss, |
1747 | top_stack->cur_block, | |
5f7b2142 ILT |
1748 | VAR_NAMESPACE, LOC_BLOCK)) |
1749 | break; | |
1750 | /* fall through */ | |
1751 | case stGlobal: | |
1752 | case stLabel: | |
6c2e7392 PS |
1753 | /* Note that the case of a symbol with indexNil must be handled |
1754 | anyways by parse_symbol(). */ | |
1755 | parse_symbol (&es->asym, ax, (struct sym_ext *) NULL, bigend); | |
1756 | /* Note that parse_symbol changed es->asym. */ | |
5f7b2142 ILT |
1757 | break; |
1758 | default: | |
1759 | break; | |
1760 | } | |
bd5635a1 RP |
1761 | } |
1762 | ||
1763 | /* Parse the line number info for file descriptor FH into | |
1764 | GDB's linetable LT. MIPS' encoding requires a little bit | |
1765 | of magic to get things out. Note also that MIPS' line | |
1766 | numbers can go back and forth, apparently we can live | |
1767 | with that and do not need to reorder our linetables */ | |
1768 | ||
4ad1963e | 1769 | static void |
6c2e7392 | 1770 | parse_lines (fh, pr, lt) |
5f7b2142 | 1771 | FDR *fh; |
6c2e7392 | 1772 | PDR *pr; |
5f7b2142 | 1773 | struct linetable *lt; |
bd5635a1 | 1774 | { |
6c2e7392 | 1775 | unsigned char *base; |
5f7b2142 ILT |
1776 | int j, k; |
1777 | int delta, count, lineno = 0; | |
6c2e7392 | 1778 | unsigned long first_off = pr->adr; |
5f7b2142 | 1779 | |
6c2e7392 | 1780 | if (fh->cbLineOffset == 0) |
5f7b2142 ILT |
1781 | return; |
1782 | ||
6c2e7392 PS |
1783 | base = ecoff_data (cur_bfd)->line + fh->cbLineOffset; |
1784 | ||
5f7b2142 | 1785 | /* Scan by procedure descriptors */ |
6c2e7392 PS |
1786 | k = 0; |
1787 | for (j = 0; j < fh->cpd; j++, pr++) | |
5f7b2142 ILT |
1788 | { |
1789 | int l, halt; | |
6c2e7392 | 1790 | unsigned long adr; |
5f7b2142 ILT |
1791 | |
1792 | /* No code for this one */ | |
1793 | if (pr->iline == ilineNil || | |
1794 | pr->lnLow == -1 || pr->lnHigh == -1) | |
1795 | continue; | |
6c2e7392 PS |
1796 | |
1797 | /* Aurgh! To know where to stop expanding we must look-ahead. */ | |
5f7b2142 ILT |
1798 | for (l = 1; l < (fh->cpd - j); l++) |
1799 | if (pr[l].iline != -1) | |
1800 | break; | |
1801 | if (l == (fh->cpd - j)) | |
1802 | halt = fh->cline; | |
1803 | else | |
1804 | halt = pr[l].iline; | |
6c2e7392 PS |
1805 | |
1806 | /* When procedures are moved around the linenumbers are | |
1807 | attributed to the next procedure up. */ | |
5f7b2142 ILT |
1808 | if (pr->iline >= halt) |
1809 | continue; | |
1810 | ||
6c2e7392 PS |
1811 | base = ecoff_data (cur_bfd)->line + fh->cbLineOffset + pr->cbLineOffset; |
1812 | adr = fh->adr + pr->adr - first_off; | |
1813 | l = adr >> 2; /* in words */ | |
1814 | halt += (adr >> 2) - pr->iline; | |
5f7b2142 ILT |
1815 | for (lineno = pr->lnLow; l < halt;) |
1816 | { | |
1817 | count = *base & 0x0f; | |
1818 | delta = *base++ >> 4; | |
1819 | if (delta >= 8) | |
1820 | delta -= 16; | |
1821 | if (delta == -8) | |
1822 | { | |
1823 | delta = (base[0] << 8) | base[1]; | |
1824 | if (delta >= 0x8000) | |
1825 | delta -= 0x10000; | |
1826 | base += 2; | |
1827 | } | |
1828 | lineno += delta; /* first delta is 0 */ | |
1829 | k = add_line (lt, lineno, l, k); | |
1830 | l += count + 1; | |
bd5635a1 | 1831 | } |
5f7b2142 | 1832 | } |
bd5635a1 | 1833 | } |
101f259c JG |
1834 | \f |
1835 | /* Master parsing procedure for first-pass reading of file symbols | |
6c2e7392 | 1836 | into a partial_symtab. */ |
bd5635a1 | 1837 | |
d747e0af | 1838 | static void |
6c2e7392 | 1839 | parse_partial_symbols (objfile, section_offsets) |
d4ea2aba | 1840 | struct objfile *objfile; |
dac4929a | 1841 | struct section_offsets *section_offsets; |
bd5635a1 | 1842 | { |
5f7b2142 | 1843 | int f_idx, s_idx; |
6c2e7392 | 1844 | HDRR *hdr = &ecoff_data (cur_bfd)->symbolic_header; |
5f7b2142 ILT |
1845 | /* Running pointers */ |
1846 | FDR *fh; | |
6c2e7392 PS |
1847 | struct ext_ext *ext_out; |
1848 | struct ext_ext *ext_out_end; | |
1849 | EXTR *ext_block; | |
1850 | register EXTR *ext_in; | |
1851 | EXTR *ext_in_end; | |
1852 | SYMR sh; | |
5f7b2142 ILT |
1853 | struct partial_symtab *pst; |
1854 | ||
1855 | int past_first_source_file = 0; | |
1856 | ||
1857 | /* List of current psymtab's include files */ | |
1858 | char **psymtab_include_list; | |
1859 | int includes_allocated; | |
1860 | int includes_used; | |
6c2e7392 | 1861 | EXTR *extern_tab; |
5f7b2142 ILT |
1862 | struct pst_map *fdr_to_pst; |
1863 | /* Index within current psymtab dependency list */ | |
1864 | struct partial_symtab **dependency_list; | |
1865 | int dependencies_used, dependencies_allocated; | |
1866 | struct cleanup *old_chain; | |
1867 | char *name; | |
1868 | ||
6c2e7392 PS |
1869 | extern_tab = (EXTR *) obstack_alloc (&objfile->psymbol_obstack, |
1870 | sizeof (EXTR) * hdr->iextMax); | |
5f7b2142 ILT |
1871 | |
1872 | includes_allocated = 30; | |
1873 | includes_used = 0; | |
1874 | psymtab_include_list = (char **) alloca (includes_allocated * | |
1875 | sizeof (char *)); | |
1876 | next_symbol_text_func = mips_next_symbol_text; | |
1877 | ||
1878 | dependencies_allocated = 30; | |
1879 | dependencies_used = 0; | |
1880 | dependency_list = | |
1881 | (struct partial_symtab **) alloca (dependencies_allocated * | |
1882 | sizeof (struct partial_symtab *)); | |
1883 | ||
1884 | last_source_file = NULL; | |
1885 | ||
1886 | /* | |
6c2e7392 PS |
1887 | * Big plan: |
1888 | * | |
1889 | * Only parse the Local and External symbols, and the Relative FDR. | |
1890 | * Fixup enough of the loader symtab to be able to use it. | |
1891 | * Allocate space only for the file's portions we need to | |
1892 | * look at. (XXX) | |
1893 | */ | |
817bc7b8 | 1894 | |
5f7b2142 ILT |
1895 | max_gdbinfo = 0; |
1896 | max_glevel = MIN_GLEVEL; | |
1897 | ||
1898 | /* Allocate the map FDR -> PST. | |
1899 | Minor hack: -O3 images might claim some global data belongs | |
1900 | to FDR -1. We`ll go along with that */ | |
1901 | fdr_to_pst = (struct pst_map *) xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst); | |
1902 | old_chain = make_cleanup (free, fdr_to_pst); | |
1903 | fdr_to_pst++; | |
1904 | { | |
1905 | struct partial_symtab *pst = new_psymtab ("", objfile); | |
1906 | fdr_to_pst[-1].pst = pst; | |
1907 | FDR_IDX (pst) = -1; | |
1908 | } | |
1909 | ||
6c2e7392 PS |
1910 | /* Pass 0 over external syms: swap them in. */ |
1911 | ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR)); | |
1912 | make_cleanup (free, ext_block); | |
1913 | ||
1914 | ext_out = ecoff_data (cur_bfd)->external_ext; | |
1915 | ext_out_end = ext_out + hdr->iextMax; | |
1916 | ext_in = ext_block; | |
1917 | for (; ext_out < ext_out_end; ext_out++, ext_in++) | |
1918 | ecoff_swap_ext_in (cur_bfd, ext_out, ext_in); | |
1919 | ||
5f7b2142 | 1920 | /* Pass 1 over external syms: Presize and partition the list */ |
6c2e7392 PS |
1921 | ext_in = ext_block; |
1922 | ext_in_end = ext_in + hdr->iextMax; | |
1923 | for (; ext_in < ext_in_end; ext_in++) | |
1924 | fdr_to_pst[ext_in->ifd].n_globals++; | |
817bc7b8 | 1925 | |
5f7b2142 ILT |
1926 | /* Pass 1.5 over files: partition out global symbol space */ |
1927 | s_idx = 0; | |
1928 | for (f_idx = -1; f_idx < hdr->ifdMax; f_idx++) | |
1929 | { | |
1930 | fdr_to_pst[f_idx].globals_offset = s_idx; | |
1931 | s_idx += fdr_to_pst[f_idx].n_globals; | |
1932 | fdr_to_pst[f_idx].n_globals = 0; | |
d4ea2aba | 1933 | } |
bd5635a1 | 1934 | |
5f7b2142 | 1935 | /* Pass 2 over external syms: fill in external symbols */ |
6c2e7392 PS |
1936 | ext_in = ext_block; |
1937 | ext_in_end = ext_in + hdr->iextMax; | |
1938 | for (; ext_in < ext_in_end; ext_in++) | |
5f7b2142 ILT |
1939 | { |
1940 | enum minimal_symbol_type ms_type = mst_text; | |
bd5635a1 | 1941 | |
6c2e7392 PS |
1942 | extern_tab[fdr_to_pst[ext_in->ifd].globals_offset |
1943 | + fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in; | |
d4ea2aba | 1944 | |
6c2e7392 | 1945 | if (ext_in->asym.sc == scUndefined || ext_in->asym.sc == scNil) |
5f7b2142 | 1946 | continue; |
101f259c | 1947 | |
6c2e7392 PS |
1948 | name = ecoff_data (cur_bfd)->ssext + ext_in->asym.iss; |
1949 | switch (ext_in->asym.st) | |
5f7b2142 | 1950 | { |
817bc7b8 | 1951 | case stProc: |
5f7b2142 | 1952 | break; |
817bc7b8 | 1953 | case stGlobal: |
5f7b2142 ILT |
1954 | ms_type = mst_data; |
1955 | break; | |
817bc7b8 | 1956 | case stLabel: |
5f7b2142 | 1957 | break; |
817bc7b8 | 1958 | default: |
5f7b2142 | 1959 | ms_type = mst_unknown; |
6c2e7392 | 1960 | complain (&unknown_ext_complaint, name); |
bd5635a1 | 1961 | } |
6c2e7392 | 1962 | prim_record_minimal_symbol (name, ext_in->asym.value, ms_type); |
817bc7b8 | 1963 | } |
bd5635a1 | 1964 | |
5f7b2142 ILT |
1965 | /* Pass 3 over files, over local syms: fill in static symbols */ |
1966 | for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) | |
1967 | { | |
1968 | struct partial_symtab *save_pst; | |
6c2e7392 | 1969 | EXTR *ext_ptr; |
dac4929a | 1970 | |
6c2e7392 | 1971 | cur_fdr = fh = ecoff_data (cur_bfd)->fdr + f_idx; |
c55e6167 | 1972 | |
5f7b2142 ILT |
1973 | if (fh->csym == 0) |
1974 | { | |
1975 | fdr_to_pst[f_idx].pst = NULL; | |
1976 | continue; | |
817bc7b8 | 1977 | } |
6c2e7392 PS |
1978 | pst = start_psymtab_common (objfile, section_offsets, |
1979 | fdr_name (fh), | |
5f7b2142 ILT |
1980 | fh->cpd ? fh->adr : 0, |
1981 | objfile->global_psymbols.next, | |
1982 | objfile->static_psymbols.next); | |
1983 | pst->read_symtab_private = ((char *) | |
1984 | obstack_alloc (&objfile->psymbol_obstack, | |
1985 | sizeof (struct symloc))); | |
6c2e7392 | 1986 | memset ((PTR) pst->read_symtab_private, 0, sizeof (struct symloc)); |
5f7b2142 ILT |
1987 | |
1988 | save_pst = pst; | |
1989 | /* Make everything point to everything. */ | |
1990 | FDR_IDX (pst) = f_idx; | |
1991 | fdr_to_pst[f_idx].pst = pst; | |
6c2e7392 PS |
1992 | |
1993 | /* FIXME: This tampers with data from BFD. */ | |
5f7b2142 ILT |
1994 | fh->ioptBase = (int) pst; |
1995 | ||
6c2e7392 | 1996 | CUR_BFD (pst) = cur_bfd; |
5f7b2142 ILT |
1997 | |
1998 | /* The way to turn this into a symtab is to call... */ | |
1999 | pst->read_symtab = mipscoff_psymtab_to_symtab; | |
2000 | ||
2001 | pst->texthigh = pst->textlow; | |
2002 | ||
2003 | /* For stabs-in-ecoff files, the second symbol must be @stab. | |
6c2e7392 PS |
2004 | This symbol is emitted by mips-tfile to signal that the |
2005 | current object file uses encapsulated stabs instead of mips | |
2006 | ecoff for local symbols. (It is the second symbol because | |
2007 | the first symbol is the stFile used to signal the start of a | |
2008 | file). */ | |
2009 | processing_gcc_compilation = 0; | |
2010 | if (fh->csym >= 2) | |
2011 | { | |
2012 | ecoff_swap_sym_in (cur_bfd, | |
2013 | (ecoff_data (cur_bfd)->external_sym | |
2014 | + fh->isymBase | |
2015 | + 1), | |
2016 | &sh); | |
2017 | if (STREQ (ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss, | |
2018 | stabs_symbol)) | |
2019 | processing_gcc_compilation = 2; | |
2020 | } | |
2021 | ||
2022 | if (processing_gcc_compilation != 0) | |
5f7b2142 | 2023 | { |
5f7b2142 ILT |
2024 | for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++) |
2025 | { | |
2026 | int type_code; | |
2027 | char *namestring; | |
6c2e7392 PS |
2028 | |
2029 | ecoff_swap_sym_in (cur_bfd, | |
2030 | (ecoff_data (cur_bfd)->external_sym | |
2031 | + fh->isymBase | |
2032 | + cur_sdx), | |
2033 | &sh); | |
2034 | type_code = MIPS_UNMARK_STAB (sh.index); | |
2035 | if (!MIPS_IS_STAB (&sh)) | |
5f7b2142 | 2036 | { |
6c2e7392 | 2037 | if (sh.st == stProc || sh.st == stStaticProc) |
5f7b2142 | 2038 | { |
6c2e7392 PS |
2039 | long procaddr = sh.value; |
2040 | long isym; | |
2041 | ||
2042 | ||
2043 | isym = AUX_GET_ISYM (fh->fBigendian, | |
2044 | (ecoff_data (cur_bfd)->external_aux | |
2045 | + fh->iauxBase | |
2046 | + sh.index)); | |
2047 | ecoff_swap_sym_in (cur_bfd, | |
2048 | (ecoff_data (cur_bfd)->external_sym | |
2049 | + fh->isymBase | |
2050 | + isym | |
2051 | - 1), | |
2052 | &sh); | |
2053 | if (sh.st == stEnd) | |
5f7b2142 | 2054 | { |
6c2e7392 | 2055 | long high = procaddr + sh.value; |
5f7b2142 ILT |
2056 | if (high > pst->texthigh) |
2057 | pst->texthigh = high; | |
101f259c | 2058 | } |
7e258d18 | 2059 | } |
5f7b2142 | 2060 | continue; |
817bc7b8 | 2061 | } |
6c2e7392 PS |
2062 | #define SET_NAMESTRING() \ |
2063 | namestring = ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss | |
7e258d18 | 2064 | #define CUR_SYMBOL_TYPE type_code |
6c2e7392 | 2065 | #define CUR_SYMBOL_VALUE sh.value |
dac4929a | 2066 | #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\ |
7e258d18 PB |
2067 | pst = save_pst |
2068 | #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0 | |
7e258d18 PB |
2069 | #define HANDLE_RBRAC(val) \ |
2070 | if ((val) > save_pst->texthigh) save_pst->texthigh = (val); | |
7e258d18 | 2071 | #include "partial-stab.h" |
7e258d18 | 2072 | } |
817bc7b8 | 2073 | } |
5f7b2142 ILT |
2074 | else |
2075 | { | |
5f7b2142 ILT |
2076 | for (cur_sdx = 0; cur_sdx < fh->csym;) |
2077 | { | |
2078 | char *name; | |
2079 | enum address_class class; | |
5f7b2142 | 2080 | |
6c2e7392 PS |
2081 | ecoff_swap_sym_in (cur_bfd, |
2082 | (ecoff_data (cur_bfd)->external_sym | |
2083 | + fh->isymBase | |
2084 | + cur_sdx), | |
2085 | &sh); | |
2086 | ||
2087 | if (MIPS_IS_STAB (&sh)) | |
5f7b2142 ILT |
2088 | { |
2089 | cur_sdx++; | |
2090 | continue; | |
817bc7b8 | 2091 | } |
101f259c | 2092 | |
6c2e7392 PS |
2093 | if (sh.sc == scUndefined || sh.sc == scNil || |
2094 | sh.index == 0xfffff) | |
5f7b2142 ILT |
2095 | { |
2096 | /* FIXME, premature? */ | |
2097 | cur_sdx++; | |
2098 | continue; | |
817bc7b8 | 2099 | } |
dac4929a | 2100 | |
6c2e7392 | 2101 | name = ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss; |
817bc7b8 | 2102 | |
6c2e7392 | 2103 | switch (sh.st) |
5f7b2142 ILT |
2104 | { |
2105 | long high; | |
2106 | long procaddr; | |
2107 | int new_sdx; | |
2108 | ||
2109 | case stProc: /* Asm labels apparently */ | |
2110 | case stStaticProc: /* Function */ | |
2111 | ADD_PSYMBOL_TO_LIST (name, strlen (name), | |
2112 | VAR_NAMESPACE, LOC_BLOCK, | |
6c2e7392 | 2113 | objfile->static_psymbols, sh.value, |
5f7b2142 ILT |
2114 | psymtab_language, objfile); |
2115 | /* Skip over procedure to next one. */ | |
6c2e7392 | 2116 | if (sh.index >= hdr->iauxMax) |
5f7b2142 ILT |
2117 | { |
2118 | /* Should not happen, but does when cross-compiling | |
2119 | with the MIPS compiler. FIXME -- pull later. */ | |
2120 | complain (&index_complaint, name); | |
2121 | new_sdx = cur_sdx + 1; /* Don't skip at all */ | |
2122 | } | |
2123 | else | |
2124 | new_sdx = AUX_GET_ISYM (fh->fBigendian, | |
6c2e7392 PS |
2125 | (ecoff_data (cur_bfd)->external_aux |
2126 | + fh->iauxBase | |
2127 | + sh.index)); | |
2128 | procaddr = sh.value; | |
5f7b2142 ILT |
2129 | |
2130 | if (new_sdx <= cur_sdx) | |
2131 | { | |
2132 | /* This should not happen either... FIXME. */ | |
2133 | complain (&aux_index_complaint, name); | |
2134 | new_sdx = cur_sdx + 1; /* Don't skip backward */ | |
7e258d18 | 2135 | } |
817bc7b8 | 2136 | |
5f7b2142 | 2137 | cur_sdx = new_sdx; |
6c2e7392 PS |
2138 | ecoff_swap_sym_in (cur_bfd, |
2139 | (ecoff_data (cur_bfd)->external_sym | |
2140 | + fh->isymBase | |
2141 | + cur_sdx | |
2142 | - 1), | |
2143 | &sh); | |
2144 | if (sh.st != stEnd) | |
817bc7b8 | 2145 | continue; |
6c2e7392 | 2146 | high = procaddr + sh.value; |
5f7b2142 ILT |
2147 | if (high > pst->texthigh) |
2148 | pst->texthigh = high; | |
2149 | continue; | |
2150 | ||
2151 | case stStatic: /* Variable */ | |
2152 | class = LOC_STATIC; | |
2153 | break; | |
2154 | ||
2155 | case stTypedef:/* Typedef */ | |
2156 | class = LOC_TYPEDEF; | |
2157 | break; | |
2158 | ||
2159 | case stConstant: /* Constant decl */ | |
2160 | class = LOC_CONST; | |
2161 | break; | |
2162 | ||
2163 | case stUnion: | |
2164 | case stStruct: | |
2165 | case stEnum: | |
2166 | case stBlock: /* { }, str, un, enum*/ | |
e7ff735c | 2167 | if (sh.sc == scInfo || sh.sc == scCommon) |
5f7b2142 ILT |
2168 | { |
2169 | ADD_PSYMBOL_TO_LIST (name, strlen (name), | |
2170 | STRUCT_NAMESPACE, LOC_TYPEDEF, | |
2171 | objfile->static_psymbols, | |
6c2e7392 | 2172 | sh.value, |
5f7b2142 ILT |
2173 | psymtab_language, objfile); |
2174 | } | |
2175 | /* Skip over the block */ | |
6c2e7392 | 2176 | new_sdx = sh.index; |
5f7b2142 ILT |
2177 | if (new_sdx <= cur_sdx) |
2178 | { | |
2179 | /* This happens with the Ultrix kernel. */ | |
2180 | complain (&block_index_complaint, name); | |
2181 | new_sdx = cur_sdx + 1; /* Don't skip backward */ | |
2182 | } | |
2183 | cur_sdx = new_sdx; | |
2184 | continue; | |
2185 | ||
2186 | case stFile: /* File headers */ | |
2187 | case stLabel: /* Labels */ | |
2188 | case stEnd: /* Ends of files */ | |
2189 | goto skip; | |
2190 | ||
2191 | case stLocal: /* Local variables */ | |
2192 | /* Normally these are skipped because we skip over | |
2193 | all blocks we see. However, these can occur | |
2194 | as visible symbols in a .h file that contains code. */ | |
2195 | goto skip; | |
2196 | ||
2197 | default: | |
2198 | /* Both complaints are valid: one gives symbol name, | |
2199 | the other the offending symbol type. */ | |
6c2e7392 PS |
2200 | complain (&unknown_sym_complaint, name); |
2201 | complain (&unknown_st_complaint, sh.st); | |
5f7b2142 ILT |
2202 | cur_sdx++; |
2203 | continue; | |
101f259c | 2204 | } |
5f7b2142 ILT |
2205 | /* Use this gdb symbol */ |
2206 | ADD_PSYMBOL_TO_LIST (name, strlen (name), | |
2207 | VAR_NAMESPACE, class, | |
6c2e7392 | 2208 | objfile->static_psymbols, sh.value, |
5f7b2142 ILT |
2209 | psymtab_language, objfile); |
2210 | skip: | |
2211 | cur_sdx++; /* Go to next file symbol */ | |
817bc7b8 | 2212 | } |
d4ea2aba | 2213 | |
5f7b2142 ILT |
2214 | /* Now do enter the external symbols. */ |
2215 | ext_ptr = &extern_tab[fdr_to_pst[f_idx].globals_offset]; | |
2216 | cur_sdx = fdr_to_pst[f_idx].n_globals; | |
2217 | PST_PRIVATE (save_pst)->extern_count = cur_sdx; | |
2218 | PST_PRIVATE (save_pst)->extern_tab = ext_ptr; | |
2219 | for (; --cur_sdx >= 0; ext_ptr++) | |
2220 | { | |
2221 | register struct partial_symbol *psym; | |
2222 | enum address_class class; | |
6c2e7392 PS |
2223 | SYMR *psh; |
2224 | char *name; | |
5f7b2142 | 2225 | |
6c2e7392 | 2226 | if (ext_ptr->ifd != f_idx) |
5f7b2142 | 2227 | abort (); |
6c2e7392 PS |
2228 | psh = &ext_ptr->asym; |
2229 | switch (psh->st) | |
5f7b2142 ILT |
2230 | { |
2231 | case stProc: | |
2232 | class = LOC_BLOCK; | |
2233 | break; | |
2234 | case stLabel: | |
2235 | class = LOC_LABEL; | |
2236 | break; | |
2237 | default: | |
6c2e7392 PS |
2238 | complain (&unknown_ext_complaint, |
2239 | ecoff_data (cur_bfd)->ssext + psh->iss); | |
5f7b2142 ILT |
2240 | /* Fall through, pretend it's global. */ |
2241 | case stGlobal: | |
2242 | class = LOC_STATIC; | |
2243 | break; | |
d4ea2aba | 2244 | } |
6c2e7392 PS |
2245 | name = ecoff_data (cur_bfd)->ssext + psh->iss; |
2246 | ADD_PSYMBOL_ADDR_TO_LIST (name, strlen (name), | |
2247 | VAR_NAMESPACE, class, | |
2248 | objfile->global_psymbols, (CORE_ADDR) psh->value, | |
2249 | psymtab_language, objfile); | |
7e258d18 | 2250 | } |
bd5635a1 RP |
2251 | } |
2252 | ||
5f7b2142 ILT |
2253 | end_psymtab (save_pst, psymtab_include_list, includes_used, |
2254 | -1, save_pst->texthigh, | |
2255 | dependency_list, dependencies_used); | |
2256 | if (objfile->ei.entry_point >= save_pst->textlow && | |
2257 | objfile->ei.entry_point < save_pst->texthigh) | |
2258 | { | |
2259 | objfile->ei.entry_file_lowpc = save_pst->textlow; | |
2260 | objfile->ei.entry_file_highpc = save_pst->texthigh; | |
2261 | } | |
817bc7b8 JG |
2262 | } |
2263 | ||
5f7b2142 ILT |
2264 | /* Now scan the FDRs for dependencies */ |
2265 | for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) | |
2266 | { | |
2267 | int s_id0 = 0; | |
6c2e7392 | 2268 | fh = f_idx + ecoff_data (cur_bfd)->fdr; |
5f7b2142 ILT |
2269 | pst = fdr_to_pst[f_idx].pst; |
2270 | ||
2271 | /* This should catch stabs-in-ecoff. */ | |
2272 | if (fh->crfd <= 1) | |
2273 | continue; | |
2274 | ||
2275 | if (fh->cpd == 0) | |
6c2e7392 | 2276 | { /* If there are no functions defined here ... */ |
5f7b2142 ILT |
2277 | /* ...then presumably a .h file: drop reverse depends .h->.c */ |
2278 | for (; s_id0 < fh->crfd; s_id0++) | |
2279 | { | |
6c2e7392 PS |
2280 | RFDT rh; |
2281 | ||
2282 | ecoff_swap_rfd_in (cur_bfd, | |
2283 | (ecoff_data (cur_bfd)->external_rfd | |
2284 | + fh->rfdBase | |
2285 | + s_id0), | |
2286 | &rh); | |
2287 | if (rh == f_idx) | |
5f7b2142 ILT |
2288 | { |
2289 | s_id0++; /* Skip self-dependency */ | |
2290 | break; | |
021959e2 | 2291 | } |
5f7b2142 | 2292 | } |
021959e2 | 2293 | } |
5f7b2142 ILT |
2294 | pst->number_of_dependencies = fh->crfd - s_id0; |
2295 | pst->dependencies = | |
2296 | ((struct partial_symtab **) | |
2297 | obstack_alloc (&objfile->psymbol_obstack, | |
2298 | (pst->number_of_dependencies | |
2299 | * sizeof (struct partial_symtab *)))); | |
2300 | for (s_idx = s_id0; s_idx < fh->crfd; s_idx++) | |
2301 | { | |
6c2e7392 PS |
2302 | RFDT rh; |
2303 | ||
2304 | ecoff_swap_rfd_in (cur_bfd, | |
2305 | (ecoff_data (cur_bfd)->external_rfd | |
2306 | + fh->rfdBase | |
2307 | + s_idx), | |
2308 | &rh); | |
2309 | if (rh < 0 || rh >= hdr->ifdMax) | |
2310 | complain (&bad_file_number_complaint, rh); | |
5f7b2142 | 2311 | else |
6c2e7392 | 2312 | pst->dependencies[s_idx - s_id0] = fdr_to_pst[rh].pst; |
021959e2 JG |
2313 | } |
2314 | } | |
5f7b2142 | 2315 | do_cleanups (old_chain); |
bd5635a1 RP |
2316 | } |
2317 | ||
2318 | ||
d4ea2aba | 2319 | #if 0 |
bd5635a1 RP |
2320 | /* Do the initial analisys of the F_IDX-th file descriptor. |
2321 | Allocates a partial symtab for it, and builds the list | |
2322 | of dependent files by recursion. LEV says at which level | |
2323 | of recursion we are called (to pretty up debug traces) */ | |
2324 | ||
2325 | static struct partial_symtab * | |
5f7b2142 ILT |
2326 | parse_fdr (f_idx, lev, objfile) |
2327 | int f_idx; | |
2328 | int lev; | |
2329 | struct objfile *objfile; | |
bd5635a1 | 2330 | { |
5f7b2142 ILT |
2331 | register FDR *fh; |
2332 | register struct partial_symtab *pst; | |
2333 | int s_idx, s_id0; | |
bd5635a1 | 2334 | |
6c2e7392 | 2335 | fh = ecoff_data (cur_bfd)->fdr + f_idx; |
5f7b2142 ILT |
2336 | |
2337 | /* Use this to indicate into which symtab this file was parsed */ | |
2338 | if (fh->ioptBase) | |
2339 | return (struct partial_symtab *) fh->ioptBase; | |
2340 | ||
2341 | /* Debuggability level */ | |
2342 | if (compare_glevel (max_glevel, fh->glevel) < 0) | |
2343 | max_glevel = fh->glevel; | |
2344 | ||
2345 | /* Make a new partial_symtab */ | |
6c2e7392 | 2346 | pst = new_psymtab (fdr_name (fh), objfile); |
5f7b2142 ILT |
2347 | if (fh->cpd == 0) |
2348 | { | |
2349 | pst->textlow = 0; | |
2350 | pst->texthigh = 0; | |
2351 | } | |
2352 | else | |
2353 | { | |
2354 | pst->textlow = fh->adr; | |
2355 | pst->texthigh = fh->cpd; /* To be fixed later */ | |
2356 | } | |
2357 | ||
2358 | /* Make everything point to everything. */ | |
2359 | FDR_IDX (pst) = f_idx; | |
2360 | fdr_to_pst[f_idx].pst = pst; | |
2361 | fh->ioptBase = (int) pst; | |
2362 | ||
2363 | /* Analyze its dependencies */ | |
2364 | if (fh->crfd <= 1) | |
2365 | return pst; | |
2366 | ||
2367 | s_id0 = 0; | |
2368 | if (fh->cpd == 0) | |
6c2e7392 | 2369 | { /* If there are no functions defined here ... */ |
5f7b2142 ILT |
2370 | /* ...then presumably a .h file: drop reverse depends .h->.c */ |
2371 | for (; s_id0 < fh->crfd; s_id0++) | |
2372 | { | |
6c2e7392 PS |
2373 | RFDT rh; |
2374 | ||
2375 | ecoff_swap_rfd_in (cur_bfd, | |
2376 | (ecoff_data (cur_bfd)->external_rfd | |
2377 | + fh->rfdBase | |
2378 | + s_id0), | |
2379 | &rh); | |
2380 | if (rh == f_idx) | |
5f7b2142 ILT |
2381 | { |
2382 | s_id0++; /* Skip self-dependency */ | |
2383 | break; | |
2384 | } | |
bd5635a1 | 2385 | } |
5f7b2142 ILT |
2386 | } |
2387 | pst->number_of_dependencies = fh->crfd - s_id0; | |
2388 | pst->dependencies = ((struct partial_symtab **) | |
2389 | obstack_alloc (&objfile->psymbol_obstack, | |
2390 | (pst->number_of_dependencies | |
2391 | * sizeof (struct partial_symtab *)))); | |
2392 | for (s_idx = s_id0; s_idx < fh->crfd; s_idx++) | |
2393 | { | |
6c2e7392 PS |
2394 | RFDT rh; |
2395 | ||
2396 | ecoff_swap_rfd_in (cur_bfd, | |
2397 | (ecoff_data (cur_bfd)->external_rfd | |
2398 | + fh->rfdBase | |
2399 | + s_idx), | |
2400 | &rh); | |
2401 | pst->dependencies[s_idx - s_id0] = parse_fdr (rh, lev + 1, objfile); | |
5f7b2142 | 2402 | } |
bd5635a1 | 2403 | |
5f7b2142 | 2404 | return pst; |
bd5635a1 | 2405 | } |
5f7b2142 | 2406 | |
d4ea2aba | 2407 | #endif |
bd5635a1 | 2408 | |
5f7b2142 | 2409 | static char * |
c55e6167 | 2410 | mips_next_symbol_text () |
7e258d18 | 2411 | { |
6c2e7392 PS |
2412 | SYMR sh; |
2413 | ||
5f7b2142 | 2414 | cur_sdx++; |
6c2e7392 PS |
2415 | ecoff_swap_sym_in (cur_bfd, |
2416 | (ecoff_data (cur_bfd)->external_sym | |
2417 | + cur_fdr->isymBase | |
2418 | + cur_sdx), | |
2419 | &sh); | |
2420 | return ecoff_data (cur_bfd)->ss + cur_fdr->issBase + sh.iss; | |
7e258d18 | 2421 | } |
bd5635a1 RP |
2422 | |
2423 | /* Ancillary function to psymtab_to_symtab(). Does all the work | |
2424 | for turning the partial symtab PST into a symtab, recurring | |
3eaebb75 SG |
2425 | first on all dependent psymtabs. The argument FILENAME is |
2426 | only passed so we can see in debug stack traces what file | |
817bc7b8 JG |
2427 | is being read. |
2428 | ||
2429 | This function has a split personality, based on whether the | |
2430 | symbol table contains ordinary ecoff symbols, or stabs-in-ecoff. | |
2431 | The flow of control and even the memory allocation differs. FIXME. */ | |
bd5635a1 | 2432 | |
e072c738 | 2433 | static void |
5f7b2142 | 2434 | psymtab_to_symtab_1 (pst, filename) |
7e258d18 PB |
2435 | struct partial_symtab *pst; |
2436 | char *filename; | |
bd5635a1 | 2437 | { |
5f7b2142 ILT |
2438 | int i; |
2439 | struct symtab *st; | |
2440 | FDR *fh; | |
2441 | struct linetable *lines; | |
7e258d18 | 2442 | |
5f7b2142 ILT |
2443 | if (pst->readin) |
2444 | return; | |
2445 | pst->readin = 1; | |
7e258d18 | 2446 | |
5f7b2142 ILT |
2447 | /* Read in all partial symbtabs on which this one is dependent. |
2448 | NOTE that we do have circular dependencies, sigh. We solved | |
2449 | that by setting pst->readin before this point. */ | |
817bc7b8 | 2450 | |
5f7b2142 ILT |
2451 | for (i = 0; i < pst->number_of_dependencies; i++) |
2452 | if (!pst->dependencies[i]->readin) | |
2453 | { | |
2454 | /* Inform about additional files to be read in. */ | |
2455 | if (info_verbose) | |
2456 | { | |
2457 | fputs_filtered (" ", stdout); | |
2458 | wrap_here (""); | |
2459 | fputs_filtered ("and ", stdout); | |
2460 | wrap_here (""); | |
2461 | printf_filtered ("%s...", | |
2462 | pst->dependencies[i]->filename); | |
2463 | wrap_here (""); /* Flush output */ | |
2464 | fflush (stdout); | |
2465 | } | |
2466 | /* We only pass the filename for debug purposes */ | |
2467 | psymtab_to_symtab_1 (pst->dependencies[i], | |
2468 | pst->dependencies[i]->filename); | |
2469 | } | |
817bc7b8 | 2470 | |
ac8cf67d PS |
2471 | /* Do nothing if this is a dummy psymtab. */ |
2472 | ||
2473 | if (pst->n_global_syms == 0 && pst->n_static_syms == 0 | |
2474 | && pst->textlow == 0 && pst->texthigh == 0) | |
2475 | return; | |
2476 | ||
5f7b2142 | 2477 | /* Now read the symbols for this symtab */ |
817bc7b8 | 2478 | |
ac8cf67d | 2479 | cur_bfd = CUR_BFD (pst); |
5f7b2142 ILT |
2480 | current_objfile = pst->objfile; |
2481 | cur_fd = FDR_IDX (pst); | |
6c2e7392 | 2482 | fh = (cur_fd == -1) ? (FDR *) NULL : ecoff_data (cur_bfd)->fdr + cur_fd; |
5f7b2142 | 2483 | cur_fdr = fh; |
817bc7b8 | 2484 | |
5f7b2142 | 2485 | /* See comment in parse_partial_symbols about the @stabs sentinel. */ |
6c2e7392 PS |
2486 | processing_gcc_compilation = 0; |
2487 | if (fh != (FDR *) NULL && fh->csym >= 2) | |
5f7b2142 | 2488 | { |
6c2e7392 PS |
2489 | SYMR sh; |
2490 | ||
2491 | ecoff_swap_sym_in (cur_bfd, | |
2492 | (ecoff_data (cur_bfd)->external_sym | |
2493 | + fh->isymBase | |
2494 | + 1), | |
2495 | &sh); | |
2496 | if (STREQ (ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss, | |
2497 | stabs_symbol)) | |
2498 | { | |
2499 | /* We indicate that this is a GCC compilation so that certain | |
2500 | features will be enabled in stabsread/dbxread. */ | |
2501 | processing_gcc_compilation = 2; | |
2502 | } | |
2503 | } | |
817bc7b8 | 2504 | |
6c2e7392 PS |
2505 | if (processing_gcc_compilation != 0) |
2506 | { | |
2507 | struct pdr_ext *pdr_ptr; | |
2508 | struct pdr_ext *pdr_end; | |
2509 | int first_pdr; | |
2510 | unsigned long first_off; | |
9adb88b7 | 2511 | |
b5d4d6d7 | 2512 | /* This symbol table contains stabs-in-ecoff entries. */ |
dac4929a | 2513 | |
5f7b2142 | 2514 | /* Parse local symbols first */ |
817bc7b8 | 2515 | |
5f7b2142 ILT |
2516 | if (fh->csym <= 2) /* FIXME, this blows psymtab->symtab ptr */ |
2517 | { | |
2518 | current_objfile = NULL; | |
2519 | return; | |
2520 | } | |
2521 | for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++) | |
2522 | { | |
6c2e7392 PS |
2523 | SYMR sh; |
2524 | char *name; | |
2525 | CORE_ADDR valu; | |
2526 | ||
2527 | ecoff_swap_sym_in (cur_bfd, | |
2528 | (ecoff_data (cur_bfd)->external_sym | |
2529 | + fh->isymBase | |
2530 | + cur_sdx), | |
2531 | &sh); | |
2532 | name = ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss; | |
2533 | valu = sh.value; | |
2534 | if (MIPS_IS_STAB (&sh)) | |
5f7b2142 | 2535 | { |
6c2e7392 | 2536 | int type_code = MIPS_UNMARK_STAB (sh.index); |
5f7b2142 ILT |
2537 | process_one_symbol (type_code, 0, valu, name, |
2538 | pst->section_offsets, pst->objfile); | |
2539 | if (type_code == N_FUN) | |
2540 | { | |
2541 | /* Make up special symbol to contain | |
2542 | procedure specific info */ | |
2543 | struct mips_extra_func_info *e = | |
6c2e7392 PS |
2544 | ((struct mips_extra_func_info *) |
2545 | obstack_alloc (¤t_objfile->symbol_obstack, | |
2546 | sizeof (struct mips_extra_func_info))); | |
5f7b2142 ILT |
2547 | struct symbol *s = new_symbol (MIPS_EFI_SYMBOL_NAME); |
2548 | SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; | |
2549 | SYMBOL_CLASS (s) = LOC_CONST; | |
2550 | SYMBOL_TYPE (s) = builtin_type_void; | |
2551 | SYMBOL_VALUE (s) = (int) e; | |
2552 | add_symbol_to_list (s, &local_symbols); | |
817bc7b8 JG |
2553 | } |
2554 | } | |
6c2e7392 | 2555 | else if (sh.st == stLabel && sh.index != indexNil) |
5f7b2142 ILT |
2556 | { |
2557 | /* Handle encoded stab line number. */ | |
6c2e7392 | 2558 | record_line (current_subfile, sh.index, valu); |
817bc7b8 | 2559 | } |
0b0d6c3f PS |
2560 | else if (sh.st == stProc || sh.st == stStaticProc || sh.st == stEnd) |
2561 | /* These are generated by gcc-2.x, do not complain */ | |
2562 | ; | |
5f7b2142 | 2563 | else |
6c2e7392 | 2564 | complain (&stab_unknown_complaint, name); |
817bc7b8 | 2565 | } |
0b0d6c3f | 2566 | st = end_symtab (pst->texthigh, 0, 0, pst->objfile, SECT_OFF_TEXT); |
5f7b2142 | 2567 | end_stabs (); |
817bc7b8 | 2568 | |
5f7b2142 ILT |
2569 | /* Sort the symbol table now, we are done adding symbols to it. |
2570 | We must do this before parse_procedure calls lookup_symbol. */ | |
2571 | sort_symtab_syms (st); | |
817bc7b8 | 2572 | |
5f7b2142 ILT |
2573 | /* This may not be necessary for stabs symtabs. FIXME. */ |
2574 | sort_blocks (st); | |
817bc7b8 | 2575 | |
6c2e7392 PS |
2576 | /* Fill in procedure info next. */ |
2577 | first_pdr = 1; | |
2578 | pdr_ptr = ecoff_data (cur_bfd)->external_pdr + fh->ipdFirst; | |
2579 | pdr_end = pdr_ptr + fh->cpd; | |
2580 | for (; pdr_ptr < pdr_end; pdr_ptr++) | |
5f7b2142 | 2581 | { |
6c2e7392 PS |
2582 | PDR pr; |
2583 | ||
2584 | ecoff_swap_pdr_in (cur_bfd, pdr_ptr, &pr); | |
2585 | if (first_pdr) | |
2586 | { | |
2587 | first_off = pr.adr; | |
2588 | first_pdr = 0; | |
2589 | } | |
b5d4d6d7 | 2590 | parse_procedure (&pr, st, first_off); |
817bc7b8 | 2591 | } |
5f7b2142 ILT |
2592 | } |
2593 | else | |
2594 | { | |
6c2e7392 | 2595 | /* This symbol table contains ordinary ecoff entries. */ |
817bc7b8 | 2596 | |
5f7b2142 | 2597 | /* FIXME: doesn't use pst->section_offsets. */ |
dac4929a | 2598 | |
5f7b2142 ILT |
2599 | int f_max; |
2600 | int maxlines; | |
6c2e7392 | 2601 | EXTR *ext_ptr; |
85f0a848 | 2602 | |
5f7b2142 ILT |
2603 | /* How many symbols will we need */ |
2604 | /* FIXME, this does not count enum values. */ | |
2605 | f_max = pst->n_global_syms + pst->n_static_syms; | |
2606 | if (fh == 0) | |
2607 | { | |
2608 | maxlines = 0; | |
2609 | st = new_symtab ("unknown", f_max, 0, pst->objfile); | |
2610 | } | |
2611 | else | |
2612 | { | |
2613 | f_max += fh->csym + fh->cpd; | |
2614 | maxlines = 2 * fh->cline; | |
2615 | st = new_symtab (pst->filename, 2 * f_max, maxlines, pst->objfile); | |
817bc7b8 JG |
2616 | } |
2617 | ||
5f7b2142 | 2618 | lines = LINETABLE (st); |
6c2e7392 | 2619 | pending_list = PST_PRIVATE (pst)->pending_list; |
5f7b2142 ILT |
2620 | if (pending_list == 0) |
2621 | { | |
6c2e7392 PS |
2622 | pending_list = ((struct mips_pending **) |
2623 | xzalloc (ecoff_data (cur_bfd)->symbolic_header.ifdMax | |
2624 | * sizeof (struct mips_pending *))); | |
2625 | PST_PRIVATE (pst)->pending_list = pending_list; | |
817bc7b8 JG |
2626 | } |
2627 | ||
5f7b2142 ILT |
2628 | /* Get a new lexical context */ |
2629 | ||
2630 | push_parse_stack (); | |
2631 | top_stack->cur_st = st; | |
2632 | top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st), | |
2633 | STATIC_BLOCK); | |
2634 | BLOCK_START (top_stack->cur_block) = fh ? fh->adr : 0; | |
2635 | BLOCK_END (top_stack->cur_block) = 0; | |
2636 | top_stack->blocktype = stFile; | |
2637 | top_stack->maxsyms = 2 * f_max; | |
2638 | top_stack->cur_type = 0; | |
2639 | top_stack->procadr = 0; | |
2640 | top_stack->numargs = 0; | |
2641 | ||
2642 | if (fh) | |
2643 | { | |
6c2e7392 PS |
2644 | struct sym_ext *sym_ptr; |
2645 | struct sym_ext *sym_end; | |
5f7b2142 ILT |
2646 | |
2647 | /* Parse local symbols first */ | |
6c2e7392 PS |
2648 | sym_ptr = ecoff_data (cur_bfd)->external_sym + fh->isymBase; |
2649 | sym_end = sym_ptr + fh->csym; | |
2650 | while (sym_ptr < sym_end) | |
5f7b2142 | 2651 | { |
6c2e7392 PS |
2652 | SYMR sh; |
2653 | int c; | |
2654 | ||
2655 | ecoff_swap_sym_in (cur_bfd, sym_ptr, &sh); | |
2656 | c = parse_symbol (&sh, | |
2657 | (ecoff_data (cur_bfd)->external_aux | |
2658 | + fh->iauxBase), | |
2659 | sym_ptr, fh->fBigendian); | |
2660 | /* FIXME: We must swap the modified symbol back out, | |
2661 | although we would rather not. See parse_symbol. */ | |
2662 | ecoff_swap_sym_out (cur_bfd, &sh, sym_ptr); | |
2663 | sym_ptr += c; | |
7e258d18 | 2664 | } |
bd5635a1 | 2665 | |
6c2e7392 PS |
2666 | /* Linenumbers. At the end, check if we can save memory. |
2667 | parse_lines has to look ahead an arbitrary number of PDR | |
2668 | structures, so we swap them all first. */ | |
2669 | if (fh->cpd > 0) | |
5f7b2142 | 2670 | { |
6c2e7392 PS |
2671 | PDR *pr_block; |
2672 | struct cleanup *old_chain; | |
2673 | struct pdr_ext *pdr_ptr; | |
2674 | struct pdr_ext *pdr_end; | |
2675 | PDR *pdr_in; | |
2676 | PDR *pdr_in_end; | |
2677 | ||
2678 | pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR)); | |
2679 | ||
2680 | old_chain = make_cleanup (free, pr_block); | |
2681 | ||
2682 | pdr_ptr = ecoff_data (cur_bfd)->external_pdr + fh->ipdFirst; | |
2683 | pdr_end = pdr_ptr + fh->cpd; | |
2684 | pdr_in = pr_block; | |
2685 | for (; pdr_ptr < pdr_end; pdr_ptr++, pdr_in++) | |
2686 | ecoff_swap_pdr_in (cur_bfd, pdr_ptr, pdr_in); | |
2687 | ||
2688 | parse_lines (fh, pr_block, lines); | |
2689 | if (lines->nitems < fh->cline) | |
2690 | lines = shrink_linetable (lines); | |
2691 | ||
2692 | /* Fill in procedure info next. */ | |
2693 | pdr_in = pr_block; | |
2694 | pdr_in_end = pdr_in + fh->cpd; | |
2695 | for (; pdr_in < pdr_in_end; pdr_in++) | |
2696 | parse_procedure (pdr_in, 0, pr_block->adr); | |
2697 | ||
2698 | do_cleanups (old_chain); | |
817bc7b8 | 2699 | } |
ad142b8e | 2700 | } |
817bc7b8 | 2701 | |
5f7b2142 ILT |
2702 | LINETABLE (st) = lines; |
2703 | ||
2704 | /* .. and our share of externals. | |
2705 | XXX use the global list to speed up things here. how? | |
2706 | FIXME, Maybe quit once we have found the right number of ext's? */ | |
2707 | top_stack->cur_st = st; | |
2708 | top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st), | |
2709 | GLOBAL_BLOCK); | |
2710 | top_stack->blocktype = stFile; | |
6c2e7392 PS |
2711 | top_stack->maxsyms = (ecoff_data (cur_bfd)->symbolic_header.isymMax |
2712 | + ecoff_data (cur_bfd)->symbolic_header.ipdMax | |
2713 | + ecoff_data (cur_bfd)->symbolic_header.iextMax); | |
5f7b2142 ILT |
2714 | |
2715 | ext_ptr = PST_PRIVATE (pst)->extern_tab; | |
2716 | for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++) | |
6c2e7392 | 2717 | parse_external (ext_ptr, 1, fh->fBigendian); |
5f7b2142 ILT |
2718 | |
2719 | /* If there are undefined, tell the user */ | |
2720 | if (n_undef_symbols) | |
2721 | { | |
2722 | printf_filtered ("File %s contains %d unresolved references:", | |
2723 | st->filename, n_undef_symbols); | |
2724 | printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n", | |
2725 | n_undef_vars, n_undef_procs, n_undef_labels); | |
2726 | n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0; | |
bd5635a1 | 2727 | |
7e258d18 | 2728 | } |
5f7b2142 | 2729 | pop_parse_stack (); |
817bc7b8 | 2730 | |
5f7b2142 ILT |
2731 | /* Sort the symbol table now, we are done adding symbols to it.*/ |
2732 | sort_symtab_syms (st); | |
817bc7b8 | 2733 | |
5f7b2142 | 2734 | sort_blocks (st); |
7e258d18 | 2735 | } |
7e258d18 | 2736 | |
5f7b2142 ILT |
2737 | /* Now link the psymtab and the symtab. */ |
2738 | pst->symtab = st; | |
021959e2 | 2739 | |
5f7b2142 | 2740 | current_objfile = NULL; |
101f259c | 2741 | } |
bd5635a1 RP |
2742 | \f |
2743 | /* Ancillary parsing procedures. */ | |
2744 | ||
2745 | /* Lookup the type at relative index RN. Return it in TPP | |
2746 | if found and in any event come up with its name PNAME. | |
d747e0af MT |
2747 | BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian). |
2748 | Return value says how many aux symbols we ate. */ | |
bd5635a1 | 2749 | |
d747e0af | 2750 | static int |
5f7b2142 | 2751 | cross_ref (ax, tpp, type_code, pname, bigend) |
d747e0af | 2752 | union aux_ext *ax; |
7e258d18 | 2753 | struct type **tpp; |
5f7b2142 | 2754 | enum type_code type_code; /* Use to alloc new type if none is found. */ |
7e258d18 | 2755 | char **pname; |
d747e0af | 2756 | int bigend; |
bd5635a1 | 2757 | { |
5f7b2142 ILT |
2758 | RNDXR rn[1]; |
2759 | unsigned rf; | |
2760 | int result = 1; | |
bd5635a1 | 2761 | |
6c2e7392 | 2762 | ecoff_swap_rndx_in (bigend, &ax->a_rndx, rn); |
5f7b2142 ILT |
2763 | |
2764 | /* Escape index means 'the next one' */ | |
2765 | if (rn->rfd == 0xfff) | |
2766 | { | |
2767 | result++; | |
2768 | rf = AUX_GET_ISYM (bigend, ax + 1); | |
2769 | } | |
2770 | else | |
2771 | { | |
2772 | rf = rn->rfd; | |
2773 | } | |
2774 | ||
2775 | if (rf == -1) | |
2776 | { | |
2777 | /* Ooops */ | |
2778 | *pname = "<undefined>"; | |
2779 | } | |
2780 | else | |
2781 | { | |
2782 | /* | |
2783 | * Find the relative file descriptor and the symbol in it | |
2784 | */ | |
2785 | FDR *fh = get_rfd (cur_fd, rf); | |
6c2e7392 PS |
2786 | struct sym_ext *esh; |
2787 | SYMR sh; | |
5f7b2142 ILT |
2788 | struct type *t; |
2789 | ||
6c2e7392 PS |
2790 | /* If we have processed this symbol then we left a forwarding |
2791 | pointer to the corresponding GDB symbol. If not, we`ll put | |
2792 | it in a list of pending symbols, to be processed later when | |
2793 | the file will be. In any event, we collect the name for the | |
2794 | type here. Which is why we made a first pass at strings. */ | |
2795 | ||
2796 | esh = ecoff_data (cur_bfd)->external_sym + fh->isymBase + rn->index; | |
2797 | ecoff_swap_sym_in (cur_bfd, esh, &sh); | |
5f7b2142 ILT |
2798 | |
2799 | /* Careful, we might be looking at .o files */ | |
6c2e7392 PS |
2800 | if (sh.iss == 0) |
2801 | *pname = "<undefined>"; | |
28d14fd8 JK |
2802 | else if (rn->rfd == 0xfff && rn->index == 0) |
2803 | /* For structs, unions and enums, rn->rfd is 0xfff and the index | |
2804 | is a relative symbol number for the type, but an index of 0 | |
2805 | seems to mean that we don't know. This is said to fix a problem | |
2806 | with "info func opendir" on an SGI showing | |
2807 | "struct BSDopendir.c *BSDopendir();". */ | |
2808 | *pname = "<unknown>"; | |
6c2e7392 PS |
2809 | else |
2810 | *pname = ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss; | |
5f7b2142 ILT |
2811 | |
2812 | /* Have we parsed it ? */ | |
6c2e7392 | 2813 | if (sh.value != 0 && sh.st == stParsed) |
5f7b2142 | 2814 | { |
6c2e7392 | 2815 | t = (struct type *) sh.value; |
5f7b2142 | 2816 | *tpp = t; |
bd5635a1 | 2817 | } |
5f7b2142 ILT |
2818 | else |
2819 | { | |
2820 | /* Avoid duplicates */ | |
6c2e7392 | 2821 | struct mips_pending *p = is_pending_symbol (fh, esh); |
5f7b2142 ILT |
2822 | if (p) |
2823 | *tpp = p->t; | |
2824 | else | |
2825 | { | |
2826 | *tpp = init_type (type_code, 0, 0, (char *) NULL, | |
2827 | (struct objfile *) NULL); | |
6c2e7392 | 2828 | add_pending (fh, esh, *tpp); |
5f7b2142 ILT |
2829 | } |
2830 | } | |
2831 | } | |
3eaebb75 | 2832 | |
5f7b2142 ILT |
2833 | /* We used one auxent normally, two if we got a "next one" rf. */ |
2834 | return result; | |
bd5635a1 RP |
2835 | } |
2836 | ||
2837 | ||
2838 | /* Quick&dirty lookup procedure, to avoid the MI ones that require | |
2839 | keeping the symtab sorted */ | |
2840 | ||
2841 | static struct symbol * | |
2842 | mylookup_symbol (name, block, namespace, class) | |
2843 | char *name; | |
2844 | register struct block *block; | |
2845 | enum namespace namespace; | |
2846 | enum address_class class; | |
2847 | { | |
5f7b2142 ILT |
2848 | register int bot, top, inc; |
2849 | register struct symbol *sym; | |
2850 | ||
2851 | bot = 0; | |
2852 | top = BLOCK_NSYMS (block); | |
2853 | inc = name[0]; | |
2854 | while (bot < top) | |
2855 | { | |
2856 | sym = BLOCK_SYM (block, bot); | |
2857 | if (SYMBOL_NAME (sym)[0] == inc | |
2858 | && SYMBOL_NAMESPACE (sym) == namespace | |
2859 | && SYMBOL_CLASS (sym) == class | |
4fb0ff3b | 2860 | && strcmp (SYMBOL_NAME (sym), name) == 0) |
5f7b2142 ILT |
2861 | return sym; |
2862 | bot++; | |
2863 | } | |
2864 | block = BLOCK_SUPERBLOCK (block); | |
2865 | if (block) | |
2866 | return mylookup_symbol (name, block, namespace, class); | |
2867 | return 0; | |
bd5635a1 RP |
2868 | } |
2869 | ||
2870 | ||
3eaebb75 SG |
2871 | /* Add a new symbol S to a block B. |
2872 | Infrequently, we will need to reallocate the block to make it bigger. | |
2873 | We only detect this case when adding to top_stack->cur_block, since | |
2874 | that's the only time we know how big the block is. FIXME. */ | |
bd5635a1 | 2875 | |
3eaebb75 | 2876 | static void |
5f7b2142 ILT |
2877 | add_symbol (s, b) |
2878 | struct symbol *s; | |
2879 | struct block *b; | |
bd5635a1 | 2880 | { |
5f7b2142 ILT |
2881 | int nsyms = BLOCK_NSYMS (b)++; |
2882 | struct block *origb; | |
2883 | struct parse_stack *stackp; | |
2884 | ||
2885 | if (b == top_stack->cur_block && | |
2886 | nsyms >= top_stack->maxsyms) | |
2887 | { | |
2888 | complain (&block_overflow_complaint, SYMBOL_NAME (s)); | |
2889 | /* In this case shrink_block is actually grow_block, since | |
3eaebb75 | 2890 | BLOCK_NSYMS(b) is larger than its current size. */ |
5f7b2142 ILT |
2891 | origb = b; |
2892 | b = shrink_block (top_stack->cur_block, top_stack->cur_st); | |
2893 | ||
2894 | /* Now run through the stack replacing pointers to the | |
2895 | original block. shrink_block has already done this | |
2896 | for the blockvector and BLOCK_FUNCTION. */ | |
2897 | for (stackp = top_stack; stackp; stackp = stackp->next) | |
2898 | { | |
2899 | if (stackp->cur_block == origb) | |
2900 | { | |
2901 | stackp->cur_block = b; | |
2902 | stackp->maxsyms = BLOCK_NSYMS (b); | |
2903 | } | |
3eaebb75 | 2904 | } |
5f7b2142 ILT |
2905 | } |
2906 | BLOCK_SYM (b, nsyms) = s; | |
bd5635a1 RP |
2907 | } |
2908 | ||
2909 | /* Add a new block B to a symtab S */ | |
2910 | ||
3eaebb75 | 2911 | static void |
5f7b2142 ILT |
2912 | add_block (b, s) |
2913 | struct block *b; | |
2914 | struct symtab *s; | |
bd5635a1 | 2915 | { |
5f7b2142 | 2916 | struct blockvector *bv = BLOCKVECTOR (s); |
bd5635a1 | 2917 | |
5f7b2142 | 2918 | bv = (struct blockvector *) xrealloc ((PTR) bv, |
6c2e7392 PS |
2919 | (sizeof (struct blockvector) |
2920 | + BLOCKVECTOR_NBLOCKS (bv) | |
2921 | * sizeof (bv->block))); | |
5f7b2142 ILT |
2922 | if (bv != BLOCKVECTOR (s)) |
2923 | BLOCKVECTOR (s) = bv; | |
bd5635a1 | 2924 | |
5f7b2142 | 2925 | BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b; |
bd5635a1 RP |
2926 | } |
2927 | ||
2928 | /* Add a new linenumber entry (LINENO,ADR) to a linevector LT. | |
2929 | MIPS' linenumber encoding might need more than one byte | |
e157305c PS |
2930 | to describe it, LAST is used to detect these continuation lines. |
2931 | ||
2932 | Combining lines with the same line number seems like a bad idea. | |
2933 | E.g: There could be a line number entry with the same line number after the | |
2934 | prologue and GDB should not ignore it (this is a better way to find | |
2935 | a prologue than mips_skip_prologue). | |
2936 | But due to the compressed line table format there are line number entries | |
2937 | for the same line which are needed to bridge the gap to the next | |
2938 | line number entry. These entries have a bogus address info with them | |
2939 | and we are unable to tell them from intended duplicate line number | |
2940 | entries. | |
2941 | This is another reason why -ggdb debugging format is preferable. */ | |
bd5635a1 | 2942 | |
3eaebb75 | 2943 | static int |
5f7b2142 ILT |
2944 | add_line (lt, lineno, adr, last) |
2945 | struct linetable *lt; | |
2946 | int lineno; | |
2947 | CORE_ADDR adr; | |
2948 | int last; | |
bd5635a1 | 2949 | { |
5f7b2142 ILT |
2950 | if (last == 0) |
2951 | last = -2; /* make sure we record first line */ | |
bd5635a1 | 2952 | |
5f7b2142 ILT |
2953 | if (last == lineno) /* skip continuation lines */ |
2954 | return lineno; | |
bd5635a1 | 2955 | |
5f7b2142 ILT |
2956 | lt->item[lt->nitems].line = lineno; |
2957 | lt->item[lt->nitems++].pc = adr << 2; | |
2958 | return lineno; | |
bd5635a1 | 2959 | } |
bd5635a1 | 2960 | \f |
84ffdec2 | 2961 | /* Sorting and reordering procedures */ |
bd5635a1 | 2962 | |
bd5635a1 RP |
2963 | /* Blocks with a smaller low bound should come first */ |
2964 | ||
84ffdec2 | 2965 | static int |
5f7b2142 | 2966 | compare_blocks (arg1, arg2) |
391ca579 | 2967 | const void *arg1, *arg2; |
bd5635a1 | 2968 | { |
5f7b2142 ILT |
2969 | register int addr_diff; |
2970 | struct block **b1 = (struct block **) arg1; | |
2971 | struct block **b2 = (struct block **) arg2; | |
2972 | ||
2973 | addr_diff = (BLOCK_START ((*b1))) - (BLOCK_START ((*b2))); | |
2974 | if (addr_diff == 0) | |
5f5341a7 | 2975 | return (BLOCK_END ((*b2))) - (BLOCK_END ((*b1))); |
5f7b2142 | 2976 | return addr_diff; |
bd5635a1 RP |
2977 | } |
2978 | ||
bd5635a1 RP |
2979 | /* Sort the blocks of a symtab S. |
2980 | Reorder the blocks in the blockvector by code-address, | |
2981 | as required by some MI search routines */ | |
2982 | ||
e072c738 | 2983 | static void |
5f7b2142 ILT |
2984 | sort_blocks (s) |
2985 | struct symtab *s; | |
bd5635a1 | 2986 | { |
5f7b2142 | 2987 | struct blockvector *bv = BLOCKVECTOR (s); |
bd5635a1 | 2988 | |
5f7b2142 ILT |
2989 | if (BLOCKVECTOR_NBLOCKS (bv) <= 2) |
2990 | { | |
2991 | /* Cosmetic */ | |
2992 | if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0) | |
2993 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0; | |
2994 | if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0) | |
2995 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0; | |
2996 | return; | |
2997 | } | |
2998 | /* | |
2999 | * This is very unfortunate: normally all functions are compiled in | |
3000 | * the order they are found, but if the file is compiled -O3 things | |
3001 | * are very different. It would be nice to find a reliable test | |
3002 | * to detect -O3 images in advance. | |
3003 | */ | |
3004 | if (BLOCKVECTOR_NBLOCKS (bv) > 3) | |
3005 | qsort (&BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK), | |
3006 | BLOCKVECTOR_NBLOCKS (bv) - FIRST_LOCAL_BLOCK, | |
3007 | sizeof (struct block *), | |
3008 | compare_blocks); | |
3009 | ||
3010 | { | |
3011 | register CORE_ADDR high = 0; | |
3012 | register int i, j = BLOCKVECTOR_NBLOCKS (bv); | |
3013 | ||
3014 | for (i = FIRST_LOCAL_BLOCK; i < j; i++) | |
3015 | if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i))) | |
3016 | high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)); | |
3017 | BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high; | |
3018 | } | |
3019 | ||
3020 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = | |
3021 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK)); | |
3022 | ||
3023 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = | |
3024 | BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); | |
3025 | BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = | |
3026 | BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); | |
bd5635a1 | 3027 | } |
bd5635a1 | 3028 | \f |
5f7b2142 | 3029 | |
bd5635a1 RP |
3030 | /* Constructor/restructor/destructor procedures */ |
3031 | ||
3032 | /* Allocate a new symtab for NAME. Needs an estimate of how many symbols | |
3033 | MAXSYMS and linenumbers MAXLINES we'll put in it */ | |
3034 | ||
4ad1963e | 3035 | static struct symtab * |
5f7b2142 ILT |
3036 | new_symtab (name, maxsyms, maxlines, objfile) |
3037 | char *name; | |
3038 | int maxsyms; | |
3039 | int maxlines; | |
3040 | struct objfile *objfile; | |
bd5635a1 | 3041 | { |
021959e2 | 3042 | struct symtab *s = allocate_symtab (name, objfile); |
bd5635a1 | 3043 | |
5f7b2142 | 3044 | LINETABLE (s) = new_linetable (maxlines); |
bd5635a1 | 3045 | |
021959e2 | 3046 | /* All symtabs must have at least two blocks */ |
5f7b2142 ILT |
3047 | BLOCKVECTOR (s) = new_bvect (2); |
3048 | BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK) = new_block (maxsyms); | |
3049 | BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) = new_block (maxsyms); | |
3050 | BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) = | |
3051 | BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); | |
bd5635a1 | 3052 | |
021959e2 | 3053 | s->free_code = free_linetable; |
bd5635a1 | 3054 | |
021959e2 | 3055 | return (s); |
bd5635a1 RP |
3056 | } |
3057 | ||
bd5635a1 RP |
3058 | /* Allocate a new partial_symtab NAME */ |
3059 | ||
3060 | static struct partial_symtab * | |
5f7b2142 ILT |
3061 | new_psymtab (name, objfile) |
3062 | char *name; | |
3063 | struct objfile *objfile; | |
bd5635a1 | 3064 | { |
021959e2 | 3065 | struct partial_symtab *psymtab; |
817bc7b8 | 3066 | |
6c2e7392 | 3067 | psymtab = allocate_psymtab (name, objfile); |
817bc7b8 | 3068 | |
021959e2 | 3069 | /* Keep a backpointer to the file's symbols */ |
bd5635a1 | 3070 | |
5f7b2142 ILT |
3071 | psymtab->read_symtab_private = ((char *) |
3072 | obstack_alloc (&objfile->psymbol_obstack, | |
3073 | sizeof (struct symloc))); | |
6c2e7392 PS |
3074 | memset ((PTR) psymtab->read_symtab_private, 0, sizeof (struct symloc)); |
3075 | CUR_BFD (psymtab) = cur_bfd; | |
817bc7b8 | 3076 | |
021959e2 JG |
3077 | /* The way to turn this into a symtab is to call... */ |
3078 | psymtab->read_symtab = mipscoff_psymtab_to_symtab; | |
3079 | return (psymtab); | |
bd5635a1 RP |
3080 | } |
3081 | ||
3082 | ||
84ffdec2 | 3083 | /* Allocate a linetable array of the given SIZE. Since the struct |
817bc7b8 | 3084 | already includes one item, we subtract one when calculating the |
84ffdec2 | 3085 | proper size to allocate. */ |
bd5635a1 | 3086 | |
7e258d18 | 3087 | static struct linetable * |
5f7b2142 ILT |
3088 | new_linetable (size) |
3089 | int size; | |
bd5635a1 | 3090 | { |
5f7b2142 | 3091 | struct linetable *l; |
bd5635a1 | 3092 | |
5f7b2142 ILT |
3093 | size = (size - 1) * sizeof (l->item) + sizeof (struct linetable); |
3094 | l = (struct linetable *) xmalloc (size); | |
3095 | l->nitems = 0; | |
3096 | return l; | |
bd5635a1 RP |
3097 | } |
3098 | ||
3099 | /* Oops, too big. Shrink it. This was important with the 2.4 linetables, | |
84ffdec2 JG |
3100 | I am not so sure about the 3.4 ones. |
3101 | ||
3102 | Since the struct linetable already includes one item, we subtract one when | |
3103 | calculating the proper size to allocate. */ | |
bd5635a1 | 3104 | |
7e258d18 | 3105 | static struct linetable * |
5f7b2142 ILT |
3106 | shrink_linetable (lt) |
3107 | struct linetable *lt; | |
bd5635a1 | 3108 | { |
bd5635a1 | 3109 | |
5f7b2142 | 3110 | return (struct linetable *) xrealloc ((PTR) lt, |
6c2e7392 PS |
3111 | (sizeof (struct linetable) |
3112 | + ((lt->nitems - 1) | |
3113 | * sizeof (lt->item)))); | |
bd5635a1 RP |
3114 | } |
3115 | ||
3116 | /* Allocate and zero a new blockvector of NBLOCKS blocks. */ | |
3117 | ||
4ad1963e | 3118 | static struct blockvector * |
5f7b2142 ILT |
3119 | new_bvect (nblocks) |
3120 | int nblocks; | |
bd5635a1 | 3121 | { |
5f7b2142 ILT |
3122 | struct blockvector *bv; |
3123 | int size; | |
bd5635a1 | 3124 | |
5f7b2142 ILT |
3125 | size = sizeof (struct blockvector) + nblocks * sizeof (struct block *); |
3126 | bv = (struct blockvector *) xzalloc (size); | |
bd5635a1 | 3127 | |
5f7b2142 | 3128 | BLOCKVECTOR_NBLOCKS (bv) = nblocks; |
bd5635a1 | 3129 | |
5f7b2142 | 3130 | return bv; |
bd5635a1 RP |
3131 | } |
3132 | ||
3133 | /* Allocate and zero a new block of MAXSYMS symbols */ | |
3134 | ||
4ad1963e | 3135 | static struct block * |
5f7b2142 ILT |
3136 | new_block (maxsyms) |
3137 | int maxsyms; | |
bd5635a1 | 3138 | { |
5f7b2142 | 3139 | int size = sizeof (struct block) + (maxsyms - 1) * sizeof (struct symbol *); |
bd5635a1 | 3140 | |
5f7b2142 | 3141 | return (struct block *) xzalloc (size); |
bd5635a1 RP |
3142 | } |
3143 | ||
3eaebb75 SG |
3144 | /* Ooops, too big. Shrink block B in symtab S to its minimal size. |
3145 | Shrink_block can also be used by add_symbol to grow a block. */ | |
bd5635a1 RP |
3146 | |
3147 | static struct block * | |
5f7b2142 ILT |
3148 | shrink_block (b, s) |
3149 | struct block *b; | |
3150 | struct symtab *s; | |
bd5635a1 | 3151 | { |
5f7b2142 ILT |
3152 | struct block *new; |
3153 | struct blockvector *bv = BLOCKVECTOR (s); | |
3154 | int i; | |
bd5635a1 | 3155 | |
5f7b2142 | 3156 | /* Just reallocate it and fix references to the old one */ |
bd5635a1 | 3157 | |
6c2e7392 PS |
3158 | new = (struct block *) xrealloc ((PTR) b, |
3159 | (sizeof (struct block) | |
3160 | + ((BLOCK_NSYMS (b) - 1) | |
3161 | * sizeof (struct symbol *)))); | |
bd5635a1 | 3162 | |
5f7b2142 | 3163 | /* Should chase pointers to old one. Fortunately, that`s just |
bd5635a1 | 3164 | the block`s function and inferior blocks */ |
5f7b2142 ILT |
3165 | if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b) |
3166 | SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new; | |
3167 | for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++) | |
3168 | if (BLOCKVECTOR_BLOCK (bv, i) == b) | |
3169 | BLOCKVECTOR_BLOCK (bv, i) = new; | |
3170 | else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) == b) | |
3171 | BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) = new; | |
3172 | return new; | |
bd5635a1 RP |
3173 | } |
3174 | ||
3175 | /* Create a new symbol with printname NAME */ | |
3176 | ||
4ad1963e | 3177 | static struct symbol * |
5f7b2142 ILT |
3178 | new_symbol (name) |
3179 | char *name; | |
bd5635a1 | 3180 | { |
6c2e7392 PS |
3181 | struct symbol *s = ((struct symbol *) |
3182 | obstack_alloc (¤t_objfile->symbol_obstack, | |
3183 | sizeof (struct symbol))); | |
bd5635a1 | 3184 | |
5f7b2142 ILT |
3185 | memset ((PTR) s, 0, sizeof (*s)); |
3186 | SYMBOL_NAME (s) = name; | |
3187 | return s; | |
bd5635a1 RP |
3188 | } |
3189 | ||
3190 | /* Create a new type with printname NAME */ | |
3191 | ||
4ad1963e | 3192 | static struct type * |
5f7b2142 ILT |
3193 | new_type (name) |
3194 | char *name; | |
bd5635a1 | 3195 | { |
5f7b2142 | 3196 | struct type *t; |
bd5635a1 | 3197 | |
5f7b2142 ILT |
3198 | t = alloc_type (current_objfile); |
3199 | TYPE_NAME (t) = name; | |
6c2e7392 | 3200 | TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default; |
5f7b2142 | 3201 | return t; |
bd5635a1 | 3202 | } |
bd5635a1 | 3203 | \f |
5f7b2142 | 3204 | |
bd5635a1 RP |
3205 | /* Things used for calling functions in the inferior. |
3206 | These functions are exported to our companion | |
7e258d18 | 3207 | mips-tdep.c file and are here because they play |
bd5635a1 RP |
3208 | with the symbol-table explicitly. */ |
3209 | ||
bd5635a1 RP |
3210 | /* Sigtramp: make sure we have all the necessary information |
3211 | about the signal trampoline code. Since the official code | |
3212 | from MIPS does not do so, we make up that information ourselves. | |
3213 | If they fix the library (unlikely) this code will neutralize itself. */ | |
3214 | ||
d747e0af | 3215 | static void |
5f7b2142 | 3216 | fixup_sigtramp () |
bd5635a1 | 3217 | { |
5f7b2142 ILT |
3218 | struct symbol *s; |
3219 | struct symtab *st; | |
3220 | struct block *b, *b0; | |
bd5635a1 | 3221 | |
5f7b2142 | 3222 | sigtramp_address = -1; |
bd5635a1 | 3223 | |
7cf92dd2 PS |
3224 | /* We have to handle the following cases here: |
3225 | a) The Mips library has a sigtramp label within sigvec. | |
3226 | b) Irix has a _sigtramp which we want to use, but it also has sigvec. */ | |
5f7b2142 | 3227 | s = lookup_symbol ("sigvec", 0, VAR_NAMESPACE, 0, NULL); |
7cf92dd2 | 3228 | if (s != 0) |
5f7b2142 ILT |
3229 | { |
3230 | b0 = SYMBOL_BLOCK_VALUE (s); | |
5f7b2142 ILT |
3231 | s = lookup_symbol ("sigtramp", b0, VAR_NAMESPACE, 0, NULL); |
3232 | } | |
7cf92dd2 PS |
3233 | if (s == 0) |
3234 | { | |
3235 | /* No sigvec or no sigtramp inside sigvec, try _sigtramp. */ | |
3236 | s = lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE, 0, NULL); | |
3237 | } | |
4ad1963e | 3238 | |
5f7b2142 ILT |
3239 | /* But maybe this program uses its own version of sigvec */ |
3240 | if (s == 0) | |
3241 | return; | |
bd5635a1 | 3242 | |
5f7b2142 ILT |
3243 | /* Did we or MIPSco fix the library ? */ |
3244 | if (SYMBOL_CLASS (s) == LOC_BLOCK) | |
3245 | { | |
3246 | sigtramp_address = BLOCK_START (SYMBOL_BLOCK_VALUE (s)); | |
3247 | sigtramp_end = BLOCK_END (SYMBOL_BLOCK_VALUE (s)); | |
3248 | return; | |
3249 | } | |
bd5635a1 | 3250 | |
5f7b2142 ILT |
3251 | sigtramp_address = SYMBOL_VALUE (s); |
3252 | sigtramp_end = sigtramp_address + 0x88; /* black magic */ | |
3253 | ||
3254 | /* But what symtab does it live in ? */ | |
3255 | st = find_pc_symtab (SYMBOL_VALUE (s)); | |
3256 | ||
3257 | /* | |
3258 | * Ok, there goes the fix: turn it into a procedure, with all the | |
3259 | * needed info. Note we make it a nested procedure of sigvec, | |
3260 | * which is the way the (assembly) code is actually written. | |
3261 | */ | |
3262 | SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; | |
3263 | SYMBOL_CLASS (s) = LOC_BLOCK; | |
3264 | SYMBOL_TYPE (s) = init_type (TYPE_CODE_FUNC, 4, 0, (char *) NULL, | |
3265 | (struct objfile *) NULL); | |
3266 | TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = builtin_type_void; | |
3267 | ||
3268 | /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */ | |
3269 | b = new_block (1); | |
3270 | SYMBOL_BLOCK_VALUE (s) = b; | |
3271 | BLOCK_START (b) = sigtramp_address; | |
3272 | BLOCK_END (b) = sigtramp_end; | |
3273 | BLOCK_FUNCTION (b) = s; | |
3274 | BLOCK_SUPERBLOCK (b) = BLOCK_SUPERBLOCK (b0); | |
3275 | add_block (b, st); | |
3276 | sort_blocks (st); | |
3277 | ||
3278 | /* Make a MIPS_EFI_SYMBOL_NAME entry for it */ | |
3279 | { | |
3280 | struct mips_extra_func_info *e = | |
3281 | ((struct mips_extra_func_info *) | |
3282 | xzalloc (sizeof (struct mips_extra_func_info))); | |
3283 | ||
3284 | e->numargs = 0; /* the kernel thinks otherwise */ | |
3285 | /* align_longword(sigcontext + SIGFRAME) */ | |
3286 | e->pdr.frameoffset = 0x150; | |
3287 | e->pdr.framereg = SP_REGNUM; | |
e157305c PS |
3288 | /* read_next_frame_reg provides the true pc at the time of signal */ |
3289 | e->pdr.pcreg = PC_REGNUM; | |
5f7b2142 ILT |
3290 | e->pdr.regmask = -2; |
3291 | e->pdr.regoffset = -(41 * sizeof (int)); | |
3292 | e->pdr.fregmask = -1; | |
e157305c | 3293 | e->pdr.fregoffset = -(7 * sizeof (int)); |
5f7b2142 | 3294 | e->pdr.isym = (long) s; |
579f0258 | 3295 | e->pdr.adr = sigtramp_address; |
5f7b2142 ILT |
3296 | |
3297 | current_objfile = st->objfile; /* Keep new_symbol happy */ | |
3298 | s = new_symbol (MIPS_EFI_SYMBOL_NAME); | |
3299 | SYMBOL_VALUE (s) = (int) e; | |
3300 | SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE; | |
3301 | SYMBOL_CLASS (s) = LOC_CONST; | |
3302 | SYMBOL_TYPE (s) = builtin_type_void; | |
3303 | current_objfile = NULL; | |
3304 | } | |
bd5635a1 | 3305 | |
5f7b2142 | 3306 | BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s; |
bd5635a1 | 3307 | } |
dac4929a SG |
3308 | |
3309 | ||
3310 | /* Fake up identical offsets for all sections. */ | |
3311 | ||
3312 | struct section_offsets * | |
3313 | mipscoff_symfile_offsets (objfile, addr) | |
3314 | struct objfile *objfile; | |
3315 | CORE_ADDR addr; | |
3316 | { | |
3317 | struct section_offsets *section_offsets; | |
3318 | int i; | |
3319 | ||
5f7b2142 ILT |
3320 | section_offsets = ((struct section_offsets *) |
3321 | obstack_alloc (&objfile->psymbol_obstack, | |
3322 | (sizeof (struct section_offsets) | |
3323 | + (sizeof (section_offsets->offsets) | |
3324 | * (SECT_OFF_MAX - 1))))); | |
dac4929a SG |
3325 | |
3326 | for (i = 0; i < SECT_OFF_MAX; i++) | |
3327 | ANOFFSET (section_offsets, i) = addr; | |
3328 | ||
3329 | return section_offsets; | |
3330 | } | |
bd5635a1 RP |
3331 | \f |
3332 | /* Initialization */ | |
3333 | ||
80d68b1d FF |
3334 | static struct sym_fns ecoff_sym_fns = |
3335 | { | |
5f7b2142 ILT |
3336 | "ecoff", /* sym_name: name or name prefix of BFD target type */ |
3337 | 5, /* sym_namelen: number of significant sym_name chars */ | |
3338 | mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */ | |
3339 | mipscoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ | |
3340 | mipscoff_symfile_read, /* sym_read: read a symbol file into symtab */ | |
3341 | mipscoff_symfile_finish, /* sym_finish: finished with file, cleanup */ | |
3342 | mipscoff_symfile_offsets, /* sym_offsets: dummy FIXME til implem sym reloc */ | |
3343 | NULL /* next: pointer to next struct sym_fns */ | |
80d68b1d FF |
3344 | }; |
3345 | ||
bd5635a1 | 3346 | |
4ad1963e | 3347 | void |
bd5635a1 RP |
3348 | _initialize_mipsread () |
3349 | { | |
5f7b2142 ILT |
3350 | add_symtab_fns (&ecoff_sym_fns); |
3351 | ||
3352 | /* Missing basic types */ | |
3353 | ||
3354 | builtin_type_string = | |
3355 | init_type (TYPE_CODE_STRING, | |
3356 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3357 | 0, "string", | |
3358 | (struct objfile *) NULL); | |
3359 | builtin_type_complex = | |
3360 | init_type (TYPE_CODE_FLT, | |
3361 | TARGET_COMPLEX_BIT / TARGET_CHAR_BIT, | |
3362 | 0, "complex", | |
3363 | (struct objfile *) NULL); | |
3364 | builtin_type_double_complex = | |
3365 | init_type (TYPE_CODE_FLT, | |
3366 | TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, | |
3367 | 0, "double complex", | |
3368 | (struct objfile *) NULL); | |
3369 | builtin_type_fixed_dec = | |
3370 | init_type (TYPE_CODE_INT, | |
3371 | TARGET_INT_BIT / TARGET_CHAR_BIT, | |
3372 | 0, "fixed decimal", | |
3373 | (struct objfile *) NULL); | |
3374 | builtin_type_float_dec = | |
3375 | init_type (TYPE_CODE_FLT, | |
3376 | TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, | |
3377 | 0, "floating decimal", | |
3378 | (struct objfile *) NULL); | |
bd5635a1 | 3379 | } |