1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major
4 work by Per Bothner and John Gilmore at Cygnus Support.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* This module provides three functions: mipscoff_symfile_init,
23 which initializes to read a symbol file; mipscoff_new_init, which
24 discards existing cached information when all symbols are being
25 discarded; and mipscoff_symfile_read, which reads a symbol table
28 mipscoff_symfile_read only does the minimum work necessary for letting the
29 user "name" things symbolically; it does not read the entire symtab.
30 Instead, it reads the external and static symbols and puts them in partial
31 symbol tables. When more extensive information is requested of a
32 file, the corresponding partial symbol table is mutated into a full
33 fledged symbol table by going back and reading the symbols
34 for real. mipscoff_psymtab_to_symtab() is called indirectly through
35 a pointer in the psymtab to do this.
37 ECOFF symbol tables are mostly written in the byte order of the
38 target machine. However, one section of the table (the auxiliary
39 symbol information) is written in the host byte order. There is a
40 bit in the other symbol info which describes which host byte order
41 was used. ECOFF thereby takes the trophy from Intel `b.out' for
42 the most brain-dead adaptation of a file format to byte order.
44 This module can read all four of the known byte-order combinations,
45 on any type of host. However, it does make (and check) the assumption
46 that the external form of a symbol table structure (on disk)
47 occupies the same number of bytes as the internal form (in a struct).
48 Fixing this is possible but requires larger structural changes. */
50 #define TM_FILE_OVERRIDE
60 #include "stabsread.h"
61 #include "complaints.h"
64 #include <sys/types.h>
69 #include <sys/param.h>
74 #include "gdb-stabs.h"
76 #include "coff/mips.h" /* COFF-like aspects of ecoff files */
77 #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */
79 #include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */
80 #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
81 #include "aout/aout64.h"
82 #include "aout/stab_gnu.h" /* STABS information */
83 #include "expression.h"
84 #include "language.h" /* Needed inside partial-stab.h */
88 struct external_filehdr f
;
89 struct external_aouthdr a
;
92 /* Each partial symbol table entry contains a pointer to private data for the
93 read_symtab() function to use when expanding a partial symbol table entry
94 to a full symbol table entry.
96 For mipsread this structure contains the index of the FDR that this psymtab
97 represents and a pointer to the symbol table header HDRR from the symbol
98 file that the psymtab was created from. */
100 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
101 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
102 #define CUR_HDR(p) (PST_PRIVATE(p)->cur_hdr)
108 EXTR
**extern_tab
; /* Pointer to external symbols for this file. */
109 int extern_count
; /* Size of extern_tab. */
112 /* Things we import explicitly from other modules */
114 extern int info_verbose
;
116 /* Various complaints about symbol reading that don't abort the process */
118 struct complaint bad_file_number_complaint
=
119 {"bad file number %d", 0, 0};
121 struct complaint index_complaint
=
122 {"bad aux index at symbol %s", 0, 0};
124 struct complaint aux_index_complaint
=
125 {"bad proc end in aux found from symbol %s", 0, 0};
127 struct complaint block_index_complaint
=
128 {"bad aux index at block symbol %s", 0, 0};
130 struct complaint unknown_ext_complaint
=
131 {"unknown external symbol %s", 0, 0};
133 struct complaint unknown_sym_complaint
=
134 {"unknown local symbol %s", 0, 0};
136 struct complaint unknown_st_complaint
=
137 {"with type %d", 0, 0};
139 struct complaint block_overflow_complaint
=
140 {"block containing %s overfilled", 0, 0};
142 struct complaint basic_type_complaint
=
143 {"cannot map MIPS basic type 0x%x", 0, 0};
145 struct complaint unknown_type_qual_complaint
=
146 {"unknown type qualifier 0x%x", 0, 0};
148 struct complaint array_bitsize_complaint
=
149 {"size of array target type not known, assuming %d bits", 0, 0};
151 struct complaint bad_tag_guess_complaint
=
152 {"guessed tag type of %s incorrectly", 0, 0};
154 struct complaint block_member_complaint
=
155 {"declaration block contains unhandled symbol type %d", 0, 0};
157 struct complaint stEnd_complaint
=
158 {"stEnd with storage class %d not handled", 0, 0};
160 struct complaint unknown_mips_symtype_complaint
=
161 {"unknown symbol type 0x%x", 0, 0};
163 struct complaint stab_unknown_complaint
=
164 {"unknown stabs symbol %s", 0, 0};
166 struct complaint pdr_for_nonsymbol_complaint
=
167 {"PDR for %s, but no symbol", 0, 0};
169 struct complaint pdr_static_symbol_complaint
=
170 {"can't handle PDR for static proc at 0x%x", 0, 0};
172 /* Macros and extra defs */
174 /* Already-parsed symbols are marked specially */
176 #define stParsed stType
178 /* Puns: hard to find whether -g was used and how */
180 #define MIN_GLEVEL GLEVEL_0
181 #define compare_glevel(a,b) \
182 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
183 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
185 /* When looking at .o files, avoid tripping over zero pointers.
186 FIXME; places that use this should be fixed to convert from
187 external to internal format, rather than examining in-place. */
189 #define UNSAFE_DATA_ADDR(p) ((p) == 0)
191 /* Things that really are local to this module */
193 /* Remember what we deduced to be the source language of this psymtab. */
195 static enum language psymtab_language
= language_unknown
;
197 /* MIPS symtab header for the current file */
199 static HDRR
*cur_hdr
;
201 /* Pointer to current file decriptor record, and its index */
206 /* Index of current symbol */
210 /* Note how much "debuggable" this image is. We would like
211 to see at least one FDR with full symbols */
216 /* When examining .o files, report on undefined symbols */
218 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
220 /* Pseudo symbol to use when putting stabs into the symbol table. */
222 static char stabs_symbol
[] = STABS_SYMBOL
;
224 /* Extra builtin types */
226 struct type
*builtin_type_complex
;
227 struct type
*builtin_type_double_complex
;
228 struct type
*builtin_type_fixed_dec
;
229 struct type
*builtin_type_float_dec
;
230 struct type
*builtin_type_string
;
232 /* Forward declarations */
235 fixup_symtab
PARAMS ((HDRR
*, char *, file_ptr
, bfd
*));
238 read_mips_symtab
PARAMS ((struct objfile
*, struct section_offsets
*));
241 read_the_mips_symtab
PARAMS ((bfd
*, CORE_ADDR
*));
244 upgrade_type
PARAMS ((struct type
**, int, union aux_ext
*, int));
247 parse_partial_symbols
PARAMS ((int, struct objfile
*,
248 struct section_offsets
*));
251 cross_ref
PARAMS ((union aux_ext
*, struct type
**, enum type_code
, char **,
255 fixup_sigtramp
PARAMS ((void));
257 static struct symbol
*
258 new_symbol
PARAMS ((char *));
261 new_type
PARAMS ((char *));
263 static struct block
*
264 new_block
PARAMS ((int));
266 static struct symtab
*
267 new_symtab
PARAMS ((char *, int, int, struct objfile
*));
269 static struct linetable
*
270 new_linetable
PARAMS ((int));
272 static struct blockvector
*
273 new_bvect
PARAMS ((int));
276 parse_type
PARAMS ((union aux_ext
*, int *, int));
278 static struct symbol
*
279 mylookup_symbol
PARAMS ((char *, struct block
*, enum namespace,
280 enum address_class
));
282 static struct block
*
283 shrink_block
PARAMS ((struct block
*, struct symtab
*));
286 xzalloc
PARAMS ((unsigned int));
289 sort_blocks
PARAMS ((struct symtab
*));
292 compare_blocks
PARAMS ((const void *, const void *));
294 static struct partial_symtab
*
295 new_psymtab
PARAMS ((char *, struct objfile
*));
298 static struct partial_symtab
*
299 parse_fdr
PARAMS ((int, int, struct objfile
*));
303 psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*, char *));
306 add_block
PARAMS ((struct block
*, struct symtab
*));
309 add_symbol
PARAMS ((struct symbol
*, struct block
*));
312 add_line
PARAMS ((struct linetable
*, int, CORE_ADDR
, int));
314 static struct linetable
*
315 shrink_linetable
PARAMS ((struct linetable
*));
318 mips_next_symbol_text
PARAMS ((void));
320 /* Things we export to other modules */
322 /* Address bounds for the signal trampoline in inferior, if any */
323 /* FIXME: Nothing really seems to use this. Why is it here? */
325 CORE_ADDR sigtramp_address
, sigtramp_end
;
328 mipscoff_new_init (ignore
)
329 struct objfile
*ignore
;
334 mipscoff_symfile_init (objfile
)
335 struct objfile
*objfile
;
337 if (objfile
->sym_private
!= NULL
)
339 mfree (objfile
->md
, objfile
->sym_private
);
341 objfile
->sym_private
= NULL
;
345 mipscoff_symfile_read (objfile
, section_offsets
, mainline
)
346 struct objfile
*objfile
;
347 struct section_offsets
*section_offsets
;
350 init_minimal_symbol_collection ();
351 make_cleanup (discard_minimal_symbols
, 0);
353 /* Now that the executable file is positioned at symbol table,
354 process it and define symbols accordingly. */
356 read_mips_symtab (objfile
, section_offsets
);
358 /* Install any minimal symbols that have been collected as the current
359 minimal symbols for this objfile. */
361 install_minimal_symbols (objfile
);
364 /* Perform any local cleanups required when we are done with a particular
365 objfile. I.E, we are in the process of discarding all symbol information
366 for an objfile, freeing up all memory held for it, and unlinking the
367 objfile struct from the global list of known objfiles. */
370 mipscoff_symfile_finish (objfile
)
371 struct objfile
*objfile
;
373 if (objfile
->sym_private
!= NULL
)
375 mfree (objfile
->md
, objfile
->sym_private
);
378 /* If we have a file symbol header lying around, blow it away. */
382 free ((PTR
) cur_hdr
);
387 /* Allocate zeroed memory */
393 PTR p
= xmalloc (size
);
399 /* Exported procedure: Builds a symtab from the PST partial one.
400 Restores the environment in effect when PST was created, delegates
401 most of the work to an ancillary procedure, and sorts
402 and reorders the symtab list at the end */
405 mipscoff_psymtab_to_symtab (pst
)
406 struct partial_symtab
*pst
;
414 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
417 /* Restore the header and list of pending typedefs */
418 cur_hdr
= CUR_HDR (pst
);
420 next_symbol_text_func
= mips_next_symbol_text
;
422 psymtab_to_symtab_1 (pst
, pst
->filename
);
424 /* Match with global symbols. This only needs to be done once,
425 after all of the symtabs and dependencies have been read in. */
426 scan_file_globals (pst
->objfile
);
429 printf_filtered ("done.\n");
432 /* Exported procedure: Is PC in the signal trampoline code */
435 in_sigtramp (pc
, ignore
)
437 char *ignore
; /* function name */
439 if (sigtramp_address
== 0)
441 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
444 /* File-level interface functions */
446 /* Read the symtab information from file ABFD into memory. Also,
447 return address just past end of our text segment in *END_OF_TEXT_SEGP. */
450 read_the_mips_symtab (abfd
, end_of_text_segp
)
452 CORE_ADDR
*end_of_text_segp
;
454 int stsize
, st_hdrsize
;
456 struct hdr_ext hdr_ext
;
458 /* Header for executable/object file we read symbols from */
459 struct coff_exec filhdr
;
462 /* We need some info from the initial headers */
463 val
= bfd_seek (abfd
, (file_ptr
) 0, L_SET
);
464 val
= bfd_read ((PTR
) & filhdr
, sizeof filhdr
, 1, abfd
);
466 if (end_of_text_segp
)
468 bfd_h_get_32 (abfd
, filhdr
.a
.text_start
) +
469 bfd_h_get_32 (abfd
, filhdr
.a
.tsize
);
471 /* Find and read the symbol table header */
472 st_hdrsize
= bfd_h_get_32 (abfd
, filhdr
.f
.f_nsyms
);
473 st_filptr
= bfd_h_get_32 (abfd
, filhdr
.f
.f_symptr
);
477 bfd_seek (abfd
, st_filptr
, L_SET
);
478 if (st_hdrsize
!= sizeof (hdr_ext
))
479 { /* Profanity check */
480 error ("Wrong header size: %d, not %d", st_hdrsize
,
483 if (bfd_read ((PTR
) & hdr_ext
, st_hdrsize
, 1, abfd
) != st_hdrsize
)
485 ecoff_swap_hdr_in (abfd
, &hdr_ext
, &st_hdr
);
487 /* Find out how large the symbol table is */
488 stsize
= ((st_hdr
.cbExtOffset
- (st_filptr
+ st_hdrsize
))
489 + st_hdr
.iextMax
* cbEXTR
);
491 /* Allocate space for the symbol table. Read it in. */
492 cur_hdr
= (HDRR
*) xmalloc (stsize
+ st_hdrsize
);
494 memcpy ((PTR
) cur_hdr
, (PTR
) & hdr_ext
, st_hdrsize
);
495 if (bfd_read ((char *) cur_hdr
+ st_hdrsize
, stsize
, 1, abfd
) != stsize
)
498 /* Fixup file_pointers in it */
499 fixup_symtab (cur_hdr
, (char *) cur_hdr
+ st_hdrsize
,
500 st_filptr
+ st_hdrsize
, abfd
);
504 error ("Short read on %s", bfd_get_filename (abfd
));
508 /* Turn all file-relative pointers in the symtab described by HDR
509 into memory pointers, given that the symtab itself is located
510 at DATA in memory and F_PTR in the file.
512 Byte-swap all the data structures, in place, while we are at it --
513 except AUX entries, which we leave in their original byte order.
514 They will be swapped as they are used instead. (FIXME: we ought to
515 do all the data structures that way.) */
518 fixup_symtab (hdr
, data
, f_ptr
, abfd
)
529 struct rfd_ext
*rbase
;
531 /* This function depends on the external and internal forms
532 of the MIPS symbol table taking identical space. Check this
533 assumption at compile-time.
534 DO NOT DELETE THESE ENTRIES, OR COMMENT THEM OUT, JUST BECAUSE SOME
535 "LINT" OR COMPILER THINKS THEY ARE UNUSED! Thank you. */
536 static check_hdr1
[1 + sizeof (struct hdr_ext
) - sizeof (HDRR
)] = {0};
537 static check_hdr2
[1 + sizeof (HDRR
) - sizeof (struct hdr_ext
)] = {0};
538 static check_fdr1
[1 + sizeof (struct fdr_ext
) - sizeof (FDR
)] = {0};
539 static check_fdr2
[1 + sizeof (FDR
) - sizeof (struct fdr_ext
)] = {0};
540 static check_pdr1
[1 + sizeof (struct pdr_ext
) - sizeof (PDR
)] = {0};
541 static check_pdr2
[1 + sizeof (PDR
) - sizeof (struct pdr_ext
)] = {0};
542 static check_sym1
[1 + sizeof (struct sym_ext
) - sizeof (SYMR
)] = {0};
543 static check_sym2
[1 + sizeof (SYMR
) - sizeof (struct sym_ext
)] = {0};
544 static check_ext1
[1 + sizeof (struct ext_ext
) - sizeof (EXTR
)] = {0};
545 static check_ext2
[1 + sizeof (EXTR
) - sizeof (struct ext_ext
)] = {0};
546 static check_rfd1
[1 + sizeof (struct rfd_ext
) - sizeof (RFDT
)] = {0};
547 static check_rfd2
[1 + sizeof (RFDT
) - sizeof (struct rfd_ext
)] = {0};
549 /* Swap in the header record. */
550 ecoff_swap_hdr_in (abfd
, hdr
, hdr
);
553 * These fields are useless (and empty) by now:
554 * hdr->cbDnOffset, hdr->cbOptOffset
555 * We use them for other internal purposes.
558 hdr
->cbOptOffset
= 0;
561 if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr);
575 /* Fix all the RFD's. */
576 rbase
= (struct rfd_ext
*) (hdr
->cbRfdOffset
);
577 for (i
= 0; i
< hdr
->crfd
; i
++)
579 ecoff_swap_rfd_in (abfd
, rbase
+ i
, (pRFDT
) rbase
+ i
);
582 /* Fix all string pointers inside the symtab, and
583 the FDR records. Also fix other miscellany. */
585 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
587 register unsigned code_offset
;
589 /* Header itself, and strings */
590 fh
= (FDR
*) (hdr
->cbFdOffset
) + f_idx
;
592 /* Swap in the FDR */
593 ecoff_swap_fdr_in (abfd
, fh
, fh
);
595 fh
->issBase
+= hdr
->cbSsOffset
;
597 fh
->rss
= (long) fh
->rss
+ fh
->issBase
;
600 fh
->isymBase
= (int) ((SYMR
*) (hdr
->cbSymOffset
) + fh
->isymBase
);
602 /* FIXME! Probably don't want to do this here! */
603 for (s_idx
= 0; s_idx
< fh
->csym
; s_idx
++)
605 sh
= (SYMR
*) fh
->isymBase
+ s_idx
;
606 ecoff_swap_sym_in (abfd
, sh
, sh
);
608 sh
->iss
= (long) sh
->iss
+ fh
->issBase
;
614 /* cannot fix fh->ipdFirst because it is a short */
615 #define IPDFIRST(h,fh) \
616 ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR))
618 /* Optional symbols (actually used for partial_symtabs) */
624 fh
->iauxBase
= hdr
->cbAuxOffset
+ fh
->iauxBase
* sizeof (union aux_ext
);
625 /* Relative file descriptor table */
626 fh
->rfdBase
= hdr
->cbRfdOffset
+ fh
->rfdBase
* sizeof (RFDT
);
630 fh
->cbLineOffset
+= hdr
->cbLineOffset
;
632 /* Procedure symbols. (XXX This should be done later) */
633 code_offset
= fh
->adr
;
634 for (s_idx
= 0; s_idx
< fh
->cpd
; s_idx
++)
636 unsigned name
, only_ext
;
638 pr
= (PDR
*) (IPDFIRST (hdr
, fh
)) + s_idx
;
639 ecoff_swap_pdr_in (abfd
, pr
, pr
);
641 /* Simple rule to find files linked "-x" */
642 only_ext
= fh
->rss
== -1;
647 /* static function */
653 name
= hdr
->cbExtOffset
+ pr
->isym
* sizeof (EXTR
);
654 sh
= &((EXTR
*) name
)->asym
;
660 sh
= (SYMR
*) fh
->isymBase
+ pr
->isym
;
661 /* Included code ? */
662 if (s_idx
== 0 && pr
->adr
!= 0)
663 code_offset
-= pr
->adr
;
666 /* Turn index into a pointer */
667 pr
->isym
= (long) sh
;
669 /* Fix line numbers */
670 pr
->cbLineOffset
+= fh
->cbLineOffset
;
672 /* Relocate address */
674 pr
->adr
+= code_offset
;
678 /* External symbols: swap in, and fix string */
679 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++)
681 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
682 ecoff_swap_ext_in (abfd
, esh
, esh
);
683 esh
->asym
.iss
= esh
->asym
.iss
+ hdr
->cbSsExtOffset
;
688 /* Find a file descriptor given its index RF relative to a file CF */
696 f
= (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
697 /* Object files do not have the RFD table, all refs are absolute */
699 return (FDR
*) (cur_hdr
->cbFdOffset
) + rf
;
700 cf
= *((pRFDT
) f
->rfdBase
+ rf
);
701 return (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
704 /* Return a safer print NAME for a file descriptor */
710 if (name
== (char *) -1)
711 return "<stripped file>";
712 if (UNSAFE_DATA_ADDR (name
))
718 /* Read in and parse the symtab of the file OBJFILE. Symbols from
719 different sections are relocated via the SECTION_OFFSETS. */
722 read_mips_symtab (objfile
, section_offsets
)
723 struct objfile
*objfile
;
724 struct section_offsets
*section_offsets
;
726 CORE_ADDR end_of_text_seg
;
728 read_the_mips_symtab (objfile
->obfd
, &end_of_text_seg
);
730 parse_partial_symbols (end_of_text_seg
, objfile
, section_offsets
);
734 * Check to make sure file was compiled with -g.
735 * If not, warn the user of this limitation.
737 if (compare_glevel (max_glevel
, GLEVEL_2
) < 0)
739 if (max_gdbinfo
== 0)
741 "\n%s not compiled with -g, debugging support is limited.\n",
744 "You should compile with -g2 or -g3 for best debugging support.\n");
750 /* Local utilities */
752 /* Map of FDR indexes to partial symtabs */
756 struct partial_symtab
*pst
; /* the psymtab proper */
757 int n_globals
; /* exported globals (external symbols) */
758 int globals_offset
; /* cumulative */
762 /* Utility stack, used to nest procedures and blocks properly.
763 It is a doubly linked list, to avoid too many alloc/free.
764 Since we might need it quite a few times it is NOT deallocated
767 static struct parse_stack
769 struct parse_stack
*next
, *prev
;
770 struct symtab
*cur_st
; /* Current symtab. */
771 struct block
*cur_block
; /* Block in it. */
772 int blocktype
; /* What are we parsing. */
773 int maxsyms
; /* Max symbols in this block. */
774 struct type
*cur_type
; /* Type we parse fields for. */
775 int cur_field
; /* Field number in cur_type. */
776 int procadr
; /* Start addres of this procedure */
777 int numargs
; /* Its argument count */
778 } *top_stack
; /* Top stack ptr */
781 /* Enter a new lexical context */
786 struct parse_stack
*new;
788 /* Reuse frames if possible */
789 if (top_stack
&& top_stack
->prev
)
790 new = top_stack
->prev
;
792 new = (struct parse_stack
*) xzalloc (sizeof (struct parse_stack
));
793 /* Initialize new frame with previous content */
796 register struct parse_stack
*prev
= new->prev
;
799 top_stack
->prev
= new;
801 new->next
= top_stack
;
806 /* Exit a lexical context */
814 top_stack
= top_stack
->next
;
818 /* Cross-references might be to things we haven't looked at
819 yet, e.g. type references. To avoid too many type
820 duplications we keep a quick fixup table, an array
821 of lists of references indexed by file descriptor */
823 static struct mips_pending
825 struct mips_pending
*next
; /* link */
826 SYMR
*s
; /* the symbol */
827 struct type
*t
; /* its partial type descriptor */
831 /* Check whether we already saw symbol SH in file FH as undefined */
833 static struct mips_pending
*
834 is_pending_symbol (fh
, sh
)
838 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
839 register struct mips_pending
*p
;
841 /* Linear search is ok, list is typically no more than 10 deep */
842 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
848 /* Add a new undef symbol SH of type T */
851 add_pending (fh
, sh
, t
)
856 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
857 struct mips_pending
*p
= is_pending_symbol (fh
, sh
);
859 /* Make sure we do not make duplicates */
862 p
= (struct mips_pending
*) xmalloc (sizeof (*p
));
865 p
->next
= pending_list
[f_idx
];
866 pending_list
[f_idx
] = p
;
868 sh
->reserved
= 1; /* for quick check */
871 /* Throw away undef entries when done with file index F_IDX */
872 /* FIXME -- storage leak. This is never called!!! --gnu */
880 register struct mips_pending
*p
, *q
;
882 for (p
= pending_list
[f_idx
]; p
; p
= q
)
887 pending_list
[f_idx
] = 0;
893 prepend_tag_kind (tag_name
, type_code
)
895 enum type_code type_code
;
904 case TYPE_CODE_STRUCT
:
907 case TYPE_CODE_UNION
:
914 result
= (char *) obstack_alloc (¤t_objfile
->symbol_obstack
,
915 strlen (prefix
) + strlen (tag_name
) + 1);
916 sprintf (result
, "%s%s", prefix
, tag_name
);
921 /* Parsing Routines proper. */
923 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
924 For blocks, procedures and types we open a new lexical context.
925 This is basically just a big switch on the symbol's type.
926 Argument AX is the base pointer of aux symbols for this file (fh->iauxBase).
927 BIGEND says whether aux symbols are big-endian or little-endian.
928 Return count of SYMR's handled (normally one). */
931 parse_symbol (sh
, ax
, bigend
)
942 /* When a symbol is cross-referenced from other files/symbols
943 we mark it explicitly */
944 int pend
= (sh
->reserved
== 1);
945 enum address_class
class;
954 case stGlobal
: /* external symbol, goes into global block */
956 b
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
958 s
= new_symbol ((char *) sh
->iss
);
959 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
962 case stStatic
: /* static data, goes into current block. */
964 b
= top_stack
->cur_block
;
965 s
= new_symbol ((char *) sh
->iss
);
966 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
969 case stLocal
: /* local variable, goes into current block */
970 if (sh
->sc
== scRegister
)
972 class = LOC_REGISTER
;
974 sh
->value
+= FP0_REGNUM
- 32;
978 b
= top_stack
->cur_block
;
979 s
= new_symbol ((char *) sh
->iss
);
980 SYMBOL_VALUE (s
) = sh
->value
;
982 data
: /* Common code for symbols describing data */
983 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
984 SYMBOL_CLASS (s
) = class;
987 /* Type could be missing in a number of cases */
988 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
989 sh
->index
== 0xfffff)
990 SYMBOL_TYPE (s
) = builtin_type_int
; /* undefined? */
992 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
993 /* Value of a data symbol is its memory address */
996 case stParam
: /* arg to procedure, goes into current block */
998 top_stack
->numargs
++;
1000 name
= (char *) sh
->iss
;
1001 /* Special GNU C++ name. */
1002 if (name
[0] == CPLUS_MARKER
&& name
[1] == 't' && name
[2] == 0)
1003 name
= "this"; /* FIXME, not alloc'd in obstack */
1004 s
= new_symbol (name
);
1006 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1007 if (sh
->sc
== scRegister
)
1009 SYMBOL_CLASS (s
) = LOC_REGPARM
;
1011 sh
->value
+= FP0_REGNUM
- 32;
1014 SYMBOL_CLASS (s
) = LOC_ARG
;
1015 SYMBOL_VALUE (s
) = sh
->value
;
1016 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
1017 add_symbol (s
, top_stack
->cur_block
);
1019 /* FIXME: This has not been tested. See dbxread.c */
1020 /* Add the type of this parameter to the function/procedure
1021 type of this block. */
1022 add_param_to_type (&top_stack
->cur_block
->function
->type
, s
);
1026 case stLabel
: /* label, goes into current block */
1027 s
= new_symbol ((char *) sh
->iss
);
1028 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
; /* so that it can be used */
1029 SYMBOL_CLASS (s
) = LOC_LABEL
; /* but not misused */
1030 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
1031 SYMBOL_TYPE (s
) = builtin_type_int
;
1032 add_symbol (s
, top_stack
->cur_block
);
1035 case stProc
: /* Procedure, usually goes into global block */
1036 case stStaticProc
: /* Static procedure, goes into current block */
1037 s
= new_symbol ((char *) sh
->iss
);
1038 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1039 SYMBOL_CLASS (s
) = LOC_BLOCK
;
1040 /* Type of the return value */
1041 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1042 t
= builtin_type_int
;
1044 t
= parse_type (ax
+ sh
->index
+ 1, 0, bigend
);
1045 b
= top_stack
->cur_block
;
1046 if (sh
->st
== stProc
)
1048 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
1049 /* The next test should normally be true,
1050 but provides a hook for nested functions
1051 (which we don't want to make global). */
1052 if (b
== BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
))
1053 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
1057 /* Make a type for the procedure itself */
1059 /* FIXME: This has not been tested yet! See dbxread.c */
1060 /* Generate a template for the type of this function. The
1061 types of the arguments will be added as we read the symbol
1063 bcopy (SYMBOL_TYPE (s
), lookup_function_type (t
), sizeof (struct type
));
1065 SYMBOL_TYPE (s
) = lookup_function_type (t
);
1068 /* Create and enter a new lexical context */
1069 b
= new_block (top_stack
->maxsyms
);
1070 SYMBOL_BLOCK_VALUE (s
) = b
;
1071 BLOCK_FUNCTION (b
) = s
;
1072 BLOCK_START (b
) = BLOCK_END (b
) = sh
->value
;
1073 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1074 add_block (b
, top_stack
->cur_st
);
1076 /* Not if we only have partial info */
1077 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1080 push_parse_stack ();
1081 top_stack
->cur_block
= b
;
1082 top_stack
->blocktype
= sh
->st
;
1083 top_stack
->cur_type
= SYMBOL_TYPE (s
);
1084 top_stack
->cur_field
= -1;
1085 top_stack
->procadr
= sh
->value
;
1086 top_stack
->numargs
= 0;
1088 sh
->value
= (long) SYMBOL_TYPE (s
);
1091 /* Beginning of code for structure, union, and enum definitions.
1092 They all share a common set of local variables, defined here. */
1094 enum type_code type_code
;
1100 case stStruct
: /* Start a block defining a struct type */
1101 type_code
= TYPE_CODE_STRUCT
;
1102 goto structured_common
;
1104 case stUnion
: /* Start a block defining a union type */
1105 type_code
= TYPE_CODE_UNION
;
1106 goto structured_common
;
1108 case stEnum
: /* Start a block defining an enum type */
1109 type_code
= TYPE_CODE_ENUM
;
1110 goto structured_common
;
1112 case stBlock
: /* Either a lexical block, or some type */
1113 if (sh
->sc
!= scInfo
)
1114 goto case_stBlock_code
; /* Lexical block */
1116 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
1118 /* Common code for handling struct, union, enum, and/or as-yet-
1119 unknown-type blocks of info about structured data. `type_code'
1120 has been set to the proper TYPE_CODE, if we know it. */
1122 push_parse_stack ();
1123 top_stack
->blocktype
= stBlock
;
1125 s
= new_symbol ((char *) sh
->iss
);
1126 SYMBOL_NAMESPACE (s
) = STRUCT_NAMESPACE
;
1127 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
1128 SYMBOL_VALUE (s
) = 0;
1129 add_symbol (s
, top_stack
->cur_block
);
1131 /* First count the number of fields and the highest value. */
1134 for (tsym
= sh
+ 1; tsym
->st
!= stEnd
; tsym
++)
1136 if (tsym
->st
== stMember
)
1138 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
1139 /* If the type of the member is Nil (or Void),
1140 without qualifiers, assume the tag is an
1142 if (tsym
->index
== indexNil
)
1143 type_code
= TYPE_CODE_ENUM
;
1146 ecoff_swap_tir_in (bigend
,
1147 &ax
[tsym
->index
].a_ti
,
1149 if ((tir
.bt
== btNil
|| tir
.bt
== btVoid
)
1150 && tir
.tq0
== tqNil
)
1151 type_code
= TYPE_CODE_ENUM
;
1154 if (tsym
->value
> max_value
)
1155 max_value
= tsym
->value
;
1157 else if (tsym
->st
== stBlock
1158 || tsym
->st
== stUnion
1159 || tsym
->st
== stEnum
1160 || tsym
->st
== stStruct
1161 || tsym
->st
== stParsed
)
1163 if (tsym
->sc
== scVariant
); /*UNIMPLEMENTED*/
1164 if (tsym
->index
!= 0)
1165 tsym
= ((SYMR
*) cur_fdr
->isymBase
)
1169 complain (&block_member_complaint
, tsym
->st
);
1172 /* In an stBlock, there is no way to distinguish structs,
1173 unions, and enums at this point. This is a bug in the
1174 original design (that has been fixed with the recent
1175 addition of the stStruct, stUnion, and stEnum symbol
1176 types.) The way you can tell is if/when you see a variable
1177 or field of that type. In that case the variable's type
1178 (in the AUX table) says if the type is struct, union, or
1179 enum, and points back to the stBlock here. So you can
1180 patch the tag kind up later - but only if there actually is
1181 a variable or field of that type.
1183 So until we know for sure, we will guess at this point.
1185 If the first member has index==indexNil or a void type,
1186 assume we have an enumeration.
1187 Otherwise, if there is more than one member, and all
1188 the members have offset 0, assume we have a union.
1189 Otherwise, assume we have a struct.
1191 The heuristic could guess wrong in the case of of an
1192 enumeration with no members or a union with one (or zero)
1193 members, or when all except the last field of a struct have
1194 width zero. These are uncommon and/or illegal situations,
1195 and in any case guessing wrong probably doesn't matter
1198 But if we later do find out we were wrong, we fixup the tag
1199 kind. Members of an enumeration must be handled
1200 differently from struct/union fields, and that is harder to
1201 patch up, but luckily we shouldn't need to. (If there are
1202 any enumeration members, we can tell for sure it's an enum
1205 if (type_code
== TYPE_CODE_UNDEF
)
1206 if (nfields
> 1 && max_value
== 0)
1207 type_code
= TYPE_CODE_UNION
;
1209 type_code
= TYPE_CODE_STRUCT
;
1211 /* If this type was expected, use its partial definition */
1213 t
= is_pending_symbol (cur_fdr
, sh
)->t
;
1215 t
= new_type (prepend_tag_kind ((char *) sh
->iss
,
1218 TYPE_CODE (t
) = type_code
;
1219 TYPE_LENGTH (t
) = sh
->value
;
1220 TYPE_NFIELDS (t
) = nfields
;
1221 TYPE_FIELDS (t
) = f
= (struct field
*)
1222 TYPE_ALLOC (t
, nfields
* sizeof (struct field
));
1224 if (type_code
== TYPE_CODE_ENUM
)
1226 /* This is a non-empty enum. */
1227 for (tsym
= sh
+ 1; tsym
->st
== stMember
; tsym
++)
1229 struct symbol
*enum_sym
;
1230 f
->bitpos
= tsym
->value
;
1232 f
->name
= (char *) tsym
->iss
;
1235 enum_sym
= ((struct symbol
*)
1236 obstack_alloc (¤t_objfile
->symbol_obstack
,
1237 sizeof (struct symbol
)));
1238 memset ((PTR
) enum_sym
, 0, sizeof (struct symbol
));
1239 SYMBOL_NAME (enum_sym
) = f
->name
;
1240 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1241 SYMBOL_TYPE (enum_sym
) = t
;
1242 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1243 SYMBOL_VALUE (enum_sym
) = tsym
->value
;
1244 add_symbol (enum_sym
, top_stack
->cur_block
);
1246 /* Skip the stMembers that we've handled. */
1251 SYMBOL_TYPE (s
) = t
;
1252 /* make this the current type */
1253 top_stack
->cur_type
= t
;
1254 top_stack
->cur_field
= 0;
1255 /* Mark that symbol has a type, and say which one */
1256 sh
->value
= (long) t
;
1259 /* End of local variables shared by struct, union, enum, and
1260 block (as yet unknown struct/union/enum) processing. */
1264 /* beginnning of (code) block. Value of symbol
1265 is the displacement from procedure start */
1266 push_parse_stack ();
1267 top_stack
->blocktype
= stBlock
;
1268 b
= new_block (top_stack
->maxsyms
);
1269 BLOCK_START (b
) = sh
->value
+ top_stack
->procadr
;
1270 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1271 top_stack
->cur_block
= b
;
1272 add_block (b
, top_stack
->cur_st
);
1275 case stEnd
: /* end (of anything) */
1276 if (sh
->sc
== scInfo
)
1278 /* Finished with type */
1279 top_stack
->cur_type
= 0;
1281 else if (sh
->sc
== scText
1282 && (top_stack
->blocktype
== stProc
1283 || top_stack
->blocktype
== stStaticProc
))
1285 /* Finished with procedure */
1286 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
1287 struct mips_extra_func_info
*e
;
1291 BLOCK_END (top_stack
->cur_block
) += sh
->value
; /* size */
1293 /* Make up special symbol to contain procedure specific info */
1294 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
1295 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
1296 SYMBOL_CLASS (s
) = LOC_CONST
;
1297 SYMBOL_TYPE (s
) = builtin_type_void
;
1298 e
= ((struct mips_extra_func_info
*)
1299 obstack_alloc (¤t_objfile
->symbol_obstack
,
1300 sizeof (struct mips_extra_func_info
)));
1301 SYMBOL_VALUE (s
) = (int) e
;
1302 e
->numargs
= top_stack
->numargs
;
1303 add_symbol (s
, top_stack
->cur_block
);
1305 /* Reallocate symbols, saving memory */
1306 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1308 /* f77 emits proc-level with address bounds==[0,0],
1309 So look for such child blocks, and patch them. */
1310 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
1312 struct block
*b_bad
= BLOCKVECTOR_BLOCK (bv
, i
);
1313 if (BLOCK_SUPERBLOCK (b_bad
) == b
1314 && BLOCK_START (b_bad
) == top_stack
->procadr
1315 && BLOCK_END (b_bad
) == top_stack
->procadr
)
1317 BLOCK_START (b_bad
) = BLOCK_START (b
);
1318 BLOCK_END (b_bad
) = BLOCK_END (b
);
1322 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
)
1324 /* End of (code) block. The value of the symbol
1325 is the displacement from the procedure`s start
1326 address of the end of this block. */
1327 BLOCK_END (top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1328 shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1330 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stFile
)
1332 /* End of file. Pop parse stack and ignore. Higher
1333 level code deals with this. */
1337 complain (&stEnd_complaint
, sh
->sc
);
1339 pop_parse_stack (); /* restore previous lexical context */
1342 case stMember
: /* member of struct or union */
1343 f
= &TYPE_FIELDS (top_stack
->cur_type
)[top_stack
->cur_field
++];
1344 f
->name
= (char *) sh
->iss
;
1345 f
->bitpos
= sh
->value
;
1347 f
->type
= parse_type (ax
+ sh
->index
, &f
->bitsize
, bigend
);
1350 case stTypedef
: /* type definition */
1351 s
= new_symbol ((char *) sh
->iss
);
1352 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1353 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
1354 SYMBOL_BLOCK_VALUE (s
) = top_stack
->cur_block
;
1355 add_symbol (s
, top_stack
->cur_block
);
1356 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
1357 sh
->value
= (long) SYMBOL_TYPE (s
);
1360 case stFile
: /* file name */
1361 push_parse_stack ();
1362 top_stack
->blocktype
= sh
->st
;
1365 /* I`ve never seen these for C */
1367 break; /* register relocation */
1369 break; /* forwarding address */
1371 break; /* constant */
1373 complain (&unknown_mips_symtype_complaint
, sh
->st
);
1380 /* Parse the type information provided in the raw AX entries for
1381 the symbol SH. Return the bitfield size in BS, in case.
1382 We must byte-swap the AX entries before we use them; BIGEND says whether
1383 they are big-endian or little-endian (from fh->fBigendian). */
1385 static struct type
*
1386 parse_type (ax
, bs
, bigend
)
1391 /* Null entries in this map are treated specially */
1392 static struct type
**map_bt
[] =
1394 &builtin_type_void
, /* btNil */
1396 &builtin_type_char
, /* btChar */
1397 &builtin_type_unsigned_char
,/* btUChar */
1398 &builtin_type_short
, /* btShort */
1399 &builtin_type_unsigned_short
, /* btUShort */
1400 &builtin_type_int
, /* btInt */
1401 &builtin_type_unsigned_int
, /* btUInt */
1402 &builtin_type_long
, /* btLong */
1403 &builtin_type_unsigned_long
,/* btULong */
1404 &builtin_type_float
, /* btFloat */
1405 &builtin_type_double
, /* btDouble */
1412 &builtin_type_complex
, /* btComplex */
1413 &builtin_type_double_complex
, /* btDComplex */
1415 &builtin_type_fixed_dec
, /* btFixedDec */
1416 &builtin_type_float_dec
, /* btFloatDec */
1417 &builtin_type_string
, /* btString */
1420 &builtin_type_void
, /* btVoid */
1421 &builtin_type_long_long
, /* btLongLong */
1422 &builtin_type_unsigned_long_long
, /* btULongLong */
1426 struct type
*tp
= 0;
1429 enum type_code type_code
;
1431 /* Use aux as a type information record, map its basic type. */
1433 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1434 if (t
->bt
> (sizeof (map_bt
) / sizeof (*map_bt
)))
1436 complain (&basic_type_complaint
, t
->bt
);
1437 return builtin_type_int
;
1441 tp
= *map_bt
[t
->bt
];
1447 /* Cannot use builtin types -- build our own */
1451 tp
= lookup_pointer_type (builtin_type_void
);
1455 type_code
= TYPE_CODE_STRUCT
;
1459 type_code
= TYPE_CODE_UNION
;
1463 type_code
= TYPE_CODE_ENUM
;
1467 type_code
= TYPE_CODE_RANGE
;
1471 type_code
= TYPE_CODE_SET
;
1476 complain (&basic_type_complaint
, t
->bt
);
1477 return builtin_type_int
;
1481 /* Skip over any further type qualifiers (FIXME). */
1484 /* This is the way it would work if the compiler worked */
1489 ecoff_swap_tir_in (bigend
, ax
, t1
);
1491 while (t1
->continued
);
1494 /* Move on to next aux */
1499 *bs
= AUX_GET_WIDTH (bigend
, ax
);
1503 /* All these types really point to some (common) MIPS type
1504 definition, and only the type-qualifiers fully identify
1505 them. We'll make the same effort at sharing. */
1506 if (t
->bt
== btIndirect
||
1507 t
->bt
== btStruct
||
1510 t
->bt
== btTypedef
||
1514 char name
[256], *pn
;
1516 /* Try to cross reference this type */
1517 ax
+= cross_ref (ax
, &tp
, type_code
, &pn
, bigend
);
1518 /* reading .o file ? */
1519 if (UNSAFE_DATA_ADDR (tp
))
1520 tp
= init_type (type_code
, 0, 0, (char *) NULL
,
1521 (struct objfile
*) NULL
);
1522 /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */
1523 sprintf (name
, fmt
, pn
);
1525 /* Usually, TYPE_CODE(tp) is already type_code. The main
1526 exception is if we guessed wrong re struct/union/enum. */
1527 if (TYPE_CODE (tp
) != type_code
)
1529 complain (&bad_tag_guess_complaint
, name
);
1530 TYPE_CODE (tp
) = type_code
;
1532 if (TYPE_NAME (tp
) == NULL
|| !STREQ (TYPE_NAME (tp
), name
))
1533 TYPE_NAME (tp
) = obsavestring (name
, strlen (name
),
1534 ¤t_objfile
->type_obstack
);
1537 /* Deal with range types */
1538 if (t
->bt
== btRange
)
1540 TYPE_NFIELDS (tp
) = 2;
1541 TYPE_FIELDS (tp
) = ((struct field
*)
1542 TYPE_ALLOC (tp
, 2 * sizeof (struct field
)));
1543 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1544 ¤t_objfile
->type_obstack
);
1545 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1547 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1548 ¤t_objfile
->type_obstack
);
1549 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1553 /* Parse all the type qualifiers now. If there are more
1554 than 6 the game will continue in the next aux */
1556 #define PARSE_TQ(tq) \
1557 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend);
1559 again
:PARSE_TQ (tq0
);
1570 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1576 /* Make up a complex type from a basic one. Type is passed by
1577 reference in TPP and side-effected as necessary. The type
1578 qualifier TQ says how to handle the aux symbols at AX for
1579 the symbol SX we are currently analyzing. BIGEND says whether
1580 aux symbols are big-endian or little-endian.
1581 Returns the number of aux symbols we parsed. */
1584 upgrade_type (tpp
, tq
, ax
, bigend
)
1593 /* Used in array processing */
1604 t
= lookup_pointer_type (*tpp
);
1609 t
= lookup_function_type (*tpp
);
1616 /* Determine and record the domain type (type of index) */
1617 ecoff_swap_rndx_in (bigend
, ax
, &rndx
);
1623 rf
= AUX_GET_ISYM (bigend
, ax
);
1626 fh
= get_rfd (cur_fd
, rf
);
1628 indx
= parse_type (id
+ (union aux_ext
*) fh
->iauxBase
,
1629 (int *) NULL
, bigend
);
1631 /* Get the bounds, and create the array type. */
1633 lower
= AUX_GET_DNLOW (bigend
, ax
);
1635 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1637 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1639 range
= create_range_type ((struct type
*) NULL
, indx
,
1642 t
= create_array_type ((struct type
*) NULL
, *tpp
, range
);
1644 /* Check whether supplied array element bit size matches
1645 the known size of the element type. If this complaint
1646 ends up not happening, we can remove this code. It's
1647 here because we aren't sure we understand this *&%&$
1649 id
= TYPE_LENGTH (TYPE_TARGET_TYPE (t
)) << 3; /* bitsize */
1652 /* Most likely an undefined type */
1654 TYPE_LENGTH (TYPE_TARGET_TYPE (t
)) = id
>> 3;
1657 complain (&array_bitsize_complaint
, rf
);
1663 /* Volatile -- currently ignored */
1667 /* Const -- currently ignored */
1671 complain (&unknown_type_qual_complaint
, tq
);
1677 /* Parse a procedure descriptor record PR. Note that the procedure
1678 is parsed _after_ the local symbols, now we just insert the extra
1679 information we need into a MIPS_EFI_SYMBOL_NAME symbol that has already
1680 been placed in the procedure's main block. Note also that images that
1681 have been partially stripped (ld -x) have been deprived
1682 of local symbols, and we have to cope with them here.
1683 The procedure's code ends at BOUND */
1686 parse_procedure (pr
, bound
, have_stabs
)
1691 struct symbol
*s
, *i
;
1692 SYMR
*sh
= (SYMR
*) pr
->isym
;
1694 struct mips_extra_func_info
*e
;
1697 /* Static procedure at address pr->adr. Sigh. */
1698 if (sh
== (SYMR
*) - 1)
1700 complain (&pdr_static_symbol_complaint
, pr
->adr
);
1703 sh_name
= (char *) sh
->iss
;
1705 s
= lookup_symbol (sh_name
, NULL
, VAR_NAMESPACE
, 0, NULL
);
1707 s
= mylookup_symbol (sh_name
, top_stack
->cur_block
,
1708 VAR_NAMESPACE
, LOC_BLOCK
);
1712 b
= SYMBOL_BLOCK_VALUE (s
);
1716 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1720 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1721 s
= new_symbol (sh_name
);
1722 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1723 SYMBOL_CLASS (s
) = LOC_BLOCK
;
1724 /* Donno its type, hope int is ok */
1725 SYMBOL_TYPE (s
) = lookup_function_type (builtin_type_int
);
1726 add_symbol (s
, top_stack
->cur_block
);
1727 /* Wont have symbols for this one */
1729 SYMBOL_BLOCK_VALUE (s
) = b
;
1730 BLOCK_FUNCTION (b
) = s
;
1731 BLOCK_START (b
) = pr
->adr
;
1732 BLOCK_END (b
) = bound
;
1733 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1734 add_block (b
, top_stack
->cur_st
);
1738 i
= mylookup_symbol (MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
, LOC_CONST
);
1742 e
= (struct mips_extra_func_info
*) SYMBOL_VALUE (i
);
1744 e
->pdr
.isym
= (long) s
;
1748 /* Parse the external symbol ES. Just call parse_symbol() after
1749 making sure we know where the aux are for it. For procedures,
1750 parsing of the PDRs has already provided all the needed
1751 information, we only parse them if SKIP_PROCEDURES is false,
1752 and only if this causes no symbol duplication.
1753 BIGEND says whether aux entries are big-endian or little-endian.
1755 This routine clobbers top_stack->cur_block and ->cur_st. */
1758 parse_external (es
, skip_procedures
, bigend
)
1760 int skip_procedures
;
1765 if (es
->ifd
!= ifdNil
)
1768 cur_fdr
= (FDR
*) (cur_hdr
->cbFdOffset
) + cur_fd
;
1769 ax
= (union aux_ext
*) cur_fdr
->iauxBase
;
1773 cur_fdr
= (FDR
*) (cur_hdr
->cbFdOffset
);
1777 /* Reading .o files */
1778 if (es
->asym
.sc
== scUndefined
|| es
->asym
.sc
== scNil
)
1781 switch (es
->asym
.st
)
1801 /* FIXME: Turn this into a complaint? */
1803 printf_filtered ("Warning: %s `%s' is undefined (in %s)\n",
1804 what
, es
->asym
.iss
, fdr_name ((char *) cur_fdr
->rss
));
1808 switch (es
->asym
.st
)
1811 /* If we have full symbols we do not need more */
1812 if (skip_procedures
)
1814 if (mylookup_symbol ((char *) es
->asym
.iss
, top_stack
->cur_block
,
1815 VAR_NAMESPACE
, LOC_BLOCK
))
1821 * Note that the case of a symbol with indexNil
1822 * must be handled anyways by parse_symbol().
1824 parse_symbol (&es
->asym
, ax
, bigend
);
1831 /* Parse the line number info for file descriptor FH into
1832 GDB's linetable LT. MIPS' encoding requires a little bit
1833 of magic to get things out. Note also that MIPS' line
1834 numbers can go back and forth, apparently we can live
1835 with that and do not need to reorder our linetables */
1838 parse_lines (fh
, lt
)
1840 struct linetable
*lt
;
1842 unsigned char *base
= (unsigned char *) fh
->cbLineOffset
;
1844 int delta
, count
, lineno
= 0;
1850 /* Scan by procedure descriptors */
1852 for (pr
= (PDR
*) IPDFIRST (cur_hdr
, fh
); j
< fh
->cpd
; j
++, pr
++)
1856 /* No code for this one */
1857 if (pr
->iline
== ilineNil
||
1858 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
1861 * Aurgh! To know where to stop expanding we
1864 for (l
= 1; l
< (fh
->cpd
- j
); l
++)
1865 if (pr
[l
].iline
!= -1)
1867 if (l
== (fh
->cpd
- j
))
1872 * When procedures are moved around the linenumbers
1873 * are attributed to the next procedure up
1875 if (pr
->iline
>= halt
)
1878 base
= (unsigned char *) pr
->cbLineOffset
;
1879 l
= pr
->adr
>> 2; /* in words */
1880 halt
+= (pr
->adr
>> 2) - pr
->iline
;
1881 for (lineno
= pr
->lnLow
; l
< halt
;)
1883 count
= *base
& 0x0f;
1884 delta
= *base
++ >> 4;
1889 delta
= (base
[0] << 8) | base
[1];
1890 if (delta
>= 0x8000)
1894 lineno
+= delta
; /* first delta is 0 */
1895 k
= add_line (lt
, lineno
, l
, k
);
1901 /* Master parsing procedure for first-pass reading of file symbols
1902 into a partial_symtab.
1904 Parses the symtab described by the global symbolic header CUR_HDR.
1905 END_OF_TEXT_SEG gives the address just after the text segment for
1906 the symtab we are reading. */
1909 parse_partial_symbols (end_of_text_seg
, objfile
, section_offsets
)
1910 int end_of_text_seg
;
1911 struct objfile
*objfile
;
1912 struct section_offsets
*section_offsets
;
1915 HDRR
*hdr
= cur_hdr
;
1916 /* Running pointers */
1920 struct partial_symtab
*pst
;
1922 int past_first_source_file
= 0;
1924 /* List of current psymtab's include files */
1925 char **psymtab_include_list
;
1926 int includes_allocated
;
1929 struct pst_map
*fdr_to_pst
;
1930 /* Index within current psymtab dependency list */
1931 struct partial_symtab
**dependency_list
;
1932 int dependencies_used
, dependencies_allocated
;
1933 struct cleanup
*old_chain
;
1936 extern_tab
= (EXTR
**) obstack_alloc (&objfile
->psymbol_obstack
,
1937 sizeof (EXTR
*) * hdr
->iextMax
);
1939 includes_allocated
= 30;
1941 psymtab_include_list
= (char **) alloca (includes_allocated
*
1943 next_symbol_text_func
= mips_next_symbol_text
;
1945 dependencies_allocated
= 30;
1946 dependencies_used
= 0;
1948 (struct partial_symtab
**) alloca (dependencies_allocated
*
1949 sizeof (struct partial_symtab
*));
1951 last_source_file
= NULL
;
1956 * Only parse the Local and External symbols, and the Relative FDR.
1957 * Fixup enough of the loader symtab to be able to use it.
1958 * Allocate space only for the file's portions we need to
1963 max_glevel
= MIN_GLEVEL
;
1965 /* Allocate the map FDR -> PST.
1966 Minor hack: -O3 images might claim some global data belongs
1967 to FDR -1. We`ll go along with that */
1968 fdr_to_pst
= (struct pst_map
*) xzalloc ((hdr
->ifdMax
+ 1) * sizeof *fdr_to_pst
);
1969 old_chain
= make_cleanup (free
, fdr_to_pst
);
1972 struct partial_symtab
*pst
= new_psymtab ("", objfile
);
1973 fdr_to_pst
[-1].pst
= pst
;
1977 /* Pass 1 over external syms: Presize and partition the list */
1978 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++)
1980 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1981 fdr_to_pst
[esh
->ifd
].n_globals
++;
1984 /* Pass 1.5 over files: partition out global symbol space */
1986 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++)
1988 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
1989 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
1990 fdr_to_pst
[f_idx
].n_globals
= 0;
1993 /* Pass 2 over external syms: fill in external symbols */
1994 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++)
1996 enum minimal_symbol_type ms_type
= mst_text
;
1997 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1999 extern_tab
[fdr_to_pst
[esh
->ifd
].globals_offset
2000 + fdr_to_pst
[esh
->ifd
].n_globals
++] = esh
;
2002 if (esh
->asym
.sc
== scUndefined
|| esh
->asym
.sc
== scNil
)
2005 switch (esh
->asym
.st
)
2015 ms_type
= mst_unknown
;
2016 complain (&unknown_ext_complaint
, esh
->asym
.iss
);
2018 name
= (char *) esh
->asym
.iss
;
2019 prim_record_minimal_symbol (name
, esh
->asym
.value
, ms_type
);
2022 /* Pass 3 over files, over local syms: fill in static symbols */
2023 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
2025 struct partial_symtab
*save_pst
;
2028 cur_fdr
= fh
= f_idx
+ (FDR
*) (cur_hdr
->cbFdOffset
);
2032 fdr_to_pst
[f_idx
].pst
= NULL
;
2035 pst
= start_psymtab_common (objfile
, section_offsets
, (char *) fh
->rss
,
2036 fh
->cpd
? fh
->adr
: 0,
2037 objfile
->global_psymbols
.next
,
2038 objfile
->static_psymbols
.next
);
2039 pst
->read_symtab_private
= ((char *)
2040 obstack_alloc (&objfile
->psymbol_obstack
,
2041 sizeof (struct symloc
)));
2044 /* Make everything point to everything. */
2045 FDR_IDX (pst
) = f_idx
;
2046 fdr_to_pst
[f_idx
].pst
= pst
;
2047 fh
->ioptBase
= (int) pst
;
2049 CUR_HDR (pst
) = cur_hdr
;
2051 /* The way to turn this into a symtab is to call... */
2052 pst
->read_symtab
= mipscoff_psymtab_to_symtab
;
2054 pst
->texthigh
= pst
->textlow
;
2056 /* For stabs-in-ecoff files, the second symbol must be @stab.
2057 This symbol is emitted by mips-tfile to signal
2058 that the current object file uses encapsulated stabs
2059 instead of mips ecoff for local symbols.
2060 (It is the second symbol because the first symbol is
2061 the stFile used to signal the start of a file). */
2063 && STREQ ((char *) (((SYMR
*) fh
->isymBase
)[1].iss
), stabs_symbol
))
2065 processing_gcc_compilation
= 2;
2066 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
2070 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2071 type_code
= MIPS_UNMARK_STAB (sh
->index
);
2072 if (!MIPS_IS_STAB (sh
))
2074 if (sh
->st
== stProc
|| sh
->st
== stStaticProc
)
2076 long procaddr
= sh
->value
;
2077 sh
= (AUX_GET_ISYM (fh
->fBigendian
,
2079 + (union aux_ext
*) (fh
->iauxBase
)))
2080 + (SYMR
*) fh
->isymBase
- 1);
2081 if (sh
->st
== stEnd
)
2083 long high
= procaddr
+ sh
->value
;
2084 if (high
> pst
->texthigh
)
2085 pst
->texthigh
= high
;
2090 #define SET_NAMESTRING() namestring = (char*)sh->iss
2091 #define CUR_SYMBOL_TYPE type_code
2092 #define CUR_SYMBOL_VALUE sh->value
2093 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
2095 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
2096 #define HANDLE_RBRAC(val) \
2097 if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
2098 #include "partial-stab.h"
2103 processing_gcc_compilation
= 0;
2104 for (cur_sdx
= 0; cur_sdx
< fh
->csym
;)
2107 enum address_class
class;
2108 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2110 if (MIPS_IS_STAB (sh
))
2116 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
2117 sh
->index
== 0xfffff)
2119 /* FIXME, premature? */
2124 name
= (char *) (sh
->iss
);
2132 case stProc
: /* Asm labels apparently */
2133 case stStaticProc
: /* Function */
2134 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2135 VAR_NAMESPACE
, LOC_BLOCK
,
2136 objfile
->static_psymbols
, sh
->value
,
2137 psymtab_language
, objfile
);
2138 /* Skip over procedure to next one. */
2139 if (sh
->index
>= hdr
->iauxMax
)
2141 /* Should not happen, but does when cross-compiling
2142 with the MIPS compiler. FIXME -- pull later. */
2143 complain (&index_complaint
, name
);
2144 new_sdx
= cur_sdx
+ 1; /* Don't skip at all */
2147 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2148 sh
->index
+ (union aux_ext
*) fh
->iauxBase
);
2149 procaddr
= sh
->value
;
2151 if (new_sdx
<= cur_sdx
)
2153 /* This should not happen either... FIXME. */
2154 complain (&aux_index_complaint
, name
);
2155 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2159 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
- 1;
2160 if (sh
->st
!= stEnd
)
2162 high
= procaddr
+ sh
->value
;
2163 if (high
> pst
->texthigh
)
2164 pst
->texthigh
= high
;
2167 case stStatic
: /* Variable */
2171 case stTypedef
:/* Typedef */
2172 class = LOC_TYPEDEF
;
2175 case stConstant
: /* Constant decl */
2182 case stBlock
: /* { }, str, un, enum*/
2183 if (sh
->sc
== scInfo
)
2185 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2186 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2187 objfile
->static_psymbols
,
2189 psymtab_language
, objfile
);
2191 /* Skip over the block */
2192 new_sdx
= sh
->index
;
2193 if (new_sdx
<= cur_sdx
)
2195 /* This happens with the Ultrix kernel. */
2196 complain (&block_index_complaint
, name
);
2197 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2202 case stFile
: /* File headers */
2203 case stLabel
: /* Labels */
2204 case stEnd
: /* Ends of files */
2207 case stLocal
: /* Local variables */
2208 /* Normally these are skipped because we skip over
2209 all blocks we see. However, these can occur
2210 as visible symbols in a .h file that contains code. */
2214 /* Both complaints are valid: one gives symbol name,
2215 the other the offending symbol type. */
2216 complain (&unknown_sym_complaint
, sh
->iss
);
2217 complain (&unknown_st_complaint
, sh
->st
);
2221 /* Use this gdb symbol */
2222 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2223 VAR_NAMESPACE
, class,
2224 objfile
->static_psymbols
, sh
->value
,
2225 psymtab_language
, objfile
);
2227 cur_sdx
++; /* Go to next file symbol */
2230 /* Now do enter the external symbols. */
2231 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2232 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2233 PST_PRIVATE (save_pst
)->extern_count
= cur_sdx
;
2234 PST_PRIVATE (save_pst
)->extern_tab
= ext_ptr
;
2235 for (; --cur_sdx
>= 0; ext_ptr
++)
2237 register struct partial_symbol
*psym
;
2238 enum address_class
class;
2240 if ((*ext_ptr
)->ifd
!= f_idx
)
2242 sh
= &(*ext_ptr
)->asym
;
2252 complain (&unknown_ext_complaint
, sh
->iss
);
2253 /* Fall through, pretend it's global. */
2258 if (objfile
->global_psymbols
.next
>=
2259 objfile
->global_psymbols
.list
+ objfile
->global_psymbols
.size
)
2260 extend_psymbol_list (&objfile
->global_psymbols
, objfile
);
2261 psym
= objfile
->global_psymbols
.next
++;
2262 SYMBOL_NAME (psym
) = (char *) sh
->iss
;
2263 SYMBOL_NAMESPACE (psym
) = VAR_NAMESPACE
;
2264 SYMBOL_CLASS (psym
) = class;
2265 SYMBOL_VALUE_ADDRESS (psym
) = (CORE_ADDR
) sh
->value
;
2269 end_psymtab (save_pst
, psymtab_include_list
, includes_used
,
2270 -1, save_pst
->texthigh
,
2271 dependency_list
, dependencies_used
);
2272 if (objfile
->ei
.entry_point
>= save_pst
->textlow
&&
2273 objfile
->ei
.entry_point
< save_pst
->texthigh
)
2275 objfile
->ei
.entry_file_lowpc
= save_pst
->textlow
;
2276 objfile
->ei
.entry_file_highpc
= save_pst
->texthigh
;
2280 /* Mark the last code address, and remember it for later */
2281 hdr
->cbDnOffset
= end_of_text_seg
;
2283 /* Now scan the FDRs for dependencies */
2284 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
2287 fh
= f_idx
+ (FDR
*) (cur_hdr
->cbFdOffset
);
2288 pst
= fdr_to_pst
[f_idx
].pst
;
2290 /* This should catch stabs-in-ecoff. */
2295 { /* If there are no functions defined here ... */
2296 /* ...then presumably a .h file: drop reverse depends .h->.c */
2297 for (; s_id0
< fh
->crfd
; s_id0
++)
2299 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2302 s_id0
++; /* Skip self-dependency */
2307 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2309 ((struct partial_symtab
**)
2310 obstack_alloc (&objfile
->psymbol_obstack
,
2311 (pst
->number_of_dependencies
2312 * sizeof (struct partial_symtab
*))));
2313 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++)
2315 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2316 if (*rh
< 0 || *rh
>= hdr
->ifdMax
)
2317 complain (&bad_file_number_complaint
, *rh
);
2319 pst
->dependencies
[s_idx
- s_id0
] = fdr_to_pst
[*rh
].pst
;
2322 do_cleanups (old_chain
);
2327 /* Do the initial analisys of the F_IDX-th file descriptor.
2328 Allocates a partial symtab for it, and builds the list
2329 of dependent files by recursion. LEV says at which level
2330 of recursion we are called (to pretty up debug traces) */
2332 static struct partial_symtab
*
2333 parse_fdr (f_idx
, lev
, objfile
)
2336 struct objfile
*objfile
;
2339 register struct partial_symtab
*pst
;
2342 fh
= (FDR
*) (cur_hdr
->cbFdOffset
) + f_idx
;
2344 /* Use this to indicate into which symtab this file was parsed */
2346 return (struct partial_symtab
*) fh
->ioptBase
;
2348 /* Debuggability level */
2349 if (compare_glevel (max_glevel
, fh
->glevel
) < 0)
2350 max_glevel
= fh
->glevel
;
2352 /* Make a new partial_symtab */
2353 pst
= new_psymtab (fh
->rss
, objfile
);
2361 pst
->textlow
= fh
->adr
;
2362 pst
->texthigh
= fh
->cpd
; /* To be fixed later */
2365 /* Make everything point to everything. */
2366 FDR_IDX (pst
) = f_idx
;
2367 fdr_to_pst
[f_idx
].pst
= pst
;
2368 fh
->ioptBase
= (int) pst
;
2370 /* Analyze its dependencies */
2376 { /* If there are no functions defined here ... */
2377 /* ...then presumably a .h file: drop reverse depends .h->.c */
2378 for (; s_id0
< fh
->crfd
; s_id0
++)
2380 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2383 s_id0
++; /* Skip self-dependency */
2388 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2389 pst
->dependencies
= ((struct partial_symtab
**)
2390 obstack_alloc (&objfile
->psymbol_obstack
,
2391 (pst
->number_of_dependencies
2392 * sizeof (struct partial_symtab
*))));
2393 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++)
2395 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2397 pst
->dependencies
[s_idx
- s_id0
] = parse_fdr (*rh
, lev
+ 1, objfile
);
2406 mips_next_symbol_text ()
2409 return (char *) ((SYMR
*) cur_fdr
->isymBase
)[cur_sdx
].iss
;
2412 /* Ancillary function to psymtab_to_symtab(). Does all the work
2413 for turning the partial symtab PST into a symtab, recurring
2414 first on all dependent psymtabs. The argument FILENAME is
2415 only passed so we can see in debug stack traces what file
2418 This function has a split personality, based on whether the
2419 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
2420 The flow of control and even the memory allocation differs. FIXME. */
2423 psymtab_to_symtab_1 (pst
, filename
)
2424 struct partial_symtab
*pst
;
2430 struct linetable
*lines
;
2437 /* Read in all partial symbtabs on which this one is dependent.
2438 NOTE that we do have circular dependencies, sigh. We solved
2439 that by setting pst->readin before this point. */
2441 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
2442 if (!pst
->dependencies
[i
]->readin
)
2444 /* Inform about additional files to be read in. */
2447 fputs_filtered (" ", stdout
);
2449 fputs_filtered ("and ", stdout
);
2451 printf_filtered ("%s...",
2452 pst
->dependencies
[i
]->filename
);
2453 wrap_here (""); /* Flush output */
2456 /* We only pass the filename for debug purposes */
2457 psymtab_to_symtab_1 (pst
->dependencies
[i
],
2458 pst
->dependencies
[i
]->filename
);
2461 /* Now read the symbols for this symtab */
2463 current_objfile
= pst
->objfile
;
2464 cur_fd
= FDR_IDX (pst
);
2465 fh
= (cur_fd
== -1) ? 0 : (FDR
*) (cur_hdr
->cbFdOffset
) + FDR_IDX (pst
);
2468 /* BOUND is the highest core address of this file's procedures */
2469 bound
= (cur_fd
== cur_hdr
->ifdMax
- 1) ?
2470 cur_hdr
->cbDnOffset
:
2473 /* See comment in parse_partial_symbols about the @stabs sentinel. */
2474 if (fh
&& fh
->csym
>= 2
2475 && STREQ ((char *) (((SYMR
*) fh
->isymBase
)[1].iss
), stabs_symbol
))
2479 * This symbol table contains stabs-in-ecoff entries.
2484 /* We indicate that this is a GCC compilation so that certain features
2485 will be enabled in stabsread/dbxread. */
2486 processing_gcc_compilation
= 2;
2487 /* Parse local symbols first */
2489 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
2491 current_objfile
= NULL
;
2494 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
2496 register SYMR
*sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2497 char *name
= (char *) sh
->iss
;
2498 CORE_ADDR valu
= sh
->value
;
2499 if (MIPS_IS_STAB (sh
))
2501 int type_code
= MIPS_UNMARK_STAB (sh
->index
);
2502 process_one_symbol (type_code
, 0, valu
, name
,
2503 pst
->section_offsets
, pst
->objfile
);
2504 if (type_code
== N_FUN
)
2506 /* Make up special symbol to contain
2507 procedure specific info */
2508 struct mips_extra_func_info
*e
=
2509 (struct mips_extra_func_info
*)
2510 obstack_alloc (¤t_objfile
->symbol_obstack
,
2511 sizeof (struct mips_extra_func_info
));
2512 struct symbol
*s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
2513 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
2514 SYMBOL_CLASS (s
) = LOC_CONST
;
2515 SYMBOL_TYPE (s
) = builtin_type_void
;
2516 SYMBOL_VALUE (s
) = (int) e
;
2517 add_symbol_to_list (s
, &local_symbols
);
2520 else if (sh
->st
== stLabel
&& sh
->index
!= indexNil
)
2522 /* Handle encoded stab line number. */
2523 record_line (current_subfile
, sh
->index
, valu
);
2526 complain (&stab_unknown_complaint
, sh
->iss
);
2528 st
= end_symtab (pst
->texthigh
, 0, 0, pst
->objfile
);
2531 /* Sort the symbol table now, we are done adding symbols to it.
2532 We must do this before parse_procedure calls lookup_symbol. */
2533 sort_symtab_syms (st
);
2535 /* This may not be necessary for stabs symtabs. FIXME. */
2538 /* Fill in procedure info next. We need to look-ahead to
2539 find out where each procedure's code ends. */
2541 for (i
= 0; i
<= fh
->cpd
- 1; i
++)
2543 pr
= (PDR
*) (IPDFIRST (cur_hdr
, fh
)) + i
;
2544 parse_procedure (pr
, i
< fh
->cpd
- 1 ? pr
[1].adr
: bound
, 1);
2551 * This symbol table contains ordinary ecoff entries.
2554 /* FIXME: doesn't use pst->section_offsets. */
2560 processing_gcc_compilation
= 0;
2562 /* How many symbols will we need */
2563 /* FIXME, this does not count enum values. */
2564 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
2568 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
2572 f_max
+= fh
->csym
+ fh
->cpd
;
2573 maxlines
= 2 * fh
->cline
;
2574 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
2577 lines
= LINETABLE (st
);
2578 pending_list
= (struct mips_pending
**) cur_hdr
->cbOptOffset
;
2579 if (pending_list
== 0)
2581 pending_list
= (struct mips_pending
**)
2582 xzalloc (cur_hdr
->ifdMax
* sizeof (struct mips_pending
*));
2583 cur_hdr
->cbOptOffset
= (int) pending_list
;
2586 /* Get a new lexical context */
2588 push_parse_stack ();
2589 top_stack
->cur_st
= st
;
2590 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (st
),
2592 BLOCK_START (top_stack
->cur_block
) = fh
? fh
->adr
: 0;
2593 BLOCK_END (top_stack
->cur_block
) = 0;
2594 top_stack
->blocktype
= stFile
;
2595 top_stack
->maxsyms
= 2 * f_max
;
2596 top_stack
->cur_type
= 0;
2597 top_stack
->procadr
= 0;
2598 top_stack
->numargs
= 0;
2605 /* Parse local symbols first */
2607 for (cur_sdx
= 0; cur_sdx
< fh
->csym
;)
2609 sh
= (SYMR
*) (fh
->isymBase
) + cur_sdx
;
2610 cur_sdx
+= parse_symbol (sh
, (union aux_ext
*) fh
->iauxBase
,
2614 /* Linenumbers. At the end, check if we can save memory */
2616 parse_lines (fh
, lines
);
2617 if (lines
->nitems
< fh
->cline
)
2618 lines
= shrink_linetable (lines
);
2620 /* Fill in procedure info next. We need to look-ahead to
2621 find out where each procedure's code ends. */
2623 for (i
= 0; i
<= fh
->cpd
- 1; i
++)
2625 pr
= (PDR
*) (IPDFIRST (cur_hdr
, fh
)) + i
;
2626 parse_procedure (pr
, i
< fh
->cpd
- 1 ? pr
[1].adr
: bound
, 0);
2630 LINETABLE (st
) = lines
;
2632 /* .. and our share of externals.
2633 XXX use the global list to speed up things here. how?
2634 FIXME, Maybe quit once we have found the right number of ext's? */
2635 top_stack
->cur_st
= st
;
2636 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
2638 top_stack
->blocktype
= stFile
;
2639 top_stack
->maxsyms
=
2640 cur_hdr
->isymMax
+ cur_hdr
->ipdMax
+ cur_hdr
->iextMax
;
2642 ext_ptr
= PST_PRIVATE (pst
)->extern_tab
;
2643 for (i
= PST_PRIVATE (pst
)->extern_count
; --i
>= 0; ext_ptr
++)
2644 parse_external (*ext_ptr
, 1, fh
->fBigendian
);
2646 /* If there are undefined, tell the user */
2647 if (n_undef_symbols
)
2649 printf_filtered ("File %s contains %d unresolved references:",
2650 st
->filename
, n_undef_symbols
);
2651 printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
2652 n_undef_vars
, n_undef_procs
, n_undef_labels
);
2653 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
2658 /* Sort the symbol table now, we are done adding symbols to it.*/
2659 sort_symtab_syms (st
);
2664 /* Now link the psymtab and the symtab. */
2667 current_objfile
= NULL
;
2670 /* Ancillary parsing procedures. */
2672 /* Lookup the type at relative index RN. Return it in TPP
2673 if found and in any event come up with its name PNAME.
2674 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
2675 Return value says how many aux symbols we ate. */
2678 cross_ref (ax
, tpp
, type_code
, pname
, bigend
)
2681 enum type_code type_code
; /* Use to alloc new type if none is found. */
2689 ecoff_swap_rndx_in (bigend
, ax
, rn
);
2691 /* Escape index means 'the next one' */
2692 if (rn
->rfd
== 0xfff)
2695 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
2705 *pname
= "<undefined>";
2710 * Find the relative file descriptor and the symbol in it
2712 FDR
*fh
= get_rfd (cur_fd
, rf
);
2717 * If we have processed this symbol then we left a forwarding
2718 * pointer to the corresponding GDB symbol. If not, we`ll put
2719 * it in a list of pending symbols, to be processed later when
2720 * the file f will be. In any event, we collect the name for
2721 * the type here. Which is why we made a first pass at
2724 sh
= (SYMR
*) (fh
->isymBase
) + rn
->index
;
2726 /* Careful, we might be looking at .o files */
2727 *pname
= (UNSAFE_DATA_ADDR (sh
->iss
)) ? "<undefined>" :
2730 /* Have we parsed it ? */
2731 if ((!UNSAFE_DATA_ADDR (sh
->value
)) && (sh
->st
== stParsed
))
2733 t
= (struct type
*) sh
->value
;
2738 /* Avoid duplicates */
2739 struct mips_pending
*p
= is_pending_symbol (fh
, sh
);
2744 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
,
2745 (struct objfile
*) NULL
);
2746 add_pending (fh
, sh
, *tpp
);
2751 /* We used one auxent normally, two if we got a "next one" rf. */
2756 /* Quick&dirty lookup procedure, to avoid the MI ones that require
2757 keeping the symtab sorted */
2759 static struct symbol
*
2760 mylookup_symbol (name
, block
, namespace, class)
2762 register struct block
*block
;
2763 enum namespace namespace;
2764 enum address_class
class;
2766 register int bot
, top
, inc
;
2767 register struct symbol
*sym
;
2770 top
= BLOCK_NSYMS (block
);
2774 sym
= BLOCK_SYM (block
, bot
);
2775 if (SYMBOL_NAME (sym
)[0] == inc
2776 && SYMBOL_NAMESPACE (sym
) == namespace
2777 && SYMBOL_CLASS (sym
) == class
2778 && STREQ (SYMBOL_NAME (sym
), name
))
2782 block
= BLOCK_SUPERBLOCK (block
);
2784 return mylookup_symbol (name
, block
, namespace, class);
2789 /* Add a new symbol S to a block B.
2790 Infrequently, we will need to reallocate the block to make it bigger.
2791 We only detect this case when adding to top_stack->cur_block, since
2792 that's the only time we know how big the block is. FIXME. */
2799 int nsyms
= BLOCK_NSYMS (b
)++;
2800 struct block
*origb
;
2801 struct parse_stack
*stackp
;
2803 if (b
== top_stack
->cur_block
&&
2804 nsyms
>= top_stack
->maxsyms
)
2806 complain (&block_overflow_complaint
, SYMBOL_NAME (s
));
2807 /* In this case shrink_block is actually grow_block, since
2808 BLOCK_NSYMS(b) is larger than its current size. */
2810 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
2812 /* Now run through the stack replacing pointers to the
2813 original block. shrink_block has already done this
2814 for the blockvector and BLOCK_FUNCTION. */
2815 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
)
2817 if (stackp
->cur_block
== origb
)
2819 stackp
->cur_block
= b
;
2820 stackp
->maxsyms
= BLOCK_NSYMS (b
);
2824 BLOCK_SYM (b
, nsyms
) = s
;
2827 /* Add a new block B to a symtab S */
2834 struct blockvector
*bv
= BLOCKVECTOR (s
);
2836 bv
= (struct blockvector
*) xrealloc ((PTR
) bv
,
2837 sizeof (struct blockvector
) +
2838 BLOCKVECTOR_NBLOCKS (bv
)
2839 * sizeof (bv
->block
));
2840 if (bv
!= BLOCKVECTOR (s
))
2841 BLOCKVECTOR (s
) = bv
;
2843 BLOCKVECTOR_BLOCK (bv
, BLOCKVECTOR_NBLOCKS (bv
)++) = b
;
2846 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
2847 MIPS' linenumber encoding might need more than one byte
2848 to describe it, LAST is used to detect these continuation lines */
2851 add_line (lt
, lineno
, adr
, last
)
2852 struct linetable
*lt
;
2858 last
= -2; /* make sure we record first line */
2860 if (last
== lineno
) /* skip continuation lines */
2863 lt
->item
[lt
->nitems
].line
= lineno
;
2864 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
2868 /* Sorting and reordering procedures */
2870 /* Blocks with a smaller low bound should come first */
2873 compare_blocks (arg1
, arg2
)
2874 const void *arg1
, *arg2
;
2876 register int addr_diff
;
2877 struct block
**b1
= (struct block
**) arg1
;
2878 struct block
**b2
= (struct block
**) arg2
;
2880 addr_diff
= (BLOCK_START ((*b1
))) - (BLOCK_START ((*b2
)));
2882 return (BLOCK_END ((*b1
))) - (BLOCK_END ((*b2
)));
2886 /* Sort the blocks of a symtab S.
2887 Reorder the blocks in the blockvector by code-address,
2888 as required by some MI search routines */
2894 struct blockvector
*bv
= BLOCKVECTOR (s
);
2896 if (BLOCKVECTOR_NBLOCKS (bv
) <= 2)
2899 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) == 0)
2900 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = 0;
2901 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) == 0)
2902 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) = 0;
2906 * This is very unfortunate: normally all functions are compiled in
2907 * the order they are found, but if the file is compiled -O3 things
2908 * are very different. It would be nice to find a reliable test
2909 * to detect -O3 images in advance.
2911 if (BLOCKVECTOR_NBLOCKS (bv
) > 3)
2912 qsort (&BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
),
2913 BLOCKVECTOR_NBLOCKS (bv
) - FIRST_LOCAL_BLOCK
,
2914 sizeof (struct block
*),
2918 register CORE_ADDR high
= 0;
2919 register int i
, j
= BLOCKVECTOR_NBLOCKS (bv
);
2921 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
2922 if (high
< BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
)))
2923 high
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
));
2924 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = high
;
2927 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) =
2928 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
));
2930 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
2931 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
2932 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
2933 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
2937 /* Constructor/restructor/destructor procedures */
2939 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
2940 MAXSYMS and linenumbers MAXLINES we'll put in it */
2942 static struct symtab
*
2943 new_symtab (name
, maxsyms
, maxlines
, objfile
)
2947 struct objfile
*objfile
;
2949 struct symtab
*s
= allocate_symtab (name
, objfile
);
2951 LINETABLE (s
) = new_linetable (maxlines
);
2953 /* All symtabs must have at least two blocks */
2954 BLOCKVECTOR (s
) = new_bvect (2);
2955 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
) = new_block (maxsyms
);
2956 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
) = new_block (maxsyms
);
2957 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
)) =
2958 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
);
2960 s
->free_code
= free_linetable
;
2965 /* Allocate a new partial_symtab NAME */
2967 static struct partial_symtab
*
2968 new_psymtab (name
, objfile
)
2970 struct objfile
*objfile
;
2972 struct partial_symtab
*psymtab
;
2974 /* FIXME -- why (char *) -1 rather than NULL? */
2975 psymtab
= allocate_psymtab (name
== (char *) -1 ? "<no name>" : name
,
2978 /* Keep a backpointer to the file's symbols */
2980 psymtab
->read_symtab_private
= ((char *)
2981 obstack_alloc (&objfile
->psymbol_obstack
,
2982 sizeof (struct symloc
)));
2983 CUR_HDR (psymtab
) = cur_hdr
;
2985 /* The way to turn this into a symtab is to call... */
2986 psymtab
->read_symtab
= mipscoff_psymtab_to_symtab
;
2991 /* Allocate a linetable array of the given SIZE. Since the struct
2992 already includes one item, we subtract one when calculating the
2993 proper size to allocate. */
2995 static struct linetable
*
2996 new_linetable (size
)
2999 struct linetable
*l
;
3001 size
= (size
- 1) * sizeof (l
->item
) + sizeof (struct linetable
);
3002 l
= (struct linetable
*) xmalloc (size
);
3007 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
3008 I am not so sure about the 3.4 ones.
3010 Since the struct linetable already includes one item, we subtract one when
3011 calculating the proper size to allocate. */
3013 static struct linetable
*
3014 shrink_linetable (lt
)
3015 struct linetable
*lt
;
3018 return (struct linetable
*) xrealloc ((PTR
) lt
,
3019 sizeof (struct linetable
)
3020 + (lt
->nitems
- 1) * sizeof (lt
->item
));
3023 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
3025 static struct blockvector
*
3029 struct blockvector
*bv
;
3032 size
= sizeof (struct blockvector
) + nblocks
* sizeof (struct block
*);
3033 bv
= (struct blockvector
*) xzalloc (size
);
3035 BLOCKVECTOR_NBLOCKS (bv
) = nblocks
;
3040 /* Allocate and zero a new block of MAXSYMS symbols */
3042 static struct block
*
3046 int size
= sizeof (struct block
) + (maxsyms
- 1) * sizeof (struct symbol
*);
3048 return (struct block
*) xzalloc (size
);
3051 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
3052 Shrink_block can also be used by add_symbol to grow a block. */
3054 static struct block
*
3060 struct blockvector
*bv
= BLOCKVECTOR (s
);
3063 /* Just reallocate it and fix references to the old one */
3065 new = (struct block
*) xrealloc ((PTR
) b
, sizeof (struct block
) +
3066 (BLOCK_NSYMS (b
) - 1) * sizeof (struct symbol
*));
3068 /* Should chase pointers to old one. Fortunately, that`s just
3069 the block`s function and inferior blocks */
3070 if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b
)
3071 SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
3072 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
3073 if (BLOCKVECTOR_BLOCK (bv
, i
) == b
)
3074 BLOCKVECTOR_BLOCK (bv
, i
) = new;
3075 else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) == b
)
3076 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) = new;
3080 /* Create a new symbol with printname NAME */
3082 static struct symbol
*
3086 struct symbol
*s
= (struct symbol
*)
3087 obstack_alloc (¤t_objfile
->symbol_obstack
, sizeof (struct symbol
));
3089 memset ((PTR
) s
, 0, sizeof (*s
));
3090 SYMBOL_NAME (s
) = name
;
3094 /* Create a new type with printname NAME */
3096 static struct type
*
3102 t
= alloc_type (current_objfile
);
3103 TYPE_NAME (t
) = name
;
3104 TYPE_CPLUS_SPECIFIC (t
) = ((struct cplus_struct_type
*)
3105 &cplus_struct_default
);
3110 /* Things used for calling functions in the inferior.
3111 These functions are exported to our companion
3112 mips-tdep.c file and are here because they play
3113 with the symbol-table explicitly. */
3115 /* Sigtramp: make sure we have all the necessary information
3116 about the signal trampoline code. Since the official code
3117 from MIPS does not do so, we make up that information ourselves.
3118 If they fix the library (unlikely) this code will neutralize itself. */
3125 struct block
*b
, *b0
;
3127 sigtramp_address
= -1;
3129 /* We know it is sold as sigvec */
3130 s
= lookup_symbol ("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
3132 /* Most programs do not play with signals */
3134 s
= lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
3137 b0
= SYMBOL_BLOCK_VALUE (s
);
3139 /* A label of sigvec, to be more precise */
3140 s
= lookup_symbol ("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
3143 /* But maybe this program uses its own version of sigvec */
3147 /* Did we or MIPSco fix the library ? */
3148 if (SYMBOL_CLASS (s
) == LOC_BLOCK
)
3150 sigtramp_address
= BLOCK_START (SYMBOL_BLOCK_VALUE (s
));
3151 sigtramp_end
= BLOCK_END (SYMBOL_BLOCK_VALUE (s
));
3155 sigtramp_address
= SYMBOL_VALUE (s
);
3156 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
3158 /* But what symtab does it live in ? */
3159 st
= find_pc_symtab (SYMBOL_VALUE (s
));
3162 * Ok, there goes the fix: turn it into a procedure, with all the
3163 * needed info. Note we make it a nested procedure of sigvec,
3164 * which is the way the (assembly) code is actually written.
3166 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
3167 SYMBOL_CLASS (s
) = LOC_BLOCK
;
3168 SYMBOL_TYPE (s
) = init_type (TYPE_CODE_FUNC
, 4, 0, (char *) NULL
,
3169 (struct objfile
*) NULL
);
3170 TYPE_TARGET_TYPE (SYMBOL_TYPE (s
)) = builtin_type_void
;
3172 /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
3174 SYMBOL_BLOCK_VALUE (s
) = b
;
3175 BLOCK_START (b
) = sigtramp_address
;
3176 BLOCK_END (b
) = sigtramp_end
;
3177 BLOCK_FUNCTION (b
) = s
;
3178 BLOCK_SUPERBLOCK (b
) = BLOCK_SUPERBLOCK (b0
);
3182 /* Make a MIPS_EFI_SYMBOL_NAME entry for it */
3184 struct mips_extra_func_info
*e
=
3185 ((struct mips_extra_func_info
*)
3186 xzalloc (sizeof (struct mips_extra_func_info
)));
3188 e
->numargs
= 0; /* the kernel thinks otherwise */
3189 /* align_longword(sigcontext + SIGFRAME) */
3190 e
->pdr
.frameoffset
= 0x150;
3191 e
->pdr
.framereg
= SP_REGNUM
;
3193 e
->pdr
.regmask
= -2;
3194 e
->pdr
.regoffset
= -(41 * sizeof (int));
3195 e
->pdr
.fregmask
= -1;
3196 e
->pdr
.fregoffset
= -(37 * sizeof (int));
3197 e
->pdr
.isym
= (long) s
;
3199 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
3200 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
3201 SYMBOL_VALUE (s
) = (int) e
;
3202 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
3203 SYMBOL_CLASS (s
) = LOC_CONST
;
3204 SYMBOL_TYPE (s
) = builtin_type_void
;
3205 current_objfile
= NULL
;
3208 BLOCK_SYM (b
, BLOCK_NSYMS (b
)++) = s
;
3212 /* Fake up identical offsets for all sections. */
3214 struct section_offsets
*
3215 mipscoff_symfile_offsets (objfile
, addr
)
3216 struct objfile
*objfile
;
3219 struct section_offsets
*section_offsets
;
3222 section_offsets
= ((struct section_offsets
*)
3223 obstack_alloc (&objfile
->psymbol_obstack
,
3224 (sizeof (struct section_offsets
)
3225 + (sizeof (section_offsets
->offsets
)
3226 * (SECT_OFF_MAX
- 1)))));
3228 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
3229 ANOFFSET (section_offsets
, i
) = addr
;
3231 return section_offsets
;
3234 /* Initialization */
3236 static struct sym_fns ecoff_sym_fns
=
3238 "ecoff", /* sym_name: name or name prefix of BFD target type */
3239 5, /* sym_namelen: number of significant sym_name chars */
3240 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
3241 mipscoff_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
3242 mipscoff_symfile_read
, /* sym_read: read a symbol file into symtab */
3243 mipscoff_symfile_finish
, /* sym_finish: finished with file, cleanup */
3244 mipscoff_symfile_offsets
, /* sym_offsets: dummy FIXME til implem sym reloc */
3245 NULL
/* next: pointer to next struct sym_fns */
3250 _initialize_mipsread ()
3252 add_symtab_fns (&ecoff_sym_fns
);
3254 /* Missing basic types */
3256 builtin_type_string
=
3257 init_type (TYPE_CODE_STRING
,
3258 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3260 (struct objfile
*) NULL
);
3261 builtin_type_complex
=
3262 init_type (TYPE_CODE_FLT
,
3263 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3265 (struct objfile
*) NULL
);
3266 builtin_type_double_complex
=
3267 init_type (TYPE_CODE_FLT
,
3268 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3269 0, "double complex",
3270 (struct objfile
*) NULL
);
3271 builtin_type_fixed_dec
=
3272 init_type (TYPE_CODE_INT
,
3273 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3275 (struct objfile
*) NULL
);
3276 builtin_type_float_dec
=
3277 init_type (TYPE_CODE_FLT
,
3278 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3279 0, "floating decimal",
3280 (struct objfile
*) NULL
);