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"
63 #include <sys/types.h>
68 #include <sys/param.h>
72 #include "gdb-stabs.h"
74 #include "coff/mips.h" /* COFF-like aspects of ecoff files */
75 #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */
77 #include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */
78 #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
79 #include "aout/aout64.h"
80 #include "aout/stab_gnu.h" /* STABS information */
83 struct external_filehdr f
;
84 struct external_aouthdr a
;
87 /* These must match the corresponding definition in gcc/config/xm-mips.h.
88 At some point, these should probably go into a shared include file,
89 but currently gcc and gdb do not share any directories. */
91 #define CODE_MASK 0x8F300
92 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
93 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
94 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
95 #define STABS_SYMBOL "@stabs"
97 /* Each partial symbol table entry contains a pointer to private data for the
98 read_symtab() function to use when expanding a partial symbol table entry
99 to a full symbol table entry.
101 For mipsread this structure contains the index of the FDR that this psymtab
102 represents and a pointer to the symbol table header HDRR from the symbol
103 file that the psymtab was created from. */
105 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
106 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
107 #define CUR_HDR(p) (PST_PRIVATE(p)->cur_hdr)
112 EXTR
**extern_tab
; /* Pointer to external symbols for this file. */
113 int extern_count
; /* Size of extern_tab. */
116 /* Things we import explicitly from other modules */
118 extern int info_verbose
;
120 /* Various complaints about symbol reading that don't abort the process */
122 struct complaint bad_file_number_complaint
=
123 {"bad file number %d", 0, 0};
125 struct complaint index_complaint
=
126 {"bad aux index at symbol %s", 0, 0};
128 struct complaint aux_index_complaint
=
129 {"bad proc end in aux found from symbol %s", 0, 0};
131 struct complaint unknown_ext_complaint
=
132 {"unknown external symbol %s", 0, 0};
134 struct complaint unknown_sym_complaint
=
135 {"unknown local symbol %s", 0, 0};
137 struct complaint unknown_st_complaint
=
138 {"with type %d", 0, 0};
140 struct complaint block_overflow_complaint
=
141 {"block containing %s overfilled", 0, 0};
143 struct complaint basic_type_complaint
=
144 {"cannot map MIPS basic type 0x%x", 0, 0};
146 struct complaint unknown_type_qual_complaint
=
147 {"unknown type qualifier 0x%x", 0, 0};
149 struct complaint array_bitsize_complaint
=
150 {"size of array target type not known, assuming %d bits", 0, 0};
152 struct complaint bad_tag_guess_complaint
=
153 {"guessed tag type of %s incorrectly", 0, 0};
155 struct complaint block_member_complaint
=
156 {"declaration block contains unhandled symbol type %d", 0, 0};
158 struct complaint stEnd_complaint
=
159 {"stEnd with storage class %d not handled", 0, 0};
161 struct complaint unknown_mips_symtype_complaint
=
162 {"unknown symbol type 0x%x", 0, 0};
164 struct complaint stab_unknown_complaint
=
165 {"unknown stabs symbol %s", 0, 0};
167 struct complaint pdr_for_nonsymbol_complaint
=
168 {"PDR for %s, but no symbol", 0, 0};
170 struct complaint pdr_static_symbol_complaint
=
171 {"can't handle PDR for static proc at 0x%x", 0, 0};
173 /* Macros and extra defs */
175 /* Already-parsed symbols are marked specially */
177 #define stParsed stType
179 /* Puns: hard to find whether -g was used and how */
181 #define MIN_GLEVEL GLEVEL_0
182 #define compare_glevel(a,b) \
183 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
184 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
186 /* When looking at .o files, avoid tripping over zero pointers.
187 FIXME; places that use this should be fixed to convert from
188 external to internal format, rather than examining in-place. */
190 #define UNSAFE_DATA_ADDR(p) ((p) == 0)
192 /* Things that really are local to this module */
194 /* MIPS symtab header for the current file */
196 static HDRR
*cur_hdr
;
198 /* Pointer to current file decriptor record, and its index */
203 /* Index of current symbol */
207 /* Note how much "debuggable" this image is. We would like
208 to see at least one FDR with full symbols */
213 /* When examining .o files, report on undefined symbols */
215 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
217 /* Pseudo symbol to use when putting stabs into the symbol table. */
219 static char stabs_symbol
[] = STABS_SYMBOL
;
221 /* Extra builtin types */
223 struct type
*builtin_type_complex
;
224 struct type
*builtin_type_double_complex
;
225 struct type
*builtin_type_fixed_dec
;
226 struct type
*builtin_type_float_dec
;
227 struct type
*builtin_type_string
;
229 /* Forward declarations */
232 fixup_symtab
PARAMS ((HDRR
*, char *, file_ptr
, bfd
*));
235 read_mips_symtab
PARAMS ((struct objfile
*, struct section_offsets
*));
238 read_the_mips_symtab
PARAMS ((bfd
*, CORE_ADDR
*));
241 upgrade_type
PARAMS ((struct type
**, int, union aux_ext
*, int));
244 parse_partial_symbols
PARAMS ((int, struct objfile
*,
245 struct section_offsets
*));
248 cross_ref
PARAMS ((union aux_ext
*, struct type
**, enum type_code
, char **,
252 fixup_sigtramp
PARAMS ((void));
254 static struct symbol
*
255 new_symbol
PARAMS ((char *));
258 new_type
PARAMS ((char *));
260 static struct block
*
261 new_block
PARAMS ((int));
263 static struct symtab
*
264 new_symtab
PARAMS ((char *, int, int, struct objfile
*));
266 static struct linetable
*
267 new_linetable
PARAMS ((int));
269 static struct blockvector
*
270 new_bvect
PARAMS ((int));
273 parse_type
PARAMS ((union aux_ext
*, int *, int));
275 static struct symbol
*
276 mylookup_symbol
PARAMS ((char *, struct block
*, enum namespace,
277 enum address_class
));
279 static struct block
*
280 shrink_block
PARAMS ((struct block
*, struct symtab
*));
283 xzalloc
PARAMS ((unsigned int));
286 sort_blocks
PARAMS ((struct symtab
*));
289 compare_blocks
PARAMS ((const void *, const void *));
291 static struct partial_symtab
*
292 new_psymtab
PARAMS ((char *, struct objfile
*));
295 static struct partial_symtab
*
296 parse_fdr
PARAMS ((int, int, struct objfile
*));
300 psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*, char *));
303 add_block
PARAMS ((struct block
*, struct symtab
*));
306 add_symbol
PARAMS ((struct symbol
*, struct block
*));
309 add_line
PARAMS ((struct linetable
*, int, CORE_ADDR
, int));
311 static struct linetable
*
312 shrink_linetable
PARAMS ((struct linetable
*));
315 mips_next_symbol_text
PARAMS ((void));
317 /* Things we export to other modules */
319 /* Address bounds for the signal trampoline in inferior, if any */
320 /* FIXME: Nothing really seems to use this. Why is it here? */
322 CORE_ADDR sigtramp_address
, sigtramp_end
;
325 mipscoff_new_init (ignore
)
326 struct objfile
*ignore
;
331 mipscoff_symfile_init (objfile
)
332 struct objfile
*objfile
;
334 if (objfile
-> sym_private
!= NULL
)
336 mfree (objfile
-> md
, objfile
-> sym_private
);
338 objfile
-> sym_private
= NULL
;
342 mipscoff_symfile_read (objfile
, section_offsets
, mainline
)
343 struct objfile
*objfile
;
344 struct section_offsets
*section_offsets
;
347 init_minimal_symbol_collection ();
348 make_cleanup (discard_minimal_symbols
, 0);
350 /* Now that the executable file is positioned at symbol table,
351 process it and define symbols accordingly. */
353 read_mips_symtab(objfile
, section_offsets
);
355 /* Install any minimal symbols that have been collected as the current
356 minimal symbols for this objfile. */
358 install_minimal_symbols (objfile
);
361 /* Perform any local cleanups required when we are done with a particular
362 objfile. I.E, we are in the process of discarding all symbol information
363 for an objfile, freeing up all memory held for it, and unlinking the
364 objfile struct from the global list of known objfiles. */
367 mipscoff_symfile_finish (objfile
)
368 struct objfile
*objfile
;
370 if (objfile
-> sym_private
!= NULL
)
372 mfree (objfile
-> md
, objfile
-> sym_private
);
375 /* If we have a file symbol header lying around, blow it away. */
384 /* Allocate zeroed memory */
390 PTR p
= xmalloc (size
);
396 /* Exported procedure: Builds a symtab from the PST partial one.
397 Restores the environment in effect when PST was created, delegates
398 most of the work to an ancillary procedure, and sorts
399 and reorders the symtab list at the end */
402 mipscoff_psymtab_to_symtab(pst
)
403 struct partial_symtab
*pst
;
410 printf_filtered("Reading in symbols for %s...", pst
->filename
);
413 /* Restore the header and list of pending typedefs */
414 cur_hdr
= CUR_HDR(pst
);
416 next_symbol_text_func
= mips_next_symbol_text
;
418 psymtab_to_symtab_1(pst
, pst
->filename
);
420 /* Match with global symbols. This only needs to be done once,
421 after all of the symtabs and dependencies have been read in. */
422 scan_file_globals (pst
->objfile
);
425 printf_filtered("done.\n");
428 /* Exported procedure: Is PC in the signal trampoline code */
431 in_sigtramp(pc
, ignore
)
433 char *ignore
; /* function name */
435 if (sigtramp_address
== 0)
437 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
440 /* File-level interface functions */
442 /* Read the symtab information from file ABFD into memory. Also,
443 return address just past end of our text segment in *END_OF_TEXT_SEGP. */
446 read_the_mips_symtab(abfd
, end_of_text_segp
)
448 CORE_ADDR
*end_of_text_segp
;
450 int stsize
, st_hdrsize
;
452 struct hdr_ext hdr_ext
;
454 /* Header for executable/object file we read symbols from */
455 struct coff_exec filhdr
;
458 /* We need some info from the initial headers */
459 val
= bfd_seek(abfd
, (file_ptr
) 0, L_SET
);
460 val
= bfd_read((PTR
)&filhdr
, sizeof filhdr
, 1, abfd
);
462 if (end_of_text_segp
)
464 bfd_h_get_32 (abfd
, filhdr
.a
.text_start
) +
465 bfd_h_get_32 (abfd
, filhdr
.a
.tsize
);
467 /* Find and read the symbol table header */
468 st_hdrsize
= bfd_h_get_32 (abfd
, filhdr
.f
.f_nsyms
);
469 st_filptr
= bfd_h_get_32 (abfd
, filhdr
.f
.f_symptr
);
473 bfd_seek (abfd
, st_filptr
, L_SET
);
474 if (st_hdrsize
!= sizeof (hdr_ext
)) { /* Profanity check */
475 error ("Wrong header size: %d, not %d", st_hdrsize
,
478 if (bfd_read((PTR
)&hdr_ext
, st_hdrsize
, 1, abfd
) != st_hdrsize
)
480 ecoff_swap_hdr_in (abfd
, &hdr_ext
, &st_hdr
);
482 /* Find out how large the symbol table is */
483 stsize
= (st_hdr
.cbExtOffset
- (st_filptr
+ st_hdrsize
))
484 + st_hdr
.iextMax
* cbEXTR
;
486 /* Allocate space for the symbol table. Read it in. */
487 cur_hdr
= (HDRR
*) xmalloc(stsize
+ st_hdrsize
);
489 memcpy((PTR
)cur_hdr
, (PTR
)&hdr_ext
, st_hdrsize
);
490 if (bfd_read((char *)cur_hdr
+ st_hdrsize
, stsize
, 1, abfd
) != stsize
)
493 /* Fixup file_pointers in it */
494 fixup_symtab(cur_hdr
, (char *) cur_hdr
+ st_hdrsize
,
495 st_filptr
+ st_hdrsize
, abfd
);
499 error("Short read on %s", bfd_get_filename (abfd
));
503 /* Turn all file-relative pointers in the symtab described by HDR
504 into memory pointers, given that the symtab itself is located
505 at DATA in memory and F_PTR in the file.
507 Byte-swap all the data structures, in place, while we are at it --
508 except AUX entries, which we leave in their original byte order.
509 They will be swapped as they are used instead. (FIXME: we ought to
510 do all the data structures that way.) */
513 fixup_symtab (hdr
, data
, f_ptr
, abfd
)
524 struct rfd_ext
*rbase
;
526 /* This function depends on the external and internal forms
527 of the MIPS symbol table taking identical space. Check this
528 assumption at compile-time.
529 DO NOT DELETE THESE ENTRIES, OR COMMENT THEM OUT, JUST BECAUSE SOME
530 "LINT" OR COMPILER THINKS THEY ARE UNUSED! Thank you. */
531 static check_hdr1
[1 + sizeof (struct hdr_ext
) - sizeof (HDRR
)] = {0};
532 static check_hdr2
[1 + sizeof (HDRR
) - sizeof (struct hdr_ext
)] = {0};
533 static check_fdr1
[1 + sizeof (struct fdr_ext
) - sizeof (FDR
)] = {0};
534 static check_fdr2
[1 + sizeof (FDR
) - sizeof (struct fdr_ext
)] = {0};
535 static check_pdr1
[1 + sizeof (struct pdr_ext
) - sizeof (PDR
)] = {0};
536 static check_pdr2
[1 + sizeof (PDR
) - sizeof (struct pdr_ext
)] = {0};
537 static check_sym1
[1 + sizeof (struct sym_ext
) - sizeof (SYMR
)] = {0};
538 static check_sym2
[1 + sizeof (SYMR
) - sizeof (struct sym_ext
)] = {0};
539 static check_ext1
[1 + sizeof (struct ext_ext
) - sizeof (EXTR
)] = {0};
540 static check_ext2
[1 + sizeof (EXTR
) - sizeof (struct ext_ext
)] = {0};
541 static check_rfd1
[1 + sizeof (struct rfd_ext
) - sizeof (RFDT
)] = {0};
542 static check_rfd2
[1 + sizeof (RFDT
) - sizeof (struct rfd_ext
)] = {0};
544 /* Swap in the header record. */
545 ecoff_swap_hdr_in (abfd
, hdr
, hdr
);
548 * These fields are useless (and empty) by now:
549 * hdr->cbDnOffset, hdr->cbOptOffset
550 * We use them for other internal purposes.
553 hdr
->cbOptOffset
= 0;
556 if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr);
570 /* Fix all the RFD's. */
571 rbase
= (struct rfd_ext
*)(hdr
->cbRfdOffset
);
572 for (i
= 0; i
< hdr
->crfd
; i
++) {
573 ecoff_swap_rfd_in (abfd
, rbase
+i
, (pRFDT
) rbase
+i
);
576 /* Fix all string pointers inside the symtab, and
577 the FDR records. Also fix other miscellany. */
579 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
580 register unsigned code_offset
;
582 /* Header itself, and strings */
583 fh
= (FDR
*) (hdr
->cbFdOffset
) + f_idx
;
585 /* Swap in the FDR */
586 ecoff_swap_fdr_in (abfd
, fh
, fh
);
588 fh
->issBase
+= hdr
->cbSsOffset
;
590 fh
->rss
= (long)fh
->rss
+ fh
->issBase
;
593 fh
->isymBase
= (int)((SYMR
*)(hdr
->cbSymOffset
)+fh
->isymBase
);
595 /* FIXME! Probably don't want to do this here! */
596 for (s_idx
= 0; s_idx
< fh
->csym
; s_idx
++) {
597 sh
= (SYMR
*)fh
->isymBase
+ s_idx
;
598 ecoff_swap_sym_in (abfd
, sh
, sh
);
600 sh
->iss
= (long) sh
->iss
+ fh
->issBase
;
606 /* cannot fix fh->ipdFirst because it is a short */
607 #define IPDFIRST(h,fh) \
608 ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR))
610 /* Optional symbols (actually used for partial_symtabs) */
616 fh
->iauxBase
= hdr
->cbAuxOffset
+ fh
->iauxBase
* sizeof(union aux_ext
);
617 /* Relative file descriptor table */
618 fh
->rfdBase
= hdr
->cbRfdOffset
+ fh
->rfdBase
* sizeof(RFDT
);
622 fh
->cbLineOffset
+= hdr
->cbLineOffset
;
624 /* Procedure symbols. (XXX This should be done later) */
625 code_offset
= fh
->adr
;
626 for (s_idx
= 0; s_idx
< fh
->cpd
; s_idx
++) {
627 unsigned name
, only_ext
;
629 pr
= (PDR
*)(IPDFIRST(hdr
,fh
)) + s_idx
;
630 ecoff_swap_pdr_in (abfd
, pr
, pr
);
632 /* Simple rule to find files linked "-x" */
633 only_ext
= fh
->rss
== -1;
635 if (pr
->isym
== -1) {
636 /* static function */
640 name
= hdr
->cbExtOffset
+ pr
->isym
* sizeof(EXTR
);
641 sh
= &((EXTR
*)name
)->asym
;
645 sh
= (SYMR
*)fh
->isymBase
+ pr
->isym
;
646 /* Included code ? */
647 if (s_idx
== 0 && pr
->adr
!= 0)
648 code_offset
-= pr
->adr
;
651 /* Turn index into a pointer */
654 /* Fix line numbers */
655 pr
->cbLineOffset
+= fh
->cbLineOffset
;
657 /* Relocate address */
659 pr
->adr
+= code_offset
;
663 /* External symbols: swap in, and fix string */
664 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
665 esh
= (EXTR
*)(hdr
->cbExtOffset
) + s_idx
;
666 ecoff_swap_ext_in (abfd
, esh
, esh
);
667 esh
->asym
.iss
= esh
->asym
.iss
+ hdr
->cbSsExtOffset
;
672 /* Find a file descriptor given its index RF relative to a file CF */
680 f
= (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
681 /* Object files do not have the RFD table, all refs are absolute */
683 return (FDR
*) (cur_hdr
->cbFdOffset
) + rf
;
684 cf
= *((pRFDT
) f
->rfdBase
+ rf
);
685 return (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
688 /* Return a safer print NAME for a file descriptor */
694 if (name
== (char *) -1)
695 return "<stripped file>";
696 if (UNSAFE_DATA_ADDR(name
))
702 /* Read in and parse the symtab of the file OBJFILE. Symbols from
703 different sections are relocated via the SECTION_OFFSETS. */
706 read_mips_symtab (objfile
, section_offsets
)
707 struct objfile
*objfile
;
708 struct section_offsets
*section_offsets
;
710 CORE_ADDR end_of_text_seg
;
712 read_the_mips_symtab(objfile
->obfd
, &end_of_text_seg
);
714 parse_partial_symbols(end_of_text_seg
, objfile
, section_offsets
);
718 * Check to make sure file was compiled with -g.
719 * If not, warn the user of this limitation.
721 if (compare_glevel(max_glevel
, GLEVEL_2
) < 0) {
722 if (max_gdbinfo
== 0)
724 "\n%s not compiled with -g, debugging support is limited.\n",
727 "You should compile with -g2 or -g3 for best debugging support.\n");
733 /* Local utilities */
735 /* Map of FDR indexes to partial symtabs */
738 struct partial_symtab
*pst
; /* the psymtab proper */
739 int n_globals
; /* exported globals (external symbols) */
740 int globals_offset
; /* cumulative */
744 /* Utility stack, used to nest procedures and blocks properly.
745 It is a doubly linked list, to avoid too many alloc/free.
746 Since we might need it quite a few times it is NOT deallocated
749 static struct parse_stack
{
750 struct parse_stack
*next
, *prev
;
751 struct symtab
*cur_st
; /* Current symtab. */
752 struct block
*cur_block
; /* Block in it. */
753 int blocktype
; /* What are we parsing. */
754 int maxsyms
; /* Max symbols in this block. */
755 struct type
*cur_type
; /* Type we parse fields for. */
756 int cur_field
; /* Field number in cur_type. */
757 int procadr
; /* Start addres of this procedure */
758 int numargs
; /* Its argument count */
759 } *top_stack
; /* Top stack ptr */
762 /* Enter a new lexical context */
767 struct parse_stack
*new;
769 /* Reuse frames if possible */
770 if (top_stack
&& top_stack
->prev
)
771 new = top_stack
->prev
;
773 new = (struct parse_stack
*) xzalloc(sizeof(struct parse_stack
));
774 /* Initialize new frame with previous content */
776 register struct parse_stack
*prev
= new->prev
;
779 top_stack
->prev
= new;
781 new->next
= top_stack
;
786 /* Exit a lexical context */
794 top_stack
= top_stack
->next
;
798 /* Cross-references might be to things we haven't looked at
799 yet, e.g. type references. To avoid too many type
800 duplications we keep a quick fixup table, an array
801 of lists of references indexed by file descriptor */
803 static struct mips_pending
{
804 struct mips_pending
*next
; /* link */
805 SYMR
*s
; /* the symbol */
806 struct type
*t
; /* its partial type descriptor */
810 /* Check whether we already saw symbol SH in file FH as undefined */
812 static struct mips_pending
*
813 is_pending_symbol(fh
, sh
)
817 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
818 register struct mips_pending
*p
;
820 /* Linear search is ok, list is typically no more than 10 deep */
821 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
827 /* Add a new undef symbol SH of type T */
830 add_pending(fh
, sh
, t
)
835 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
836 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
838 /* Make sure we do not make duplicates */
840 p
= (struct mips_pending
*) xmalloc(sizeof(*p
));
843 p
->next
= pending_list
[f_idx
];
844 pending_list
[f_idx
] = p
;
846 sh
->reserved
= 1; /* for quick check */
849 /* Throw away undef entries when done with file index F_IDX */
850 /* FIXME -- storage leak. This is never called!!! --gnu */
858 register struct mips_pending
*p
, *q
;
860 for (p
= pending_list
[f_idx
]; p
; p
= q
) {
864 pending_list
[f_idx
] = 0;
870 prepend_tag_kind(tag_name
, type_code
)
872 enum type_code type_code
;
880 case TYPE_CODE_STRUCT
:
883 case TYPE_CODE_UNION
:
890 result
= (char*)obstack_alloc (¤t_objfile
->symbol_obstack
,
891 strlen(prefix
) + strlen(tag_name
) + 1);
892 sprintf(result
, "%s%s", prefix
, tag_name
);
897 /* Parsing Routines proper. */
899 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
900 For blocks, procedures and types we open a new lexical context.
901 This is basically just a big switch on the symbol's type.
902 Argument AX is the base pointer of aux symbols for this file (fh->iauxBase).
903 BIGEND says whether aux symbols are big-endian or little-endian.
904 Return count of SYMR's handled (normally one). */
907 parse_symbol(sh
, ax
, bigend
)
918 /* When a symbol is cross-referenced from other files/symbols
919 we mark it explicitly */
920 int pend
= (sh
->reserved
== 1);
921 enum address_class
class;
929 case stGlobal
: /* external symbol, goes into global block */
931 b
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
933 s
= new_symbol((char *)sh
->iss
);
934 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
937 case stStatic
: /* static data, goes into current block. */
939 b
= top_stack
->cur_block
;
940 s
= new_symbol((char *)sh
->iss
);
941 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
944 case stLocal
: /* local variable, goes into current block */
945 if (sh
->sc
== scRegister
) {
946 class = LOC_REGISTER
;
948 sh
->value
+= FP0_REGNUM
-32;
951 b
= top_stack
->cur_block
;
952 s
= new_symbol((char *)sh
->iss
);
953 SYMBOL_VALUE(s
) = sh
->value
;
955 data
: /* Common code for symbols describing data */
956 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
957 SYMBOL_CLASS(s
) = class;
960 /* Type could be missing in a number of cases */
961 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
962 sh
->index
== 0xfffff)
963 SYMBOL_TYPE(s
) = builtin_type_int
; /* undefined? */
965 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
966 /* Value of a data symbol is its memory address */
969 case stParam
: /* arg to procedure, goes into current block */
971 top_stack
->numargs
++;
973 name
= (char*)sh
->iss
;
974 /* Special GNU C++ name. */
975 if (name
[0] == CPLUS_MARKER
&& name
[1] == 't' && name
[2] == 0)
976 name
= "this"; /* FIXME, not alloc'd in obstack */
977 s
= new_symbol(name
);
979 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
980 if (sh
->sc
== scRegister
) {
981 SYMBOL_CLASS(s
) = LOC_REGPARM
;
983 sh
->value
+= FP0_REGNUM
-32;
985 SYMBOL_CLASS(s
) = LOC_ARG
;
986 SYMBOL_VALUE(s
) = sh
->value
;
987 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
988 add_symbol(s
, top_stack
->cur_block
);
990 /* FIXME: This has not been tested. See dbxread.c */
991 /* Add the type of this parameter to the function/procedure
992 type of this block. */
993 add_param_to_type(&top_stack
->cur_block
->function
->type
,s
);
997 case stLabel
: /* label, goes into current block */
998 s
= new_symbol((char *)sh
->iss
);
999 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
; /* so that it can be used */
1000 SYMBOL_CLASS(s
) = LOC_LABEL
; /* but not misused */
1001 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
1002 SYMBOL_TYPE(s
) = builtin_type_int
;
1003 add_symbol(s
, top_stack
->cur_block
);
1006 case stProc
: /* Procedure, usually goes into global block */
1007 case stStaticProc
: /* Static procedure, goes into current block */
1008 s
= new_symbol((char *)sh
->iss
);
1009 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1010 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1011 /* Type of the return value */
1012 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1013 t
= builtin_type_int
;
1015 t
= parse_type(ax
+ sh
->index
+ 1, 0, bigend
);
1016 b
= top_stack
->cur_block
;
1017 if (sh
->st
== stProc
) {
1018 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1019 /* The next test should normally be true,
1020 but provides a hook for nested functions
1021 (which we don't want to make global). */
1022 if (b
== BLOCKVECTOR_BLOCK(bv
, STATIC_BLOCK
))
1023 b
= BLOCKVECTOR_BLOCK(bv
, GLOBAL_BLOCK
);
1027 /* Make a type for the procedure itself */
1029 /* FIXME: This has not been tested yet! See dbxread.c */
1030 /* Generate a template for the type of this function. The
1031 types of the arguments will be added as we read the symbol
1033 bcopy(SYMBOL_TYPE(s
),lookup_function_type(t
),sizeof(struct type
));
1035 SYMBOL_TYPE(s
) = lookup_function_type (t
);
1038 /* Create and enter a new lexical context */
1039 b
= new_block(top_stack
->maxsyms
);
1040 SYMBOL_BLOCK_VALUE(s
) = b
;
1041 BLOCK_FUNCTION(b
) = s
;
1042 BLOCK_START(b
) = BLOCK_END(b
) = sh
->value
;
1043 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1044 add_block(b
, top_stack
->cur_st
);
1046 /* Not if we only have partial info */
1047 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1051 top_stack
->cur_block
= b
;
1052 top_stack
->blocktype
= sh
->st
;
1053 top_stack
->cur_type
= SYMBOL_TYPE(s
);
1054 top_stack
->cur_field
= -1;
1055 top_stack
->procadr
= sh
->value
;
1056 top_stack
->numargs
= 0;
1058 sh
->value
= (long) SYMBOL_TYPE(s
);
1061 /* Beginning of code for structure, union, and enum definitions.
1062 They all share a common set of local variables, defined here. */
1064 enum type_code type_code
;
1070 case stStruct
: /* Start a block defining a struct type */
1071 type_code
= TYPE_CODE_STRUCT
;
1072 goto structured_common
;
1074 case stUnion
: /* Start a block defining a union type */
1075 type_code
= TYPE_CODE_UNION
;
1076 goto structured_common
;
1078 case stEnum
: /* Start a block defining an enum type */
1079 type_code
= TYPE_CODE_ENUM
;
1080 goto structured_common
;
1082 case stBlock
: /* Either a lexical block, or some type */
1083 if (sh
->sc
!= scInfo
)
1084 goto case_stBlock_code
; /* Lexical block */
1086 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
1088 /* Common code for handling struct, union, enum, and/or as-yet-
1089 unknown-type blocks of info about structured data. `type_code'
1090 has been set to the proper TYPE_CODE, if we know it. */
1093 top_stack
->blocktype
= stBlock
;
1095 s
= new_symbol((char *)sh
->iss
);
1096 SYMBOL_NAMESPACE(s
) = STRUCT_NAMESPACE
;
1097 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1098 SYMBOL_VALUE(s
) = 0;
1099 add_symbol(s
, top_stack
->cur_block
);
1101 /* First count the number of fields and the highest value. */
1104 for (tsym
= sh
+1; tsym
->st
!= stEnd
; tsym
++)
1106 if (tsym
->st
== stMember
) {
1107 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
1108 /* If the type of the member is Nil (or Void),
1109 assume the tag is an enumeration. */
1110 if (tsym
->index
== indexNil
)
1111 type_code
= TYPE_CODE_ENUM
;
1113 ecoff_swap_tir_in (bigend
,
1114 &ax
[tsym
->index
].a_ti
,
1116 if (tir
.bt
== btNil
|| tir
.bt
== btVoid
)
1117 type_code
= TYPE_CODE_ENUM
;
1120 if (tsym
->value
> max_value
)
1121 max_value
= tsym
->value
;
1123 else if (tsym
->st
== stBlock
1124 || tsym
->st
== stUnion
1125 || tsym
->st
== stEnum
1126 || tsym
->st
== stStruct
1127 || tsym
->st
== stParsed
) {
1128 if (tsym
->sc
== scVariant
) ; /*UNIMPLEMENTED*/
1129 if (tsym
->index
!= 0)
1130 tsym
= ((SYMR
*)cur_fdr
->isymBase
)
1133 else complain (&block_member_complaint
, (char *)tsym
->st
);
1136 /* In an stBlock, there is no way to distinguish structs,
1137 unions, and enums at this point. This is a bug in the
1138 original design (that has been fixed with the
1139 recent addition of the stStruct, stUnion, and stEnum
1140 symbol types.) The way you can tell is if/when you
1141 see a variable or field of that type. In that case
1142 the variable's type (in the AUX table) says if the
1143 type is struct, union, or enum,
1144 and points back to the stBlock here.
1145 So you can patch the tag kind up later - but only
1146 if there actually is a variable or field of that type.
1148 So until we know for sure, we will guess at this point.
1150 If the first member has index==indexNil or a void type,
1151 assume we have an enumeration.
1152 Otherwise, if there is more than one member, and all
1153 the members have offset 0, assume we have a union.
1154 Otherwise, assume we have a struct.
1156 The heuristic could guess wrong in the case of
1157 of an enumeration with no members or a union
1158 with one (or zero) members, or when all except the
1159 last field of a struct have width zero.
1160 These are uncommon and/or illegal situations, and
1161 in any case guessing wrong probably doesn't matter much.
1163 But if we later do find out we were wrong,
1164 we fixup the tag kind. Members of an enumeration
1165 must be handled differently from struct/union fields,
1166 and that is harder to patch up, but luckily we
1167 shouldn't need to. (If there are any enumeration
1168 members, we can tell for sure it's an enum here.) */
1170 if (type_code
== TYPE_CODE_UNDEF
)
1171 if (nfields
> 1 && max_value
== 0)
1172 type_code
= TYPE_CODE_UNION
;
1174 type_code
= TYPE_CODE_STRUCT
;
1176 /* If this type was expected, use its partial definition */
1178 t
= is_pending_symbol(cur_fdr
, sh
)->t
;
1180 t
= new_type(prepend_tag_kind((char *)sh
->iss
,
1183 TYPE_CODE(t
) = type_code
;
1184 TYPE_LENGTH(t
) = sh
->value
;
1185 TYPE_NFIELDS(t
) = nfields
;
1186 TYPE_FIELDS(t
) = f
= (struct field
*)
1187 TYPE_ALLOC (t
, nfields
* sizeof (struct field
));
1189 if (type_code
== TYPE_CODE_ENUM
) {
1190 /* This is a non-empty enum. */
1191 for (tsym
= sh
+ 1; tsym
->st
== stMember
; tsym
++) {
1192 struct symbol
*enum_sym
;
1193 f
->bitpos
= tsym
->value
;
1195 f
->name
= (char*)tsym
->iss
;
1198 enum_sym
= (struct symbol
*)
1199 obstack_alloc (¤t_objfile
->symbol_obstack
,
1200 sizeof (struct symbol
));
1201 memset ((PTR
)enum_sym
, 0, sizeof (struct symbol
));
1202 SYMBOL_NAME (enum_sym
) = f
->name
;
1203 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1204 SYMBOL_TYPE (enum_sym
) = t
;
1205 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1206 SYMBOL_VALUE (enum_sym
) = tsym
->value
;
1207 add_symbol(enum_sym
, top_stack
->cur_block
);
1209 /* Skip the stMembers that we've handled. */
1215 /* make this the current type */
1216 top_stack
->cur_type
= t
;
1217 top_stack
->cur_field
= 0;
1218 /* Mark that symbol has a type, and say which one */
1219 sh
->value
= (long) t
;
1222 /* End of local variables shared by struct, union, enum, and
1223 block (as yet unknown struct/union/enum) processing. */
1227 /* beginnning of (code) block. Value of symbol
1228 is the displacement from procedure start */
1230 top_stack
->blocktype
= stBlock
;
1231 b
= new_block(top_stack
->maxsyms
);
1232 BLOCK_START(b
) = sh
->value
+ top_stack
->procadr
;
1233 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1234 top_stack
->cur_block
= b
;
1235 add_block(b
, top_stack
->cur_st
);
1238 case stEnd
: /* end (of anything) */
1239 if (sh
->sc
== scInfo
) {
1240 /* Finished with type */
1241 top_stack
->cur_type
= 0;
1242 } else if (sh
->sc
== scText
&&
1243 (top_stack
->blocktype
== stProc
||
1244 top_stack
->blocktype
== stStaticProc
)) {
1245 /* Finished with procedure */
1246 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1247 struct mips_extra_func_info
*e
;
1251 BLOCK_END(top_stack
->cur_block
) += sh
->value
; /* size */
1253 /* Make up special symbol to contain procedure specific
1255 s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
1256 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
1257 SYMBOL_CLASS(s
) = LOC_CONST
;
1258 SYMBOL_TYPE(s
) = builtin_type_void
;
1259 e
= (struct mips_extra_func_info
*)
1260 obstack_alloc (¤t_objfile
->symbol_obstack
,
1261 sizeof (struct mips_extra_func_info
));
1262 SYMBOL_VALUE(s
) = (int)e
;
1263 e
->numargs
= top_stack
->numargs
;
1264 add_symbol(s
, top_stack
->cur_block
);
1266 /* Reallocate symbols, saving memory */
1267 b
= shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1269 /* f77 emits proc-level with address bounds==[0,0],
1270 So look for such child blocks, and patch them. */
1271 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++) {
1272 struct block
*b_bad
= BLOCKVECTOR_BLOCK(bv
,i
);
1273 if (BLOCK_SUPERBLOCK(b_bad
) == b
1274 && BLOCK_START(b_bad
) == top_stack
->procadr
1275 && BLOCK_END(b_bad
) == top_stack
->procadr
) {
1276 BLOCK_START(b_bad
) = BLOCK_START(b
);
1277 BLOCK_END(b_bad
) = BLOCK_END(b
);
1280 } else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
) {
1281 /* End of (code) block. The value of the symbol
1282 is the displacement from the procedure`s start
1283 address of the end of this block. */
1284 BLOCK_END(top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1285 shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1286 } else if (sh
->sc
== scText
&& top_stack
->blocktype
== stFile
) {
1287 /* End of file. Pop parse stack and ignore. Higher
1288 level code deals with this. */
1290 } else complain (&stEnd_complaint
, (char *)sh
->sc
);
1292 pop_parse_stack(); /* restore previous lexical context */
1295 case stMember
: /* member of struct or union */
1296 f
= &TYPE_FIELDS(top_stack
->cur_type
)[top_stack
->cur_field
++];
1297 f
->name
= (char*)sh
->iss
;
1298 f
->bitpos
= sh
->value
;
1300 f
->type
= parse_type(ax
+ sh
->index
, &f
->bitsize
, bigend
);
1303 case stTypedef
: /* type definition */
1304 s
= new_symbol((char *)sh
->iss
);
1305 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1306 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1307 SYMBOL_BLOCK_VALUE(s
) = top_stack
->cur_block
;
1308 add_symbol(s
, top_stack
->cur_block
);
1309 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
1310 sh
->value
= (long) SYMBOL_TYPE(s
);
1313 case stFile
: /* file name */
1315 top_stack
->blocktype
= sh
->st
;
1318 /* I`ve never seen these for C */
1320 break; /* register relocation */
1322 break; /* forwarding address */
1324 break; /* constant */
1326 complain(&unknown_mips_symtype_complaint
, (char *)sh
->st
);
1333 /* Parse the type information provided in the raw AX entries for
1334 the symbol SH. Return the bitfield size in BS, in case.
1335 We must byte-swap the AX entries before we use them; BIGEND says whether
1336 they are big-endian or little-endian (from fh->fBigendian). */
1338 static struct type
*
1339 parse_type(ax
, bs
, bigend
)
1344 /* Null entries in this map are treated specially */
1345 static struct type
**map_bt
[] =
1347 &builtin_type_void
, /* btNil */
1349 &builtin_type_char
, /* btChar */
1350 &builtin_type_unsigned_char
, /* btUChar */
1351 &builtin_type_short
, /* btShort */
1352 &builtin_type_unsigned_short
, /* btUShort */
1353 &builtin_type_int
, /* btInt */
1354 &builtin_type_unsigned_int
, /* btUInt */
1355 &builtin_type_long
, /* btLong */
1356 &builtin_type_unsigned_long
, /* btULong */
1357 &builtin_type_float
, /* btFloat */
1358 &builtin_type_double
, /* btDouble */
1365 &builtin_type_complex
, /* btComplex */
1366 &builtin_type_double_complex
, /* btDComplex */
1368 &builtin_type_fixed_dec
, /* btFixedDec */
1369 &builtin_type_float_dec
, /* btFloatDec */
1370 &builtin_type_string
, /* btString */
1373 &builtin_type_void
, /* btVoid */
1374 &builtin_type_long_long
, /* btLongLong */
1375 &builtin_type_unsigned_long_long
,/* btULongLong */
1379 struct type
*tp
= 0;
1382 enum type_code type_code
;
1384 /* Use aux as a type information record, map its basic type. */
1386 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1387 if (t
->bt
> (sizeof (map_bt
)/sizeof (*map_bt
))) {
1388 complain (&basic_type_complaint
, (char *)t
->bt
);
1389 return builtin_type_int
;
1391 if (map_bt
[t
->bt
]) {
1392 tp
= *map_bt
[t
->bt
];
1396 /* Cannot use builtin types -- build our own */
1399 tp
= lookup_pointer_type (builtin_type_void
);
1403 type_code
= TYPE_CODE_STRUCT
;
1407 type_code
= TYPE_CODE_UNION
;
1411 type_code
= TYPE_CODE_ENUM
;
1415 type_code
= TYPE_CODE_RANGE
;
1419 type_code
= TYPE_CODE_SET
;
1424 complain (&basic_type_complaint
, (char *)t
->bt
);
1425 return builtin_type_int
;
1429 /* Skip over any further type qualifiers (FIXME). */
1431 /* This is the way it would work if the compiler worked */
1435 ecoff_swap_tir_in (bigend
, ax
, t1
);
1436 } while (t1
->continued
);
1439 /* Move on to next aux */
1443 *bs
= AUX_GET_WIDTH (bigend
, ax
);
1447 /* All these types really point to some (common) MIPS type
1448 definition, and only the type-qualifiers fully identify
1449 them. We'll make the same effort at sharing. */
1450 if (t
->bt
== btIndirect
||
1451 t
->bt
== btStruct
||
1454 t
->bt
== btTypedef
||
1457 char name
[256], *pn
;
1459 /* Try to cross reference this type */
1460 ax
+= cross_ref(ax
, &tp
, type_code
, &pn
, bigend
);
1461 /* reading .o file ? */
1462 if (UNSAFE_DATA_ADDR(tp
))
1463 tp
= init_type(type_code
, 0, 0, (char *) NULL
,
1464 (struct objfile
*) NULL
);
1465 /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */
1466 sprintf(name
, fmt
, pn
);
1468 /* Usually, TYPE_CODE(tp) is already type_code. The main
1469 exception is if we guessed wrong re struct/union/enum. */
1470 if (TYPE_CODE(tp
) != type_code
) {
1471 complain (&bad_tag_guess_complaint
, name
);
1472 TYPE_CODE(tp
) = type_code
;
1474 if (TYPE_NAME(tp
) == NULL
|| strcmp(TYPE_NAME(tp
), name
) != 0)
1475 TYPE_NAME(tp
) = obsavestring(name
, strlen(name
),
1476 ¤t_objfile
-> type_obstack
);
1479 /* Deal with range types */
1480 if (t
->bt
== btRange
) {
1481 TYPE_NFIELDS (tp
) = 2;
1482 TYPE_FIELDS (tp
) = (struct field
*)
1483 TYPE_ALLOC (tp
, 2 * sizeof (struct field
));
1484 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1485 ¤t_objfile
-> type_obstack
);
1486 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1488 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1489 ¤t_objfile
-> type_obstack
);
1490 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1494 /* Parse all the type qualifiers now. If there are more
1495 than 6 the game will continue in the next aux */
1497 #define PARSE_TQ(tq) \
1498 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend);
1500 again
: PARSE_TQ(tq0
);
1510 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1516 /* Make up a complex type from a basic one. Type is passed by
1517 reference in TPP and side-effected as necessary. The type
1518 qualifier TQ says how to handle the aux symbols at AX for
1519 the symbol SX we are currently analyzing. BIGEND says whether
1520 aux symbols are big-endian or little-endian.
1521 Returns the number of aux symbols we parsed. */
1524 upgrade_type(tpp
, tq
, ax
, bigend
)
1533 /* Used in array processing */
1542 t
= lookup_pointer_type (*tpp
);
1547 t
= lookup_function_type (*tpp
);
1553 t
= init_type(TYPE_CODE_ARRAY
, 0, 0, (char *) NULL
,
1554 (struct objfile
*) NULL
);
1555 TYPE_TARGET_TYPE(t
) = *tpp
;
1557 /* Determine and record the domain type (type of index) */
1558 ecoff_swap_rndx_in (bigend
, ax
, &rndx
);
1563 rf
= AUX_GET_ISYM (bigend
, ax
);
1566 fh
= get_rfd(cur_fd
, rf
);
1568 /* Fields are kept in an array */
1569 /* FIXME - Memory leak! */
1570 if (TYPE_NFIELDS(t
))
1571 TYPE_FIELDS(t
) = (struct field
*)
1572 xrealloc((PTR
) TYPE_FIELDS(t
),
1573 (TYPE_NFIELDS(t
)+1) * sizeof(struct field
));
1575 TYPE_FIELDS(t
) = (struct field
*)
1576 xzalloc(sizeof(struct field
));
1577 f
= &(TYPE_FIELD(t
,TYPE_NFIELDS(t
)));
1579 memset((PTR
)f
, 0, sizeof(struct field
));
1581 /* XXX */ f
->type
= parse_type(id
+ (union aux_ext
*)fh
->iauxBase
,
1582 &f
->bitsize
, bigend
);
1585 lower
= AUX_GET_DNLOW (bigend
, ax
);
1587 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1589 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1591 /* Check whether supplied array element bit size matches
1592 the known size of the element type. If this complaint
1593 ends up not happening, we can remove this code. It's
1594 here because we aren't sure we understand this *&%&$
1596 id
= TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) << 3; /* bitsize */
1598 /* Most likely an undefined type */
1600 TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) = id
>> 3;
1603 complain (&array_bitsize_complaint
, (char *)rf
);
1605 TYPE_LENGTH(t
) = (upper
< 0) ? 0 :
1606 (upper
- lower
+ 1) * (rf
>> 3);
1611 /* Volatile -- currently ignored */
1615 /* Const -- currently ignored */
1619 complain (&unknown_type_qual_complaint
, (char *)tq
);
1625 /* Parse a procedure descriptor record PR. Note that the procedure
1626 is parsed _after_ the local symbols, now we just insert the extra
1627 information we need into a MIPS_EFI_SYMBOL_NAME symbol that has already
1628 been placed in the procedure's main block. Note also that images that
1629 have been partially stripped (ld -x) have been deprived
1630 of local symbols, and we have to cope with them here.
1631 The procedure's code ends at BOUND */
1634 parse_procedure (pr
, bound
, have_stabs
)
1639 struct symbol
*s
, *i
;
1640 SYMR
*sh
= (SYMR
*)pr
->isym
;
1642 struct mips_extra_func_info
*e
;
1645 /* Static procedure at address pr->adr. Sigh. */
1646 if (sh
== (SYMR
*)-1) {
1647 complain (&pdr_static_symbol_complaint
, (char *)pr
->adr
);
1650 sh_name
= (char*)sh
->iss
;
1652 s
= lookup_symbol(sh_name
, NULL
, VAR_NAMESPACE
, 0, NULL
);
1654 s
= mylookup_symbol(sh_name
, top_stack
->cur_block
,
1655 VAR_NAMESPACE
, LOC_BLOCK
);
1658 b
= SYMBOL_BLOCK_VALUE(s
);
1660 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1664 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1665 s
= new_symbol(sh_name
);
1666 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1667 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1668 /* Donno its type, hope int is ok */
1669 SYMBOL_TYPE(s
) = lookup_function_type (builtin_type_int
);
1670 add_symbol(s
, top_stack
->cur_block
);
1671 /* Wont have symbols for this one */
1673 SYMBOL_BLOCK_VALUE(s
) = b
;
1674 BLOCK_FUNCTION(b
) = s
;
1675 BLOCK_START(b
) = pr
->adr
;
1676 BLOCK_END(b
) = bound
;
1677 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1678 add_block(b
, top_stack
->cur_st
);
1682 i
= mylookup_symbol(MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
, LOC_CONST
);
1686 e
= (struct mips_extra_func_info
*)SYMBOL_VALUE(i
);
1688 e
->pdr
.isym
= (long)s
;
1692 /* Parse the external symbol ES. Just call parse_symbol() after
1693 making sure we know where the aux are for it. For procedures,
1694 parsing of the PDRs has already provided all the needed
1695 information, we only parse them if SKIP_PROCEDURES is false,
1696 and only if this causes no symbol duplication.
1697 BIGEND says whether aux entries are big-endian or little-endian.
1699 This routine clobbers top_stack->cur_block and ->cur_st. */
1702 parse_external(es
, skip_procedures
, bigend
)
1704 int skip_procedures
;
1709 if (es
->ifd
!= ifdNil
) {
1711 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
) + cur_fd
;
1712 ax
= (union aux_ext
*)cur_fdr
->iauxBase
;
1714 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
);
1718 /* Reading .o files */
1719 if (es
->asym
.sc
== scUndefined
|| es
->asym
.sc
== scNil
) {
1721 switch (es
->asym
.st
) {
1723 case stProc
: what
= "procedure"; n_undef_procs
++; break;
1724 case stGlobal
: what
= "variable"; n_undef_vars
++; break;
1725 case stLabel
: what
= "label"; n_undef_labels
++; break;
1726 default : what
= "symbol"; break;
1729 /* FIXME: Turn this into a complaint? */
1731 printf_filtered("Warning: %s `%s' is undefined (in %s)\n",
1732 what
, es
->asym
.iss
, fdr_name((char *)cur_fdr
->rss
));
1736 switch (es
->asym
.st
) {
1738 /* If we have full symbols we do not need more */
1739 if (skip_procedures
)
1741 if (mylookup_symbol ((char *)es
->asym
.iss
, top_stack
->cur_block
,
1742 VAR_NAMESPACE
, LOC_BLOCK
))
1748 * Note that the case of a symbol with indexNil
1749 * must be handled anyways by parse_symbol().
1751 parse_symbol(&es
->asym
, ax
, bigend
);
1758 /* Parse the line number info for file descriptor FH into
1759 GDB's linetable LT. MIPS' encoding requires a little bit
1760 of magic to get things out. Note also that MIPS' line
1761 numbers can go back and forth, apparently we can live
1762 with that and do not need to reorder our linetables */
1767 struct linetable
*lt
;
1769 unsigned char *base
= (unsigned char*)fh
->cbLineOffset
;
1771 int delta
, count
, lineno
= 0;
1777 /* Scan by procedure descriptors */
1779 for (pr
= (PDR
*)IPDFIRST(cur_hdr
,fh
); j
< fh
->cpd
; j
++, pr
++) {
1782 /* No code for this one */
1783 if (pr
->iline
== ilineNil
||
1784 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
1787 * Aurgh! To know where to stop expanding we
1790 for (l
= 1; l
< (fh
->cpd
- j
); l
++)
1791 if (pr
[l
].iline
!= -1)
1793 if (l
== (fh
->cpd
- j
))
1798 * When procedures are moved around the linenumbers
1799 * are attributed to the next procedure up
1801 if (pr
->iline
>= halt
) continue;
1803 base
= (unsigned char*)pr
->cbLineOffset
;
1804 l
= pr
->adr
>> 2; /* in words */
1805 halt
+= (pr
->adr
>> 2) - pr
->iline
;
1806 for (lineno
= pr
->lnLow
; l
< halt
;) {
1807 count
= *base
& 0x0f;
1808 delta
= *base
++ >> 4;
1812 delta
= (base
[0] << 8) | base
[1];
1813 if (delta
>= 0x8000)
1817 lineno
+= delta
;/* first delta is 0 */
1818 k
= add_line(lt
, lineno
, l
, k
);
1824 /* Master parsing procedure for first-pass reading of file symbols
1825 into a partial_symtab.
1827 Parses the symtab described by the global symbolic header CUR_HDR.
1828 END_OF_TEXT_SEG gives the address just after the text segment for
1829 the symtab we are reading. */
1832 parse_partial_symbols (end_of_text_seg
, objfile
, section_offsets
)
1833 int end_of_text_seg
;
1834 struct objfile
*objfile
;
1835 struct section_offsets
*section_offsets
;
1838 HDRR
*hdr
= cur_hdr
;
1839 /* Running pointers */
1843 struct partial_symtab
*pst
;
1845 int past_first_source_file
= 0;
1847 /* List of current psymtab's include files */
1848 char **psymtab_include_list
;
1849 int includes_allocated
;
1852 struct pst_map
* fdr_to_pst
;
1853 /* Index within current psymtab dependency list */
1854 struct partial_symtab
**dependency_list
;
1855 int dependencies_used
, dependencies_allocated
;
1856 struct cleanup
*old_chain
;
1858 extern_tab
= (EXTR
**)obstack_alloc (&objfile
->psymbol_obstack
,
1859 sizeof(EXTR
*) * hdr
->iextMax
);
1861 includes_allocated
= 30;
1863 psymtab_include_list
= (char **) alloca (includes_allocated
*
1865 next_symbol_text_func
= mips_next_symbol_text
;
1867 dependencies_allocated
= 30;
1868 dependencies_used
= 0;
1870 (struct partial_symtab
**) alloca (dependencies_allocated
*
1871 sizeof (struct partial_symtab
*));
1873 last_source_file
= NULL
;
1878 * Only parse the Local and External symbols, and the Relative FDR.
1879 * Fixup enough of the loader symtab to be able to use it.
1880 * Allocate space only for the file's portions we need to
1885 max_glevel
= MIN_GLEVEL
;
1887 /* Allocate the map FDR -> PST.
1888 Minor hack: -O3 images might claim some global data belongs
1889 to FDR -1. We`ll go along with that */
1890 fdr_to_pst
= (struct pst_map
*)xzalloc((hdr
->ifdMax
+1) * sizeof *fdr_to_pst
);
1891 old_chain
= make_cleanup (free
, fdr_to_pst
);
1894 struct partial_symtab
* pst
= new_psymtab("", objfile
);
1895 fdr_to_pst
[-1].pst
= pst
;
1899 /* Pass 1 over external syms: Presize and partition the list */
1900 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1901 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1902 fdr_to_pst
[esh
->ifd
].n_globals
++;
1905 /* Pass 1.5 over files: partition out global symbol space */
1907 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++) {
1908 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
1909 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
1910 fdr_to_pst
[f_idx
].n_globals
= 0;
1913 /* Pass 2 over external syms: fill in external symbols */
1914 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1915 enum minimal_symbol_type ms_type
= mst_text
;
1916 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1918 extern_tab
[fdr_to_pst
[esh
->ifd
].globals_offset
1919 + fdr_to_pst
[esh
->ifd
].n_globals
++] = esh
;
1921 if (esh
->asym
.sc
== scUndefined
|| esh
->asym
.sc
== scNil
)
1924 switch (esh
->asym
.st
) {
1933 ms_type
= mst_unknown
;
1934 complain (&unknown_ext_complaint
, (char *)esh
->asym
.iss
);
1936 prim_record_minimal_symbol ((char *)esh
->asym
.iss
,
1941 /* Pass 3 over files, over local syms: fill in static symbols */
1942 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
1943 struct partial_symtab
*save_pst
;
1946 cur_fdr
= fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
1948 if (fh
->csym
== 0) {
1949 fdr_to_pst
[f_idx
].pst
= NULL
;
1952 pst
= start_psymtab_common (objfile
, section_offsets
, (char*)fh
->rss
,
1953 fh
->cpd
? fh
->adr
: 0,
1954 objfile
->global_psymbols
.next
,
1955 objfile
->static_psymbols
.next
);
1956 pst
->read_symtab_private
= (char *)
1957 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
1960 /* Make everything point to everything. */
1961 FDR_IDX(pst
) = f_idx
;
1962 fdr_to_pst
[f_idx
].pst
= pst
;
1963 fh
->ioptBase
= (int)pst
;
1965 CUR_HDR(pst
) = cur_hdr
;
1967 /* The way to turn this into a symtab is to call... */
1968 pst
->read_symtab
= mipscoff_psymtab_to_symtab
;
1970 pst
->texthigh
= pst
->textlow
;
1972 /* For stabs-in-ecoff files, the second symbol must be @stab.
1973 This symbol is emitted by mips-tfile to signal
1974 that the current object file uses encapsulated stabs
1975 instead of mips ecoff for local symbols.
1976 (It is the second symbol because the first symbol is
1977 the stFile used to signal the start of a file). */
1979 && strcmp((char *)(((SYMR
*)fh
->isymBase
)[1].iss
),
1980 stabs_symbol
) == 0) {
1981 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
1984 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
1985 type_code
= MIPS_UNMARK_STAB(sh
->index
);
1986 if (!MIPS_IS_STAB(sh
)) {
1987 if (sh
->st
== stProc
|| sh
->st
== stStaticProc
) {
1988 long procaddr
= sh
->value
;
1989 sh
= AUX_GET_ISYM (fh
->fBigendian
,
1990 sh
->index
+ (union aux_ext
*)(fh
->iauxBase
))
1991 + (SYMR
*) fh
->isymBase
- 1;
1992 if (sh
->st
== stEnd
) {
1993 long high
= procaddr
+ sh
->value
;
1994 if (high
> pst
->texthigh
)
1995 pst
->texthigh
= high
;
2000 #define SET_NAMESTRING() namestring = (char*)sh->iss
2001 #define CUR_SYMBOL_TYPE type_code
2002 #define CUR_SYMBOL_VALUE sh->value
2003 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
2005 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
2006 #define HANDLE_RBRAC(val) \
2007 if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
2008 #include "partial-stab.h"
2012 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2014 enum address_class
class;
2015 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2017 if (MIPS_IS_STAB(sh
)) {
2022 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
2023 sh
->index
== 0xfffff) {
2024 /* FIXME, premature? */
2029 name
= (char *)(sh
->iss
);
2036 case stProc
: /* Asm labels apparently */
2037 case stStaticProc
: /* Function */
2038 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2039 VAR_NAMESPACE
, LOC_BLOCK
,
2040 objfile
->static_psymbols
, sh
->value
);
2041 /* Skip over procedure to next one. */
2042 if (sh
->index
>= hdr
->iauxMax
)
2044 /* Should not happen, but does when cross-compiling
2045 with the MIPS compiler. FIXME -- pull later. */
2046 complain (&index_complaint
, name
);
2047 new_sdx
= cur_sdx
+1; /* Don't skip at all */
2050 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2051 sh
->index
+ (union aux_ext
*)fh
->iauxBase
);
2052 procaddr
= sh
->value
;
2054 if (new_sdx
<= cur_sdx
)
2056 /* This should not happen either... FIXME. */
2057 complain (&aux_index_complaint
, name
);
2058 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2062 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
- 1;
2063 if (sh
->st
!= stEnd
)
2065 high
= procaddr
+ sh
->value
;
2066 if (high
> pst
->texthigh
)
2067 pst
->texthigh
= high
;
2070 case stStatic
: /* Variable */
2074 case stTypedef
: /* Typedef */
2075 class = LOC_TYPEDEF
;
2078 case stConstant
: /* Constant decl */
2085 case stBlock
: /* { }, str, un, enum*/
2086 if (sh
->sc
== scInfo
) {
2087 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2088 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2089 objfile
->static_psymbols
, sh
->value
);
2091 /* Skip over the block */
2092 cur_sdx
= sh
->index
;
2095 case stFile
: /* File headers */
2096 case stLabel
: /* Labels */
2097 case stEnd
: /* Ends of files */
2100 case stLocal
: /* Local variables */
2101 /* Normally these are skipped because we skip over
2102 all blocks we see. However, these can occur
2103 as visible symbols in a .h file that contains code. */
2107 /* Both complaints are valid: one gives symbol name,
2108 the other the offending symbol type. */
2109 complain (&unknown_sym_complaint
, (char *)sh
->iss
);
2110 complain (&unknown_st_complaint
, (char *)sh
->st
);
2114 /* Use this gdb symbol */
2115 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2116 VAR_NAMESPACE
, class,
2117 objfile
->static_psymbols
, sh
->value
);
2119 cur_sdx
++; /* Go to next file symbol */
2122 /* Now do enter the external symbols. */
2123 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2124 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2125 PST_PRIVATE(save_pst
)->extern_count
= cur_sdx
;
2126 PST_PRIVATE(save_pst
)->extern_tab
= ext_ptr
;
2127 for (; --cur_sdx
>= 0; ext_ptr
++) {
2128 register struct partial_symbol
*psym
;
2129 enum address_class
class;
2131 if ((*ext_ptr
)->ifd
!= f_idx
)
2133 sh
= &(*ext_ptr
)->asym
;
2142 complain (&unknown_ext_complaint
, (char *)sh
->iss
);
2143 /* Fall through, pretend it's global. */
2148 if (objfile
->global_psymbols
.next
>=
2149 objfile
->global_psymbols
.list
+ objfile
->global_psymbols
.size
)
2150 extend_psymbol_list (&objfile
->global_psymbols
, objfile
);
2151 psym
= objfile
->global_psymbols
.next
++;
2152 SYMBOL_NAME (psym
) = (char*)sh
->iss
;
2153 SYMBOL_NAMESPACE (psym
) = VAR_NAMESPACE
;
2154 SYMBOL_CLASS (psym
) = class;
2155 SYMBOL_VALUE_ADDRESS (psym
) = (CORE_ADDR
)sh
->value
;
2159 end_psymtab (save_pst
, psymtab_include_list
, includes_used
,
2160 -1, save_pst
->texthigh
,
2161 dependency_list
, dependencies_used
);
2162 if (objfile
-> ei
.entry_point
>= save_pst
->textlow
&&
2163 objfile
-> ei
.entry_point
< save_pst
->texthigh
)
2165 objfile
-> ei
.entry_file_lowpc
= save_pst
->textlow
;
2166 objfile
-> ei
.entry_file_highpc
= save_pst
->texthigh
;
2170 /* Mark the last code address, and remember it for later */
2171 hdr
->cbDnOffset
= end_of_text_seg
;
2173 /* Now scan the FDRs for dependencies */
2174 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
2176 fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
2177 pst
= fdr_to_pst
[f_idx
].pst
;
2179 /* This should catch stabs-in-ecoff. */
2183 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2184 /* ...then presumably a .h file: drop reverse depends .h->.c */
2185 for (; s_id0
< fh
->crfd
; s_id0
++) {
2186 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2188 s_id0
++; /* Skip self-dependency */
2193 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2194 pst
->dependencies
= (struct partial_symtab
**)
2195 obstack_alloc (&objfile
->psymbol_obstack
,
2196 pst
->number_of_dependencies
*
2197 sizeof (struct partial_symtab
*));
2198 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2199 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2200 if (*rh
< 0 || *rh
>= hdr
->ifdMax
)
2201 complain(&bad_file_number_complaint
, (char *)*rh
);
2203 pst
->dependencies
[s_idx
-s_id0
] = fdr_to_pst
[*rh
].pst
;
2206 do_cleanups (old_chain
);
2211 /* Do the initial analisys of the F_IDX-th file descriptor.
2212 Allocates a partial symtab for it, and builds the list
2213 of dependent files by recursion. LEV says at which level
2214 of recursion we are called (to pretty up debug traces) */
2216 static struct partial_symtab
*
2217 parse_fdr(f_idx
, lev
, objfile
)
2220 struct objfile
*objfile
;
2223 register struct partial_symtab
*pst
;
2226 fh
= (FDR
*) (cur_hdr
->cbFdOffset
) + f_idx
;
2228 /* Use this to indicate into which symtab this file was parsed */
2230 return (struct partial_symtab
*) fh
->ioptBase
;
2232 /* Debuggability level */
2233 if (compare_glevel(max_glevel
, fh
->glevel
) < 0)
2234 max_glevel
= fh
->glevel
;
2236 /* Make a new partial_symtab */
2237 pst
= new_psymtab(fh
->rss
, objfile
);
2242 pst
->textlow
= fh
->adr
;
2243 pst
->texthigh
= fh
->cpd
; /* To be fixed later */
2246 /* Make everything point to everything. */
2247 FDR_IDX(pst
) = f_idx
;
2248 fdr_to_pst
[f_idx
].pst
= pst
;
2249 fh
->ioptBase
= (int)pst
;
2251 /* Analyze its dependencies */
2256 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2257 /* ...then presumably a .h file: drop reverse depends .h->.c */
2258 for (; s_id0
< fh
->crfd
; s_id0
++) {
2259 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2261 s_id0
++; /* Skip self-dependency */
2266 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2267 pst
->dependencies
= (struct partial_symtab
**)
2268 obstack_alloc (&objfile
->psymbol_obstack
,
2269 pst
->number_of_dependencies
*
2270 sizeof (struct partial_symtab
*));
2271 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2272 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2274 pst
->dependencies
[s_idx
-s_id0
] = parse_fdr(*rh
, lev
+1, objfile
);
2282 mips_next_symbol_text ()
2285 return (char*)((SYMR
*)cur_fdr
->isymBase
)[cur_sdx
].iss
;
2288 /* Ancillary function to psymtab_to_symtab(). Does all the work
2289 for turning the partial symtab PST into a symtab, recurring
2290 first on all dependent psymtabs. The argument FILENAME is
2291 only passed so we can see in debug stack traces what file
2294 This function has a split personality, based on whether the
2295 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
2296 The flow of control and even the memory allocation differs. FIXME. */
2299 psymtab_to_symtab_1(pst
, filename
)
2300 struct partial_symtab
*pst
;
2306 struct linetable
*lines
;
2313 /* Read in all partial symbtabs on which this one is dependent.
2314 NOTE that we do have circular dependencies, sigh. We solved
2315 that by setting pst->readin before this point. */
2317 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
2318 if (!pst
->dependencies
[i
]->readin
) {
2319 /* Inform about additional files to be read in. */
2322 fputs_filtered (" ", stdout
);
2324 fputs_filtered ("and ", stdout
);
2326 printf_filtered ("%s...",
2327 pst
->dependencies
[i
]->filename
);
2328 wrap_here (""); /* Flush output */
2331 /* We only pass the filename for debug purposes */
2332 psymtab_to_symtab_1(pst
->dependencies
[i
],
2333 pst
->dependencies
[i
]->filename
);
2336 /* Now read the symbols for this symtab */
2338 current_objfile
= pst
->objfile
;
2339 cur_fd
= FDR_IDX(pst
);
2340 fh
= (cur_fd
== -1) ? 0 : (FDR
*) (cur_hdr
->cbFdOffset
) + FDR_IDX(pst
);
2343 /* BOUND is the highest core address of this file's procedures */
2344 bound
= (cur_fd
== cur_hdr
->ifdMax
- 1) ?
2345 cur_hdr
->cbDnOffset
:
2348 /* See comment in parse_partial_symbols about the @stabs sentinel. */
2349 if (fh
&& fh
->csym
>= 2
2350 && strcmp((char *)(((SYMR
*)fh
->isymBase
)[1].iss
), stabs_symbol
)
2354 * This symbol table contains stabs-in-ecoff entries.
2359 /* Parse local symbols first */
2361 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
2363 current_objfile
= NULL
;
2366 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
2367 register SYMR
*sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2368 char *name
= (char*)sh
->iss
;
2369 CORE_ADDR valu
= sh
->value
;
2370 if (MIPS_IS_STAB(sh
)) {
2371 int type_code
= MIPS_UNMARK_STAB(sh
->index
);
2372 process_one_symbol (type_code
, 0, valu
, name
,
2373 pst
->section_offsets
, pst
->objfile
);
2374 if (type_code
== N_FUN
) {
2375 /* Make up special symbol to contain
2376 procedure specific info */
2377 struct mips_extra_func_info
*e
=
2378 (struct mips_extra_func_info
*)
2379 obstack_alloc(¤t_objfile
->symbol_obstack
,
2380 sizeof(struct mips_extra_func_info
));
2381 struct symbol
*s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
2382 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
2383 SYMBOL_CLASS(s
) = LOC_CONST
;
2384 SYMBOL_TYPE(s
) = builtin_type_void
;
2385 SYMBOL_VALUE(s
) = (int)e
;
2386 add_symbol_to_list (s
, &local_symbols
);
2389 else if (sh
->st
== stLabel
&& sh
->index
!= indexNil
) {
2390 /* Handle encoded stab line number. */
2391 record_line (current_subfile
, sh
->index
, valu
);
2393 else complain (&stab_unknown_complaint
, (char *)sh
->iss
);
2395 st
= end_symtab (pst
->texthigh
, 0, 0, pst
->objfile
);
2398 /* Sort the symbol table now, we are done adding symbols to it.
2399 We must do this before parse_procedure calls lookup_symbol. */
2400 sort_symtab_syms(st
);
2402 /* This may not be necessary for stabs symtabs. FIXME. */
2405 /* Fill in procedure info next. We need to look-ahead to
2406 find out where each procedure's code ends. */
2408 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2409 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2410 parse_procedure (pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 1);
2415 * This symbol table contains ordinary ecoff entries.
2418 /* FIXME: doesn't use pst->section_offsets. */
2424 /* How many symbols will we need */
2425 /* FIXME, this does not count enum values. */
2426 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
2429 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
2431 f_max
+= fh
->csym
+ fh
->cpd
;
2432 maxlines
= 2 * fh
->cline
;
2433 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
2436 lines
= LINETABLE(st
);
2437 pending_list
= (struct mips_pending
**) cur_hdr
->cbOptOffset
;
2438 if (pending_list
== 0) {
2439 pending_list
= (struct mips_pending
**)
2440 xzalloc(cur_hdr
->ifdMax
* sizeof(struct mips_pending
*));
2441 cur_hdr
->cbOptOffset
= (int)pending_list
;
2444 /* Get a new lexical context */
2447 top_stack
->cur_st
= st
;
2448 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(st
),
2450 BLOCK_START(top_stack
->cur_block
) = fh
? fh
->adr
: 0;
2451 BLOCK_END(top_stack
->cur_block
) = 0;
2452 top_stack
->blocktype
= stFile
;
2453 top_stack
->maxsyms
= 2*f_max
;
2454 top_stack
->cur_type
= 0;
2455 top_stack
->procadr
= 0;
2456 top_stack
->numargs
= 0;
2462 /* Parse local symbols first */
2464 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2465 sh
= (SYMR
*) (fh
->isymBase
) + cur_sdx
;
2466 cur_sdx
+= parse_symbol(sh
, (union aux_ext
*)fh
->iauxBase
,
2470 /* Linenumbers. At the end, check if we can save memory */
2472 parse_lines(fh
, lines
);
2473 if (lines
->nitems
< fh
->cline
)
2474 lines
= shrink_linetable(lines
);
2476 /* Fill in procedure info next. We need to look-ahead to
2477 find out where each procedure's code ends. */
2479 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2480 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2481 parse_procedure(pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 0);
2485 LINETABLE(st
) = lines
;
2487 /* .. and our share of externals.
2488 XXX use the global list to speed up things here. how?
2489 FIXME, Maybe quit once we have found the right number of ext's? */
2490 top_stack
->cur_st
= st
;
2491 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
2493 top_stack
->blocktype
= stFile
;
2494 top_stack
->maxsyms
=
2495 cur_hdr
->isymMax
+ cur_hdr
->ipdMax
+ cur_hdr
->iextMax
;
2497 ext_ptr
= PST_PRIVATE(pst
)->extern_tab
;
2498 for (i
= PST_PRIVATE(pst
)->extern_count
; --i
>= 0; ext_ptr
++)
2499 parse_external(*ext_ptr
, 1, fh
->fBigendian
);
2501 /* If there are undefined, tell the user */
2502 if (n_undef_symbols
) {
2503 printf_filtered("File %s contains %d unresolved references:",
2504 st
->filename
, n_undef_symbols
);
2505 printf_filtered("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
2506 n_undef_vars
, n_undef_procs
, n_undef_labels
);
2507 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
2512 /* Sort the symbol table now, we are done adding symbols to it.*/
2513 sort_symtab_syms(st
);
2518 /* Now link the psymtab and the symtab. */
2521 current_objfile
= NULL
;
2524 /* Ancillary parsing procedures. */
2526 /* Lookup the type at relative index RN. Return it in TPP
2527 if found and in any event come up with its name PNAME.
2528 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
2529 Return value says how many aux symbols we ate. */
2532 cross_ref(ax
, tpp
, type_code
, pname
, bigend
)
2535 enum type_code type_code
; /* Use to alloc new type if none is found. */
2543 ecoff_swap_rndx_in (bigend
, ax
, rn
);
2545 /* Escape index means 'the next one' */
2546 if (rn
->rfd
== 0xfff) {
2548 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
2555 *pname
= "<undefined>";
2558 * Find the relative file descriptor and the symbol in it
2560 FDR
*fh
= get_rfd(cur_fd
, rf
);
2565 * If we have processed this symbol then we left a forwarding
2566 * pointer to the corresponding GDB symbol. If not, we`ll put
2567 * it in a list of pending symbols, to be processed later when
2568 * the file f will be. In any event, we collect the name for
2569 * the type here. Which is why we made a first pass at
2572 sh
= (SYMR
*) (fh
->isymBase
) + rn
->index
;
2574 /* Careful, we might be looking at .o files */
2575 *pname
= (UNSAFE_DATA_ADDR(sh
->iss
)) ? "<undefined>" :
2578 /* Have we parsed it ? */
2579 if ((!UNSAFE_DATA_ADDR(sh
->value
)) && (sh
->st
== stParsed
)) {
2580 t
= (struct type
*) sh
->value
;
2583 /* Avoid duplicates */
2584 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
2588 *tpp
= init_type(type_code
, 0, 0, (char *) NULL
,
2589 (struct objfile
*) NULL
);
2590 add_pending(fh
, sh
, *tpp
);
2595 /* We used one auxent normally, two if we got a "next one" rf. */
2600 /* Quick&dirty lookup procedure, to avoid the MI ones that require
2601 keeping the symtab sorted */
2603 static struct symbol
*
2604 mylookup_symbol (name
, block
, namespace, class)
2606 register struct block
*block
;
2607 enum namespace namespace;
2608 enum address_class
class;
2610 register int bot
, top
, inc
;
2611 register struct symbol
*sym
;
2614 top
= BLOCK_NSYMS(block
);
2617 sym
= BLOCK_SYM(block
, bot
);
2618 if (SYMBOL_NAME(sym
)[0] == inc
2619 && SYMBOL_NAMESPACE(sym
) == namespace
2620 && SYMBOL_CLASS(sym
) == class
2621 && !strcmp(SYMBOL_NAME(sym
), name
))
2625 block
= BLOCK_SUPERBLOCK (block
);
2627 return mylookup_symbol (name
, block
, namespace, class);
2632 /* Add a new symbol S to a block B.
2633 Infrequently, we will need to reallocate the block to make it bigger.
2634 We only detect this case when adding to top_stack->cur_block, since
2635 that's the only time we know how big the block is. FIXME. */
2642 int nsyms
= BLOCK_NSYMS(b
)++;
2643 struct block
*origb
;
2644 struct parse_stack
*stackp
;
2646 if (b
== top_stack
->cur_block
&&
2647 nsyms
>= top_stack
->maxsyms
) {
2648 complain (&block_overflow_complaint
, s
->name
);
2649 /* In this case shrink_block is actually grow_block, since
2650 BLOCK_NSYMS(b) is larger than its current size. */
2652 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
2654 /* Now run through the stack replacing pointers to the
2655 original block. shrink_block has already done this
2656 for the blockvector and BLOCK_FUNCTION. */
2657 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
) {
2658 if (stackp
->cur_block
== origb
) {
2659 stackp
->cur_block
= b
;
2660 stackp
->maxsyms
= BLOCK_NSYMS (b
);
2664 BLOCK_SYM(b
,nsyms
) = s
;
2667 /* Add a new block B to a symtab S */
2674 struct blockvector
*bv
= BLOCKVECTOR(s
);
2676 bv
= (struct blockvector
*)xrealloc((PTR
) bv
,
2677 sizeof(struct blockvector
) +
2678 BLOCKVECTOR_NBLOCKS(bv
)
2679 * sizeof(bv
->block
));
2680 if (bv
!= BLOCKVECTOR(s
))
2681 BLOCKVECTOR(s
) = bv
;
2683 BLOCKVECTOR_BLOCK(bv
, BLOCKVECTOR_NBLOCKS(bv
)++) = b
;
2686 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
2687 MIPS' linenumber encoding might need more than one byte
2688 to describe it, LAST is used to detect these continuation lines */
2691 add_line(lt
, lineno
, adr
, last
)
2692 struct linetable
*lt
;
2698 last
= -2; /* make sure we record first line */
2700 if (last
== lineno
) /* skip continuation lines */
2703 lt
->item
[lt
->nitems
].line
= lineno
;
2704 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
2708 /* Sorting and reordering procedures */
2710 /* Blocks with a smaller low bound should come first */
2713 compare_blocks(arg1
, arg2
)
2714 const void *arg1
, *arg2
;
2716 register int addr_diff
;
2717 struct block
**b1
= (struct block
**) arg1
;
2718 struct block
**b2
= (struct block
**) arg2
;
2720 addr_diff
= (BLOCK_START((*b1
))) - (BLOCK_START((*b2
)));
2722 return (BLOCK_END((*b1
))) - (BLOCK_END((*b2
)));
2726 /* Sort the blocks of a symtab S.
2727 Reorder the blocks in the blockvector by code-address,
2728 as required by some MI search routines */
2734 struct blockvector
*bv
= BLOCKVECTOR(s
);
2736 if (BLOCKVECTOR_NBLOCKS(bv
) <= 2) {
2738 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) == 0)
2739 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = 0;
2740 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) == 0)
2741 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) = 0;
2745 * This is very unfortunate: normally all functions are compiled in
2746 * the order they are found, but if the file is compiled -O3 things
2747 * are very different. It would be nice to find a reliable test
2748 * to detect -O3 images in advance.
2750 if (BLOCKVECTOR_NBLOCKS(bv
) > 3)
2751 qsort(&BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
),
2752 BLOCKVECTOR_NBLOCKS(bv
) - FIRST_LOCAL_BLOCK
,
2753 sizeof(struct block
*),
2757 register CORE_ADDR high
= 0;
2758 register int i
, j
= BLOCKVECTOR_NBLOCKS(bv
);
2760 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
2761 if (high
< BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
)))
2762 high
= BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
));
2763 BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = high
;
2766 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) =
2767 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
));
2769 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2770 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2771 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2772 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2776 /* Constructor/restructor/destructor procedures */
2778 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
2779 MAXSYMS and linenumbers MAXLINES we'll put in it */
2781 static struct symtab
*
2782 new_symtab(name
, maxsyms
, maxlines
, objfile
)
2786 struct objfile
*objfile
;
2788 struct symtab
*s
= allocate_symtab (name
, objfile
);
2790 LINETABLE(s
) = new_linetable(maxlines
);
2792 /* All symtabs must have at least two blocks */
2793 BLOCKVECTOR(s
) = new_bvect(2);
2794 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
) = new_block(maxsyms
);
2795 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), STATIC_BLOCK
) = new_block(maxsyms
);
2796 BLOCK_SUPERBLOCK( BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
),STATIC_BLOCK
)) =
2797 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
);
2799 s
->free_code
= free_linetable
;
2804 /* Allocate a new partial_symtab NAME */
2806 static struct partial_symtab
*
2807 new_psymtab(name
, objfile
)
2809 struct objfile
*objfile
;
2811 struct partial_symtab
*psymtab
;
2813 /* FIXME -- why (char *) -1 rather than NULL? */
2814 psymtab
= allocate_psymtab (name
== (char *) -1 ? "<no name>" : name
,
2817 /* Keep a backpointer to the file's symbols */
2819 psymtab
-> read_symtab_private
= (char *)
2820 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2821 CUR_HDR(psymtab
) = cur_hdr
;
2823 /* The way to turn this into a symtab is to call... */
2824 psymtab
->read_symtab
= mipscoff_psymtab_to_symtab
;
2829 /* Allocate a linetable array of the given SIZE. Since the struct
2830 already includes one item, we subtract one when calculating the
2831 proper size to allocate. */
2833 static struct linetable
*
2837 struct linetable
*l
;
2839 size
= (size
-1) * sizeof(l
->item
) + sizeof(struct linetable
);
2840 l
= (struct linetable
*)xmalloc(size
);
2845 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
2846 I am not so sure about the 3.4 ones.
2848 Since the struct linetable already includes one item, we subtract one when
2849 calculating the proper size to allocate. */
2851 static struct linetable
*
2852 shrink_linetable(lt
)
2853 struct linetable
* lt
;
2856 return (struct linetable
*) xrealloc ((PTR
)lt
,
2857 sizeof(struct linetable
)
2858 + (lt
->nitems
- 1) * sizeof(lt
->item
));
2861 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
2863 static struct blockvector
*
2867 struct blockvector
*bv
;
2870 size
= sizeof(struct blockvector
) + nblocks
* sizeof(struct block
*);
2871 bv
= (struct blockvector
*) xzalloc(size
);
2873 BLOCKVECTOR_NBLOCKS(bv
) = nblocks
;
2878 /* Allocate and zero a new block of MAXSYMS symbols */
2880 static struct block
*
2884 int size
= sizeof(struct block
) + (maxsyms
-1) * sizeof(struct symbol
*);
2886 return (struct block
*)xzalloc (size
);
2889 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
2890 Shrink_block can also be used by add_symbol to grow a block. */
2892 static struct block
*
2898 struct blockvector
*bv
= BLOCKVECTOR(s
);
2901 /* Just reallocate it and fix references to the old one */
2903 new = (struct block
*) xrealloc ((PTR
)b
, sizeof(struct block
) +
2904 (BLOCK_NSYMS(b
)-1) * sizeof(struct symbol
*));
2906 /* Should chase pointers to old one. Fortunately, that`s just
2907 the block`s function and inferior blocks */
2908 if (BLOCK_FUNCTION(new) && SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) == b
)
2909 SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) = new;
2910 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++)
2911 if (BLOCKVECTOR_BLOCK(bv
,i
) == b
)
2912 BLOCKVECTOR_BLOCK(bv
,i
) = new;
2913 else if (BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) == b
)
2914 BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) = new;
2918 /* Create a new symbol with printname NAME */
2920 static struct symbol
*
2924 struct symbol
*s
= (struct symbol
*)
2925 obstack_alloc (¤t_objfile
->symbol_obstack
, sizeof (struct symbol
));
2927 memset ((PTR
)s
, 0, sizeof (*s
));
2928 SYMBOL_NAME(s
) = name
;
2932 /* Create a new type with printname NAME */
2934 static struct type
*
2940 t
= alloc_type (current_objfile
);
2941 TYPE_NAME(t
) = name
;
2942 TYPE_CPLUS_SPECIFIC(t
) = (struct cplus_struct_type
*)
2943 &cplus_struct_default
;
2948 /* Things used for calling functions in the inferior.
2949 These functions are exported to our companion
2950 mips-tdep.c file and are here because they play
2951 with the symbol-table explicitly. */
2953 /* Sigtramp: make sure we have all the necessary information
2954 about the signal trampoline code. Since the official code
2955 from MIPS does not do so, we make up that information ourselves.
2956 If they fix the library (unlikely) this code will neutralize itself. */
2963 struct block
*b
, *b0
;
2965 sigtramp_address
= -1;
2967 /* We know it is sold as sigvec */
2968 s
= lookup_symbol("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
2970 /* Most programs do not play with signals */
2972 s
= lookup_symbol("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
2975 b0
= SYMBOL_BLOCK_VALUE(s
);
2977 /* A label of sigvec, to be more precise */
2978 s
= lookup_symbol("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
2981 /* But maybe this program uses its own version of sigvec */
2985 /* Did we or MIPSco fix the library ? */
2986 if (SYMBOL_CLASS(s
) == LOC_BLOCK
)
2988 sigtramp_address
= BLOCK_START(SYMBOL_BLOCK_VALUE(s
));
2989 sigtramp_end
= BLOCK_END(SYMBOL_BLOCK_VALUE(s
));
2993 sigtramp_address
= SYMBOL_VALUE(s
);
2994 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
2996 /* But what symtab does it live in ? */
2997 st
= find_pc_symtab(SYMBOL_VALUE(s
));
3000 * Ok, there goes the fix: turn it into a procedure, with all the
3001 * needed info. Note we make it a nested procedure of sigvec,
3002 * which is the way the (assembly) code is actually written.
3004 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
3005 SYMBOL_CLASS(s
) = LOC_BLOCK
;
3006 SYMBOL_TYPE(s
) = init_type(TYPE_CODE_FUNC
, 4, 0, (char *) NULL
,
3007 (struct objfile
*) NULL
);
3008 TYPE_TARGET_TYPE(SYMBOL_TYPE(s
)) = builtin_type_void
;
3010 /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
3012 SYMBOL_BLOCK_VALUE(s
) = b
;
3013 BLOCK_START(b
) = sigtramp_address
;
3014 BLOCK_END(b
) = sigtramp_end
;
3015 BLOCK_FUNCTION(b
) = s
;
3016 BLOCK_SUPERBLOCK(b
) = BLOCK_SUPERBLOCK(b0
);
3020 /* Make a MIPS_EFI_SYMBOL_NAME entry for it */
3022 struct mips_extra_func_info
*e
=
3023 (struct mips_extra_func_info
*)
3024 xzalloc(sizeof(struct mips_extra_func_info
));
3026 e
->numargs
= 0; /* the kernel thinks otherwise */
3027 /* align_longword(sigcontext + SIGFRAME) */
3028 e
->pdr
.frameoffset
= 0x150;
3029 e
->pdr
.framereg
= SP_REGNUM
;
3031 e
->pdr
.regmask
= -2;
3032 e
->pdr
.regoffset
= -(41 * sizeof(int));
3033 e
->pdr
.fregmask
= -1;
3034 e
->pdr
.fregoffset
= -(37 * sizeof(int));
3035 e
->pdr
.isym
= (long)s
;
3037 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
3038 s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
3039 SYMBOL_VALUE(s
) = (int) e
;
3040 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
3041 SYMBOL_CLASS(s
) = LOC_CONST
;
3042 SYMBOL_TYPE(s
) = builtin_type_void
;
3043 current_objfile
= NULL
;
3046 BLOCK_SYM(b
,BLOCK_NSYMS(b
)++) = s
;
3050 /* Fake up identical offsets for all sections. */
3052 struct section_offsets
*
3053 mipscoff_symfile_offsets (objfile
, addr
)
3054 struct objfile
*objfile
;
3057 struct section_offsets
*section_offsets
;
3060 section_offsets
= (struct section_offsets
*)
3061 obstack_alloc (&objfile
-> psymbol_obstack
,
3062 sizeof (struct section_offsets
) +
3063 sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
3065 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
3066 ANOFFSET (section_offsets
, i
) = addr
;
3068 return section_offsets
;
3071 /* Initialization */
3073 static struct sym_fns ecoff_sym_fns
=
3075 "ecoff", /* sym_name: name or name prefix of BFD target type */
3076 5, /* sym_namelen: number of significant sym_name chars */
3077 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
3078 mipscoff_symfile_init
,/* sym_init: read initial info, setup for sym_read() */
3079 mipscoff_symfile_read
,/* sym_read: read a symbol file into symtab */
3080 mipscoff_symfile_finish
,/* sym_finish: finished with file, cleanup */
3081 mipscoff_symfile_offsets
,/* sym_offsets: dummy FIXME til implem sym reloc */
3082 NULL
/* next: pointer to next struct sym_fns */
3087 _initialize_mipsread ()
3089 add_symtab_fns (&ecoff_sym_fns
);
3091 /* Missing basic types */
3093 builtin_type_string
=
3094 init_type(TYPE_CODE_PASCAL_ARRAY
,
3095 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3097 (struct objfile
*) NULL
);
3098 builtin_type_complex
=
3099 init_type(TYPE_CODE_FLT
,
3100 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3102 (struct objfile
*) NULL
);
3103 builtin_type_double_complex
=
3104 init_type(TYPE_CODE_FLT
,
3105 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3106 0, "double complex",
3107 (struct objfile
*) NULL
);
3108 builtin_type_fixed_dec
=
3109 init_type(TYPE_CODE_INT
,
3110 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3112 (struct objfile
*) NULL
);
3113 builtin_type_float_dec
=
3114 init_type(TYPE_CODE_FLT
,
3115 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3116 0, "floating decimal",
3117 (struct objfile
*) NULL
);