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 */
87 struct external_filehdr f
;
88 struct external_aouthdr a
;
91 /* Each partial symbol table entry contains a pointer to private data for the
92 read_symtab() function to use when expanding a partial symbol table entry
93 to a full symbol table entry.
95 For mipsread this structure contains the index of the FDR that this psymtab
96 represents and a pointer to the symbol table header HDRR from the symbol
97 file that the psymtab was created from. */
99 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
100 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
101 #define CUR_HDR(p) (PST_PRIVATE(p)->cur_hdr)
106 EXTR
**extern_tab
; /* Pointer to external symbols for this file. */
107 int extern_count
; /* Size of extern_tab. */
110 /* Things we import explicitly from other modules */
112 extern int info_verbose
;
114 /* Various complaints about symbol reading that don't abort the process */
116 struct complaint bad_file_number_complaint
=
117 {"bad file number %d", 0, 0};
119 struct complaint index_complaint
=
120 {"bad aux index at symbol %s", 0, 0};
122 struct complaint aux_index_complaint
=
123 {"bad proc end in aux found from symbol %s", 0, 0};
125 struct complaint block_index_complaint
=
126 {"bad aux index at block symbol %s", 0, 0};
128 struct complaint unknown_ext_complaint
=
129 {"unknown external symbol %s", 0, 0};
131 struct complaint unknown_sym_complaint
=
132 {"unknown local symbol %s", 0, 0};
134 struct complaint unknown_st_complaint
=
135 {"with type %d", 0, 0};
137 struct complaint block_overflow_complaint
=
138 {"block containing %s overfilled", 0, 0};
140 struct complaint basic_type_complaint
=
141 {"cannot map MIPS basic type 0x%x", 0, 0};
143 struct complaint unknown_type_qual_complaint
=
144 {"unknown type qualifier 0x%x", 0, 0};
146 struct complaint array_bitsize_complaint
=
147 {"size of array target type not known, assuming %d bits", 0, 0};
149 struct complaint bad_tag_guess_complaint
=
150 {"guessed tag type of %s incorrectly", 0, 0};
152 struct complaint block_member_complaint
=
153 {"declaration block contains unhandled symbol type %d", 0, 0};
155 struct complaint stEnd_complaint
=
156 {"stEnd with storage class %d not handled", 0, 0};
158 struct complaint unknown_mips_symtype_complaint
=
159 {"unknown symbol type 0x%x", 0, 0};
161 struct complaint stab_unknown_complaint
=
162 {"unknown stabs symbol %s", 0, 0};
164 struct complaint pdr_for_nonsymbol_complaint
=
165 {"PDR for %s, but no symbol", 0, 0};
167 struct complaint pdr_static_symbol_complaint
=
168 {"can't handle PDR for static proc at 0x%x", 0, 0};
170 /* Macros and extra defs */
172 /* Already-parsed symbols are marked specially */
174 #define stParsed stType
176 /* Puns: hard to find whether -g was used and how */
178 #define MIN_GLEVEL GLEVEL_0
179 #define compare_glevel(a,b) \
180 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
181 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
183 /* When looking at .o files, avoid tripping over zero pointers.
184 FIXME; places that use this should be fixed to convert from
185 external to internal format, rather than examining in-place. */
187 #define UNSAFE_DATA_ADDR(p) ((p) == 0)
189 /* Things that really are local to this module */
191 /* Remember what we deduced to be the source language of this psymtab. */
193 static enum language psymtab_language
= language_unknown
;
195 /* MIPS symtab header for the current file */
197 static HDRR
*cur_hdr
;
199 /* Pointer to current file decriptor record, and its index */
204 /* Index of current symbol */
208 /* Note how much "debuggable" this image is. We would like
209 to see at least one FDR with full symbols */
214 /* When examining .o files, report on undefined symbols */
216 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
218 /* Pseudo symbol to use when putting stabs into the symbol table. */
220 static char stabs_symbol
[] = STABS_SYMBOL
;
222 /* Extra builtin types */
224 struct type
*builtin_type_complex
;
225 struct type
*builtin_type_double_complex
;
226 struct type
*builtin_type_fixed_dec
;
227 struct type
*builtin_type_float_dec
;
228 struct type
*builtin_type_string
;
230 /* Forward declarations */
233 fixup_symtab
PARAMS ((HDRR
*, char *, file_ptr
, bfd
*));
236 read_mips_symtab
PARAMS ((struct objfile
*, struct section_offsets
*));
239 read_the_mips_symtab
PARAMS ((bfd
*, CORE_ADDR
*));
242 upgrade_type
PARAMS ((struct type
**, int, union aux_ext
*, int));
245 parse_partial_symbols
PARAMS ((int, struct objfile
*,
246 struct section_offsets
*));
249 cross_ref
PARAMS ((union aux_ext
*, struct type
**, enum type_code
, char **,
253 fixup_sigtramp
PARAMS ((void));
255 static struct symbol
*
256 new_symbol
PARAMS ((char *));
259 new_type
PARAMS ((char *));
261 static struct block
*
262 new_block
PARAMS ((int));
264 static struct symtab
*
265 new_symtab
PARAMS ((char *, int, int, struct objfile
*));
267 static struct linetable
*
268 new_linetable
PARAMS ((int));
270 static struct blockvector
*
271 new_bvect
PARAMS ((int));
274 parse_type
PARAMS ((union aux_ext
*, int *, int));
276 static struct symbol
*
277 mylookup_symbol
PARAMS ((char *, struct block
*, enum namespace,
278 enum address_class
));
280 static struct block
*
281 shrink_block
PARAMS ((struct block
*, struct symtab
*));
284 xzalloc
PARAMS ((unsigned int));
287 sort_blocks
PARAMS ((struct symtab
*));
290 compare_blocks
PARAMS ((const void *, const void *));
292 static struct partial_symtab
*
293 new_psymtab
PARAMS ((char *, struct objfile
*));
296 static struct partial_symtab
*
297 parse_fdr
PARAMS ((int, int, struct objfile
*));
301 psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*, char *));
304 add_block
PARAMS ((struct block
*, struct symtab
*));
307 add_symbol
PARAMS ((struct symbol
*, struct block
*));
310 add_line
PARAMS ((struct linetable
*, int, CORE_ADDR
, int));
312 static struct linetable
*
313 shrink_linetable
PARAMS ((struct linetable
*));
316 mips_next_symbol_text
PARAMS ((void));
318 /* Things we export to other modules */
320 /* Address bounds for the signal trampoline in inferior, if any */
321 /* FIXME: Nothing really seems to use this. Why is it here? */
323 CORE_ADDR sigtramp_address
, sigtramp_end
;
326 mipscoff_new_init (ignore
)
327 struct objfile
*ignore
;
332 mipscoff_symfile_init (objfile
)
333 struct objfile
*objfile
;
335 if (objfile
-> sym_private
!= NULL
)
337 mfree (objfile
-> md
, objfile
-> sym_private
);
339 objfile
-> sym_private
= NULL
;
343 mipscoff_symfile_read (objfile
, section_offsets
, mainline
)
344 struct objfile
*objfile
;
345 struct section_offsets
*section_offsets
;
348 init_minimal_symbol_collection ();
349 make_cleanup (discard_minimal_symbols
, 0);
351 /* Now that the executable file is positioned at symbol table,
352 process it and define symbols accordingly. */
354 read_mips_symtab(objfile
, section_offsets
);
356 /* Install any minimal symbols that have been collected as the current
357 minimal symbols for this objfile. */
359 install_minimal_symbols (objfile
);
362 /* Perform any local cleanups required when we are done with a particular
363 objfile. I.E, we are in the process of discarding all symbol information
364 for an objfile, freeing up all memory held for it, and unlinking the
365 objfile struct from the global list of known objfiles. */
368 mipscoff_symfile_finish (objfile
)
369 struct objfile
*objfile
;
371 if (objfile
-> sym_private
!= NULL
)
373 mfree (objfile
-> md
, objfile
-> sym_private
);
376 /* If we have a file symbol header lying around, blow it away. */
385 /* Allocate zeroed memory */
391 PTR p
= xmalloc (size
);
397 /* Exported procedure: Builds a symtab from the PST partial one.
398 Restores the environment in effect when PST was created, delegates
399 most of the work to an ancillary procedure, and sorts
400 and reorders the symtab list at the end */
403 mipscoff_psymtab_to_symtab(pst
)
404 struct partial_symtab
*pst
;
411 printf_filtered("Reading in symbols for %s...", pst
->filename
);
414 /* Restore the header and list of pending typedefs */
415 cur_hdr
= CUR_HDR(pst
);
417 next_symbol_text_func
= mips_next_symbol_text
;
419 psymtab_to_symtab_1(pst
, pst
->filename
);
421 /* Match with global symbols. This only needs to be done once,
422 after all of the symtabs and dependencies have been read in. */
423 scan_file_globals (pst
->objfile
);
426 printf_filtered("done.\n");
429 /* Exported procedure: Is PC in the signal trampoline code */
432 in_sigtramp(pc
, ignore
)
434 char *ignore
; /* function name */
436 if (sigtramp_address
== 0)
438 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
441 /* File-level interface functions */
443 /* Read the symtab information from file ABFD into memory. Also,
444 return address just past end of our text segment in *END_OF_TEXT_SEGP. */
447 read_the_mips_symtab(abfd
, end_of_text_segp
)
449 CORE_ADDR
*end_of_text_segp
;
451 int stsize
, st_hdrsize
;
453 struct hdr_ext hdr_ext
;
455 /* Header for executable/object file we read symbols from */
456 struct coff_exec filhdr
;
459 /* We need some info from the initial headers */
460 val
= bfd_seek(abfd
, (file_ptr
) 0, L_SET
);
461 val
= bfd_read((PTR
)&filhdr
, sizeof filhdr
, 1, abfd
);
463 if (end_of_text_segp
)
465 bfd_h_get_32 (abfd
, filhdr
.a
.text_start
) +
466 bfd_h_get_32 (abfd
, filhdr
.a
.tsize
);
468 /* Find and read the symbol table header */
469 st_hdrsize
= bfd_h_get_32 (abfd
, filhdr
.f
.f_nsyms
);
470 st_filptr
= bfd_h_get_32 (abfd
, filhdr
.f
.f_symptr
);
474 bfd_seek (abfd
, st_filptr
, L_SET
);
475 if (st_hdrsize
!= sizeof (hdr_ext
)) { /* Profanity check */
476 error ("Wrong header size: %d, not %d", st_hdrsize
,
479 if (bfd_read((PTR
)&hdr_ext
, st_hdrsize
, 1, abfd
) != st_hdrsize
)
481 ecoff_swap_hdr_in (abfd
, &hdr_ext
, &st_hdr
);
483 /* Find out how large the symbol table is */
484 stsize
= (st_hdr
.cbExtOffset
- (st_filptr
+ st_hdrsize
))
485 + st_hdr
.iextMax
* cbEXTR
;
487 /* Allocate space for the symbol table. Read it in. */
488 cur_hdr
= (HDRR
*) xmalloc(stsize
+ st_hdrsize
);
490 memcpy((PTR
)cur_hdr
, (PTR
)&hdr_ext
, st_hdrsize
);
491 if (bfd_read((char *)cur_hdr
+ st_hdrsize
, stsize
, 1, abfd
) != stsize
)
494 /* Fixup file_pointers in it */
495 fixup_symtab(cur_hdr
, (char *) cur_hdr
+ st_hdrsize
,
496 st_filptr
+ st_hdrsize
, abfd
);
500 error("Short read on %s", bfd_get_filename (abfd
));
504 /* Turn all file-relative pointers in the symtab described by HDR
505 into memory pointers, given that the symtab itself is located
506 at DATA in memory and F_PTR in the file.
508 Byte-swap all the data structures, in place, while we are at it --
509 except AUX entries, which we leave in their original byte order.
510 They will be swapped as they are used instead. (FIXME: we ought to
511 do all the data structures that way.) */
514 fixup_symtab (hdr
, data
, f_ptr
, abfd
)
525 struct rfd_ext
*rbase
;
527 /* This function depends on the external and internal forms
528 of the MIPS symbol table taking identical space. Check this
529 assumption at compile-time.
530 DO NOT DELETE THESE ENTRIES, OR COMMENT THEM OUT, JUST BECAUSE SOME
531 "LINT" OR COMPILER THINKS THEY ARE UNUSED! Thank you. */
532 static check_hdr1
[1 + sizeof (struct hdr_ext
) - sizeof (HDRR
)] = {0};
533 static check_hdr2
[1 + sizeof (HDRR
) - sizeof (struct hdr_ext
)] = {0};
534 static check_fdr1
[1 + sizeof (struct fdr_ext
) - sizeof (FDR
)] = {0};
535 static check_fdr2
[1 + sizeof (FDR
) - sizeof (struct fdr_ext
)] = {0};
536 static check_pdr1
[1 + sizeof (struct pdr_ext
) - sizeof (PDR
)] = {0};
537 static check_pdr2
[1 + sizeof (PDR
) - sizeof (struct pdr_ext
)] = {0};
538 static check_sym1
[1 + sizeof (struct sym_ext
) - sizeof (SYMR
)] = {0};
539 static check_sym2
[1 + sizeof (SYMR
) - sizeof (struct sym_ext
)] = {0};
540 static check_ext1
[1 + sizeof (struct ext_ext
) - sizeof (EXTR
)] = {0};
541 static check_ext2
[1 + sizeof (EXTR
) - sizeof (struct ext_ext
)] = {0};
542 static check_rfd1
[1 + sizeof (struct rfd_ext
) - sizeof (RFDT
)] = {0};
543 static check_rfd2
[1 + sizeof (RFDT
) - sizeof (struct rfd_ext
)] = {0};
545 /* Swap in the header record. */
546 ecoff_swap_hdr_in (abfd
, hdr
, hdr
);
549 * These fields are useless (and empty) by now:
550 * hdr->cbDnOffset, hdr->cbOptOffset
551 * We use them for other internal purposes.
554 hdr
->cbOptOffset
= 0;
557 if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr);
571 /* Fix all the RFD's. */
572 rbase
= (struct rfd_ext
*)(hdr
->cbRfdOffset
);
573 for (i
= 0; i
< hdr
->crfd
; i
++) {
574 ecoff_swap_rfd_in (abfd
, rbase
+i
, (pRFDT
) rbase
+i
);
577 /* Fix all string pointers inside the symtab, and
578 the FDR records. Also fix other miscellany. */
580 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
581 register unsigned code_offset
;
583 /* Header itself, and strings */
584 fh
= (FDR
*) (hdr
->cbFdOffset
) + f_idx
;
586 /* Swap in the FDR */
587 ecoff_swap_fdr_in (abfd
, fh
, fh
);
589 fh
->issBase
+= hdr
->cbSsOffset
;
591 fh
->rss
= (long)fh
->rss
+ fh
->issBase
;
594 fh
->isymBase
= (int)((SYMR
*)(hdr
->cbSymOffset
)+fh
->isymBase
);
596 /* FIXME! Probably don't want to do this here! */
597 for (s_idx
= 0; s_idx
< fh
->csym
; s_idx
++) {
598 sh
= (SYMR
*)fh
->isymBase
+ s_idx
;
599 ecoff_swap_sym_in (abfd
, sh
, sh
);
601 sh
->iss
= (long) sh
->iss
+ fh
->issBase
;
607 /* cannot fix fh->ipdFirst because it is a short */
608 #define IPDFIRST(h,fh) \
609 ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR))
611 /* Optional symbols (actually used for partial_symtabs) */
617 fh
->iauxBase
= hdr
->cbAuxOffset
+ fh
->iauxBase
* sizeof(union aux_ext
);
618 /* Relative file descriptor table */
619 fh
->rfdBase
= hdr
->cbRfdOffset
+ fh
->rfdBase
* sizeof(RFDT
);
623 fh
->cbLineOffset
+= hdr
->cbLineOffset
;
625 /* Procedure symbols. (XXX This should be done later) */
626 code_offset
= fh
->adr
;
627 for (s_idx
= 0; s_idx
< fh
->cpd
; s_idx
++) {
628 unsigned name
, only_ext
;
630 pr
= (PDR
*)(IPDFIRST(hdr
,fh
)) + s_idx
;
631 ecoff_swap_pdr_in (abfd
, pr
, pr
);
633 /* Simple rule to find files linked "-x" */
634 only_ext
= fh
->rss
== -1;
636 if (pr
->isym
== -1) {
637 /* static function */
641 name
= hdr
->cbExtOffset
+ pr
->isym
* sizeof(EXTR
);
642 sh
= &((EXTR
*)name
)->asym
;
646 sh
= (SYMR
*)fh
->isymBase
+ pr
->isym
;
647 /* Included code ? */
648 if (s_idx
== 0 && pr
->adr
!= 0)
649 code_offset
-= pr
->adr
;
652 /* Turn index into a pointer */
655 /* Fix line numbers */
656 pr
->cbLineOffset
+= fh
->cbLineOffset
;
658 /* Relocate address */
660 pr
->adr
+= code_offset
;
664 /* External symbols: swap in, and fix string */
665 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
666 esh
= (EXTR
*)(hdr
->cbExtOffset
) + s_idx
;
667 ecoff_swap_ext_in (abfd
, esh
, esh
);
668 esh
->asym
.iss
= esh
->asym
.iss
+ hdr
->cbSsExtOffset
;
673 /* Find a file descriptor given its index RF relative to a file CF */
681 f
= (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
682 /* Object files do not have the RFD table, all refs are absolute */
684 return (FDR
*) (cur_hdr
->cbFdOffset
) + rf
;
685 cf
= *((pRFDT
) f
->rfdBase
+ rf
);
686 return (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
689 /* Return a safer print NAME for a file descriptor */
695 if (name
== (char *) -1)
696 return "<stripped file>";
697 if (UNSAFE_DATA_ADDR(name
))
703 /* Read in and parse the symtab of the file OBJFILE. Symbols from
704 different sections are relocated via the SECTION_OFFSETS. */
707 read_mips_symtab (objfile
, section_offsets
)
708 struct objfile
*objfile
;
709 struct section_offsets
*section_offsets
;
711 CORE_ADDR end_of_text_seg
;
713 read_the_mips_symtab(objfile
->obfd
, &end_of_text_seg
);
715 parse_partial_symbols(end_of_text_seg
, objfile
, section_offsets
);
719 * Check to make sure file was compiled with -g.
720 * If not, warn the user of this limitation.
722 if (compare_glevel(max_glevel
, GLEVEL_2
) < 0) {
723 if (max_gdbinfo
== 0)
725 "\n%s not compiled with -g, debugging support is limited.\n",
728 "You should compile with -g2 or -g3 for best debugging support.\n");
734 /* Local utilities */
736 /* Map of FDR indexes to partial symtabs */
739 struct partial_symtab
*pst
; /* the psymtab proper */
740 int n_globals
; /* exported globals (external symbols) */
741 int globals_offset
; /* cumulative */
745 /* Utility stack, used to nest procedures and blocks properly.
746 It is a doubly linked list, to avoid too many alloc/free.
747 Since we might need it quite a few times it is NOT deallocated
750 static struct parse_stack
{
751 struct parse_stack
*next
, *prev
;
752 struct symtab
*cur_st
; /* Current symtab. */
753 struct block
*cur_block
; /* Block in it. */
754 int blocktype
; /* What are we parsing. */
755 int maxsyms
; /* Max symbols in this block. */
756 struct type
*cur_type
; /* Type we parse fields for. */
757 int cur_field
; /* Field number in cur_type. */
758 int procadr
; /* Start addres of this procedure */
759 int numargs
; /* Its argument count */
760 } *top_stack
; /* Top stack ptr */
763 /* Enter a new lexical context */
768 struct parse_stack
*new;
770 /* Reuse frames if possible */
771 if (top_stack
&& top_stack
->prev
)
772 new = top_stack
->prev
;
774 new = (struct parse_stack
*) xzalloc(sizeof(struct parse_stack
));
775 /* Initialize new frame with previous content */
777 register struct parse_stack
*prev
= new->prev
;
780 top_stack
->prev
= new;
782 new->next
= top_stack
;
787 /* Exit a lexical context */
795 top_stack
= top_stack
->next
;
799 /* Cross-references might be to things we haven't looked at
800 yet, e.g. type references. To avoid too many type
801 duplications we keep a quick fixup table, an array
802 of lists of references indexed by file descriptor */
804 static struct mips_pending
{
805 struct mips_pending
*next
; /* link */
806 SYMR
*s
; /* the symbol */
807 struct type
*t
; /* its partial type descriptor */
811 /* Check whether we already saw symbol SH in file FH as undefined */
813 static struct mips_pending
*
814 is_pending_symbol(fh
, sh
)
818 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
819 register struct mips_pending
*p
;
821 /* Linear search is ok, list is typically no more than 10 deep */
822 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
828 /* Add a new undef symbol SH of type T */
831 add_pending(fh
, sh
, t
)
836 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
837 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
839 /* Make sure we do not make duplicates */
841 p
= (struct mips_pending
*) xmalloc(sizeof(*p
));
844 p
->next
= pending_list
[f_idx
];
845 pending_list
[f_idx
] = p
;
847 sh
->reserved
= 1; /* for quick check */
850 /* Throw away undef entries when done with file index F_IDX */
851 /* FIXME -- storage leak. This is never called!!! --gnu */
859 register struct mips_pending
*p
, *q
;
861 for (p
= pending_list
[f_idx
]; p
; p
= q
) {
865 pending_list
[f_idx
] = 0;
871 prepend_tag_kind(tag_name
, type_code
)
873 enum type_code type_code
;
881 case TYPE_CODE_STRUCT
:
884 case TYPE_CODE_UNION
:
891 result
= (char*)obstack_alloc (¤t_objfile
->symbol_obstack
,
892 strlen(prefix
) + strlen(tag_name
) + 1);
893 sprintf(result
, "%s%s", prefix
, tag_name
);
898 /* Parsing Routines proper. */
900 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
901 For blocks, procedures and types we open a new lexical context.
902 This is basically just a big switch on the symbol's type.
903 Argument AX is the base pointer of aux symbols for this file (fh->iauxBase).
904 BIGEND says whether aux symbols are big-endian or little-endian.
905 Return count of SYMR's handled (normally one). */
908 parse_symbol(sh
, ax
, bigend
)
919 /* When a symbol is cross-referenced from other files/symbols
920 we mark it explicitly */
921 int pend
= (sh
->reserved
== 1);
922 enum address_class
class;
930 case stGlobal
: /* external symbol, goes into global block */
932 b
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
934 s
= new_symbol((char *)sh
->iss
);
935 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
938 case stStatic
: /* static data, goes into current block. */
940 b
= top_stack
->cur_block
;
941 s
= new_symbol((char *)sh
->iss
);
942 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
945 case stLocal
: /* local variable, goes into current block */
946 if (sh
->sc
== scRegister
) {
947 class = LOC_REGISTER
;
949 sh
->value
+= FP0_REGNUM
-32;
952 b
= top_stack
->cur_block
;
953 s
= new_symbol((char *)sh
->iss
);
954 SYMBOL_VALUE(s
) = sh
->value
;
956 data
: /* Common code for symbols describing data */
957 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
958 SYMBOL_CLASS(s
) = class;
961 /* Type could be missing in a number of cases */
962 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
963 sh
->index
== 0xfffff)
964 SYMBOL_TYPE(s
) = builtin_type_int
; /* undefined? */
966 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
967 /* Value of a data symbol is its memory address */
970 case stParam
: /* arg to procedure, goes into current block */
972 top_stack
->numargs
++;
974 name
= (char*)sh
->iss
;
975 /* Special GNU C++ name. */
976 if (name
[0] == CPLUS_MARKER
&& name
[1] == 't' && name
[2] == 0)
977 name
= "this"; /* FIXME, not alloc'd in obstack */
978 s
= new_symbol(name
);
980 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
981 if (sh
->sc
== scRegister
) {
982 SYMBOL_CLASS(s
) = LOC_REGPARM
;
984 sh
->value
+= FP0_REGNUM
-32;
986 SYMBOL_CLASS(s
) = LOC_ARG
;
987 SYMBOL_VALUE(s
) = sh
->value
;
988 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
989 add_symbol(s
, top_stack
->cur_block
);
991 /* FIXME: This has not been tested. See dbxread.c */
992 /* Add the type of this parameter to the function/procedure
993 type of this block. */
994 add_param_to_type(&top_stack
->cur_block
->function
->type
,s
);
998 case stLabel
: /* label, goes into current block */
999 s
= new_symbol((char *)sh
->iss
);
1000 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
; /* so that it can be used */
1001 SYMBOL_CLASS(s
) = LOC_LABEL
; /* but not misused */
1002 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
1003 SYMBOL_TYPE(s
) = builtin_type_int
;
1004 add_symbol(s
, top_stack
->cur_block
);
1007 case stProc
: /* Procedure, usually goes into global block */
1008 case stStaticProc
: /* Static procedure, goes into current block */
1009 s
= new_symbol((char *)sh
->iss
);
1010 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1011 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1012 /* Type of the return value */
1013 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1014 t
= builtin_type_int
;
1016 t
= parse_type(ax
+ sh
->index
+ 1, 0, bigend
);
1017 b
= top_stack
->cur_block
;
1018 if (sh
->st
== stProc
) {
1019 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1020 /* The next test should normally be true,
1021 but provides a hook for nested functions
1022 (which we don't want to make global). */
1023 if (b
== BLOCKVECTOR_BLOCK(bv
, STATIC_BLOCK
))
1024 b
= BLOCKVECTOR_BLOCK(bv
, GLOBAL_BLOCK
);
1028 /* Make a type for the procedure itself */
1030 /* FIXME: This has not been tested yet! See dbxread.c */
1031 /* Generate a template for the type of this function. The
1032 types of the arguments will be added as we read the symbol
1034 bcopy(SYMBOL_TYPE(s
),lookup_function_type(t
),sizeof(struct type
));
1036 SYMBOL_TYPE(s
) = lookup_function_type (t
);
1039 /* Create and enter a new lexical context */
1040 b
= new_block(top_stack
->maxsyms
);
1041 SYMBOL_BLOCK_VALUE(s
) = b
;
1042 BLOCK_FUNCTION(b
) = s
;
1043 BLOCK_START(b
) = BLOCK_END(b
) = sh
->value
;
1044 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1045 add_block(b
, top_stack
->cur_st
);
1047 /* Not if we only have partial info */
1048 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1052 top_stack
->cur_block
= b
;
1053 top_stack
->blocktype
= sh
->st
;
1054 top_stack
->cur_type
= SYMBOL_TYPE(s
);
1055 top_stack
->cur_field
= -1;
1056 top_stack
->procadr
= sh
->value
;
1057 top_stack
->numargs
= 0;
1059 sh
->value
= (long) SYMBOL_TYPE(s
);
1062 /* Beginning of code for structure, union, and enum definitions.
1063 They all share a common set of local variables, defined here. */
1065 enum type_code type_code
;
1071 case stStruct
: /* Start a block defining a struct type */
1072 type_code
= TYPE_CODE_STRUCT
;
1073 goto structured_common
;
1075 case stUnion
: /* Start a block defining a union type */
1076 type_code
= TYPE_CODE_UNION
;
1077 goto structured_common
;
1079 case stEnum
: /* Start a block defining an enum type */
1080 type_code
= TYPE_CODE_ENUM
;
1081 goto structured_common
;
1083 case stBlock
: /* Either a lexical block, or some type */
1084 if (sh
->sc
!= scInfo
)
1085 goto case_stBlock_code
; /* Lexical block */
1087 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
1089 /* Common code for handling struct, union, enum, and/or as-yet-
1090 unknown-type blocks of info about structured data. `type_code'
1091 has been set to the proper TYPE_CODE, if we know it. */
1094 top_stack
->blocktype
= stBlock
;
1096 s
= new_symbol((char *)sh
->iss
);
1097 SYMBOL_NAMESPACE(s
) = STRUCT_NAMESPACE
;
1098 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1099 SYMBOL_VALUE(s
) = 0;
1100 add_symbol(s
, top_stack
->cur_block
);
1102 /* First count the number of fields and the highest value. */
1105 for (tsym
= sh
+1; tsym
->st
!= stEnd
; tsym
++)
1107 if (tsym
->st
== stMember
) {
1108 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
1109 /* If the type of the member is Nil (or Void),
1110 without qualifiers, assume the tag is an
1112 if (tsym
->index
== indexNil
)
1113 type_code
= TYPE_CODE_ENUM
;
1115 ecoff_swap_tir_in (bigend
,
1116 &ax
[tsym
->index
].a_ti
,
1118 if ((tir
.bt
== btNil
|| tir
.bt
== btVoid
)
1119 && tir
.tq0
== tqNil
)
1120 type_code
= TYPE_CODE_ENUM
;
1123 if (tsym
->value
> max_value
)
1124 max_value
= tsym
->value
;
1126 else if (tsym
->st
== stBlock
1127 || tsym
->st
== stUnion
1128 || tsym
->st
== stEnum
1129 || tsym
->st
== stStruct
1130 || tsym
->st
== stParsed
) {
1131 if (tsym
->sc
== scVariant
) ; /*UNIMPLEMENTED*/
1132 if (tsym
->index
!= 0)
1133 tsym
= ((SYMR
*)cur_fdr
->isymBase
)
1136 else complain (&block_member_complaint
, tsym
->st
);
1139 /* In an stBlock, there is no way to distinguish structs,
1140 unions, and enums at this point. This is a bug in the
1141 original design (that has been fixed with the
1142 recent addition of the stStruct, stUnion, and stEnum
1143 symbol types.) The way you can tell is if/when you
1144 see a variable or field of that type. In that case
1145 the variable's type (in the AUX table) says if the
1146 type is struct, union, or enum,
1147 and points back to the stBlock here.
1148 So you can patch the tag kind up later - but only
1149 if there actually is a variable or field of that type.
1151 So until we know for sure, we will guess at this point.
1153 If the first member has index==indexNil or a void type,
1154 assume we have an enumeration.
1155 Otherwise, if there is more than one member, and all
1156 the members have offset 0, assume we have a union.
1157 Otherwise, assume we have a struct.
1159 The heuristic could guess wrong in the case of
1160 of an enumeration with no members or a union
1161 with one (or zero) members, or when all except the
1162 last field of a struct have width zero.
1163 These are uncommon and/or illegal situations, and
1164 in any case guessing wrong probably doesn't matter much.
1166 But if we later do find out we were wrong,
1167 we fixup the tag kind. Members of an enumeration
1168 must be handled differently from struct/union fields,
1169 and that is harder to patch up, but luckily we
1170 shouldn't need to. (If there are any enumeration
1171 members, we can tell for sure it's an enum here.) */
1173 if (type_code
== TYPE_CODE_UNDEF
)
1174 if (nfields
> 1 && max_value
== 0)
1175 type_code
= TYPE_CODE_UNION
;
1177 type_code
= TYPE_CODE_STRUCT
;
1179 /* If this type was expected, use its partial definition */
1181 t
= is_pending_symbol(cur_fdr
, sh
)->t
;
1183 t
= new_type(prepend_tag_kind((char *)sh
->iss
,
1186 TYPE_CODE(t
) = type_code
;
1187 TYPE_LENGTH(t
) = sh
->value
;
1188 TYPE_NFIELDS(t
) = nfields
;
1189 TYPE_FIELDS(t
) = f
= (struct field
*)
1190 TYPE_ALLOC (t
, nfields
* sizeof (struct field
));
1192 if (type_code
== TYPE_CODE_ENUM
) {
1193 /* This is a non-empty enum. */
1194 for (tsym
= sh
+ 1; tsym
->st
== stMember
; tsym
++) {
1195 struct symbol
*enum_sym
;
1196 f
->bitpos
= tsym
->value
;
1198 f
->name
= (char*)tsym
->iss
;
1201 enum_sym
= (struct symbol
*)
1202 obstack_alloc (¤t_objfile
->symbol_obstack
,
1203 sizeof (struct symbol
));
1204 memset ((PTR
)enum_sym
, 0, sizeof (struct symbol
));
1205 SYMBOL_NAME (enum_sym
) = f
->name
;
1206 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1207 SYMBOL_TYPE (enum_sym
) = t
;
1208 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1209 SYMBOL_VALUE (enum_sym
) = tsym
->value
;
1210 add_symbol(enum_sym
, top_stack
->cur_block
);
1212 /* Skip the stMembers that we've handled. */
1218 /* make this the current type */
1219 top_stack
->cur_type
= t
;
1220 top_stack
->cur_field
= 0;
1221 /* Mark that symbol has a type, and say which one */
1222 sh
->value
= (long) t
;
1225 /* End of local variables shared by struct, union, enum, and
1226 block (as yet unknown struct/union/enum) processing. */
1230 /* beginnning of (code) block. Value of symbol
1231 is the displacement from procedure start */
1233 top_stack
->blocktype
= stBlock
;
1234 b
= new_block(top_stack
->maxsyms
);
1235 BLOCK_START(b
) = sh
->value
+ top_stack
->procadr
;
1236 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1237 top_stack
->cur_block
= b
;
1238 add_block(b
, top_stack
->cur_st
);
1241 case stEnd
: /* end (of anything) */
1242 if (sh
->sc
== scInfo
) {
1243 /* Finished with type */
1244 top_stack
->cur_type
= 0;
1245 } else if (sh
->sc
== scText
&&
1246 (top_stack
->blocktype
== stProc
||
1247 top_stack
->blocktype
== stStaticProc
)) {
1248 /* Finished with procedure */
1249 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1250 struct mips_extra_func_info
*e
;
1254 BLOCK_END(top_stack
->cur_block
) += sh
->value
; /* size */
1256 /* Make up special symbol to contain procedure specific
1258 s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
1259 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
1260 SYMBOL_CLASS(s
) = LOC_CONST
;
1261 SYMBOL_TYPE(s
) = builtin_type_void
;
1262 e
= (struct mips_extra_func_info
*)
1263 obstack_alloc (¤t_objfile
->symbol_obstack
,
1264 sizeof (struct mips_extra_func_info
));
1265 SYMBOL_VALUE(s
) = (int)e
;
1266 e
->numargs
= top_stack
->numargs
;
1267 add_symbol(s
, top_stack
->cur_block
);
1269 /* Reallocate symbols, saving memory */
1270 b
= shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1272 /* f77 emits proc-level with address bounds==[0,0],
1273 So look for such child blocks, and patch them. */
1274 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++) {
1275 struct block
*b_bad
= BLOCKVECTOR_BLOCK(bv
,i
);
1276 if (BLOCK_SUPERBLOCK(b_bad
) == b
1277 && BLOCK_START(b_bad
) == top_stack
->procadr
1278 && BLOCK_END(b_bad
) == top_stack
->procadr
) {
1279 BLOCK_START(b_bad
) = BLOCK_START(b
);
1280 BLOCK_END(b_bad
) = BLOCK_END(b
);
1283 } else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
) {
1284 /* End of (code) block. The value of the symbol
1285 is the displacement from the procedure`s start
1286 address of the end of this block. */
1287 BLOCK_END(top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1288 shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1289 } else if (sh
->sc
== scText
&& top_stack
->blocktype
== stFile
) {
1290 /* End of file. Pop parse stack and ignore. Higher
1291 level code deals with this. */
1293 } else complain (&stEnd_complaint
, sh
->sc
);
1295 pop_parse_stack(); /* restore previous lexical context */
1298 case stMember
: /* member of struct or union */
1299 f
= &TYPE_FIELDS(top_stack
->cur_type
)[top_stack
->cur_field
++];
1300 f
->name
= (char*)sh
->iss
;
1301 f
->bitpos
= sh
->value
;
1303 f
->type
= parse_type(ax
+ sh
->index
, &f
->bitsize
, bigend
);
1306 case stTypedef
: /* type definition */
1307 s
= new_symbol((char *)sh
->iss
);
1308 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1309 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1310 SYMBOL_BLOCK_VALUE(s
) = top_stack
->cur_block
;
1311 add_symbol(s
, top_stack
->cur_block
);
1312 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
1313 sh
->value
= (long) SYMBOL_TYPE(s
);
1316 case stFile
: /* file name */
1318 top_stack
->blocktype
= sh
->st
;
1321 /* I`ve never seen these for C */
1323 break; /* register relocation */
1325 break; /* forwarding address */
1327 break; /* constant */
1329 complain(&unknown_mips_symtype_complaint
, sh
->st
);
1336 /* Parse the type information provided in the raw AX entries for
1337 the symbol SH. Return the bitfield size in BS, in case.
1338 We must byte-swap the AX entries before we use them; BIGEND says whether
1339 they are big-endian or little-endian (from fh->fBigendian). */
1341 static struct type
*
1342 parse_type(ax
, bs
, bigend
)
1347 /* Null entries in this map are treated specially */
1348 static struct type
**map_bt
[] =
1350 &builtin_type_void
, /* btNil */
1352 &builtin_type_char
, /* btChar */
1353 &builtin_type_unsigned_char
, /* btUChar */
1354 &builtin_type_short
, /* btShort */
1355 &builtin_type_unsigned_short
, /* btUShort */
1356 &builtin_type_int
, /* btInt */
1357 &builtin_type_unsigned_int
, /* btUInt */
1358 &builtin_type_long
, /* btLong */
1359 &builtin_type_unsigned_long
, /* btULong */
1360 &builtin_type_float
, /* btFloat */
1361 &builtin_type_double
, /* btDouble */
1368 &builtin_type_complex
, /* btComplex */
1369 &builtin_type_double_complex
, /* btDComplex */
1371 &builtin_type_fixed_dec
, /* btFixedDec */
1372 &builtin_type_float_dec
, /* btFloatDec */
1373 &builtin_type_string
, /* btString */
1376 &builtin_type_void
, /* btVoid */
1377 &builtin_type_long_long
, /* btLongLong */
1378 &builtin_type_unsigned_long_long
,/* btULongLong */
1382 struct type
*tp
= 0;
1385 enum type_code type_code
;
1387 /* Use aux as a type information record, map its basic type. */
1389 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1390 if (t
->bt
> (sizeof (map_bt
)/sizeof (*map_bt
))) {
1391 complain (&basic_type_complaint
, t
->bt
);
1392 return builtin_type_int
;
1394 if (map_bt
[t
->bt
]) {
1395 tp
= *map_bt
[t
->bt
];
1399 /* Cannot use builtin types -- build our own */
1402 tp
= lookup_pointer_type (builtin_type_void
);
1406 type_code
= TYPE_CODE_STRUCT
;
1410 type_code
= TYPE_CODE_UNION
;
1414 type_code
= TYPE_CODE_ENUM
;
1418 type_code
= TYPE_CODE_RANGE
;
1422 type_code
= TYPE_CODE_SET
;
1427 complain (&basic_type_complaint
, t
->bt
);
1428 return builtin_type_int
;
1432 /* Skip over any further type qualifiers (FIXME). */
1434 /* This is the way it would work if the compiler worked */
1438 ecoff_swap_tir_in (bigend
, ax
, t1
);
1439 } while (t1
->continued
);
1442 /* Move on to next aux */
1446 *bs
= AUX_GET_WIDTH (bigend
, ax
);
1450 /* All these types really point to some (common) MIPS type
1451 definition, and only the type-qualifiers fully identify
1452 them. We'll make the same effort at sharing. */
1453 if (t
->bt
== btIndirect
||
1454 t
->bt
== btStruct
||
1457 t
->bt
== btTypedef
||
1460 char name
[256], *pn
;
1462 /* Try to cross reference this type */
1463 ax
+= cross_ref(ax
, &tp
, type_code
, &pn
, bigend
);
1464 /* reading .o file ? */
1465 if (UNSAFE_DATA_ADDR(tp
))
1466 tp
= init_type(type_code
, 0, 0, (char *) NULL
,
1467 (struct objfile
*) NULL
);
1468 /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */
1469 sprintf(name
, fmt
, pn
);
1471 /* Usually, TYPE_CODE(tp) is already type_code. The main
1472 exception is if we guessed wrong re struct/union/enum. */
1473 if (TYPE_CODE(tp
) != type_code
) {
1474 complain (&bad_tag_guess_complaint
, name
);
1475 TYPE_CODE(tp
) = type_code
;
1477 if (TYPE_NAME(tp
) == NULL
|| !STREQ (TYPE_NAME(tp
), name
))
1478 TYPE_NAME(tp
) = obsavestring(name
, strlen(name
),
1479 ¤t_objfile
-> type_obstack
);
1482 /* Deal with range types */
1483 if (t
->bt
== btRange
) {
1484 TYPE_NFIELDS (tp
) = 2;
1485 TYPE_FIELDS (tp
) = (struct field
*)
1486 TYPE_ALLOC (tp
, 2 * sizeof (struct field
));
1487 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1488 ¤t_objfile
-> type_obstack
);
1489 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1491 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1492 ¤t_objfile
-> type_obstack
);
1493 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1497 /* Parse all the type qualifiers now. If there are more
1498 than 6 the game will continue in the next aux */
1500 #define PARSE_TQ(tq) \
1501 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend);
1503 again
: PARSE_TQ(tq0
);
1513 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1519 /* Make up a complex type from a basic one. Type is passed by
1520 reference in TPP and side-effected as necessary. The type
1521 qualifier TQ says how to handle the aux symbols at AX for
1522 the symbol SX we are currently analyzing. BIGEND says whether
1523 aux symbols are big-endian or little-endian.
1524 Returns the number of aux symbols we parsed. */
1527 upgrade_type(tpp
, tq
, ax
, bigend
)
1536 /* Used in array processing */
1545 t
= lookup_pointer_type (*tpp
);
1550 t
= lookup_function_type (*tpp
);
1555 /* We should probably try to use create_range_type and
1556 create_array_type here. FIXME! */
1558 t
= init_type(TYPE_CODE_ARRAY
, 0, 0, (char *) NULL
,
1559 (struct objfile
*) NULL
);
1560 TYPE_TARGET_TYPE(t
) = *tpp
;
1562 /* Determine and record the domain type (type of index) */
1563 ecoff_swap_rndx_in (bigend
, ax
, &rndx
);
1568 rf
= AUX_GET_ISYM (bigend
, ax
);
1571 fh
= get_rfd(cur_fd
, rf
);
1573 /* Fields are kept in an array */
1574 /* FIXME - Memory leak! */
1575 if (TYPE_NFIELDS(t
))
1576 TYPE_FIELDS(t
) = (struct field
*)
1577 xrealloc((PTR
) TYPE_FIELDS(t
),
1578 (TYPE_NFIELDS(t
)+1) * sizeof(struct field
));
1580 TYPE_FIELDS(t
) = (struct field
*)
1581 xzalloc(sizeof(struct field
));
1582 f
= &(TYPE_FIELD(t
,TYPE_NFIELDS(t
)));
1584 memset((PTR
)f
, 0, sizeof(struct field
));
1586 /* XXX */ f
->type
= parse_type(id
+ (union aux_ext
*)fh
->iauxBase
,
1587 &f
->bitsize
, bigend
);
1590 lower
= AUX_GET_DNLOW (bigend
, ax
);
1592 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1594 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1596 /* Check whether supplied array element bit size matches
1597 the known size of the element type. If this complaint
1598 ends up not happening, we can remove this code. It's
1599 here because we aren't sure we understand this *&%&$
1601 id
= TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) << 3; /* bitsize */
1603 /* Most likely an undefined type */
1605 TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) = id
>> 3;
1608 complain (&array_bitsize_complaint
, rf
);
1610 TYPE_LENGTH(t
) = (upper
< 0) ? 0 :
1611 (upper
- lower
+ 1) * (rf
>> 3);
1616 /* Volatile -- currently ignored */
1620 /* Const -- currently ignored */
1624 complain (&unknown_type_qual_complaint
, tq
);
1630 /* Parse a procedure descriptor record PR. Note that the procedure
1631 is parsed _after_ the local symbols, now we just insert the extra
1632 information we need into a MIPS_EFI_SYMBOL_NAME symbol that has already
1633 been placed in the procedure's main block. Note also that images that
1634 have been partially stripped (ld -x) have been deprived
1635 of local symbols, and we have to cope with them here.
1636 The procedure's code ends at BOUND */
1639 parse_procedure (pr
, bound
, have_stabs
)
1644 struct symbol
*s
, *i
;
1645 SYMR
*sh
= (SYMR
*)pr
->isym
;
1647 struct mips_extra_func_info
*e
;
1650 /* Static procedure at address pr->adr. Sigh. */
1651 if (sh
== (SYMR
*)-1) {
1652 complain (&pdr_static_symbol_complaint
, pr
->adr
);
1655 sh_name
= (char*)sh
->iss
;
1657 s
= lookup_symbol(sh_name
, NULL
, VAR_NAMESPACE
, 0, NULL
);
1659 s
= mylookup_symbol(sh_name
, top_stack
->cur_block
,
1660 VAR_NAMESPACE
, LOC_BLOCK
);
1663 b
= SYMBOL_BLOCK_VALUE(s
);
1665 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1669 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1670 s
= new_symbol(sh_name
);
1671 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1672 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1673 /* Donno its type, hope int is ok */
1674 SYMBOL_TYPE(s
) = lookup_function_type (builtin_type_int
);
1675 add_symbol(s
, top_stack
->cur_block
);
1676 /* Wont have symbols for this one */
1678 SYMBOL_BLOCK_VALUE(s
) = b
;
1679 BLOCK_FUNCTION(b
) = s
;
1680 BLOCK_START(b
) = pr
->adr
;
1681 BLOCK_END(b
) = bound
;
1682 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1683 add_block(b
, top_stack
->cur_st
);
1687 i
= mylookup_symbol(MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
, LOC_CONST
);
1691 e
= (struct mips_extra_func_info
*)SYMBOL_VALUE(i
);
1693 e
->pdr
.isym
= (long)s
;
1697 /* Parse the external symbol ES. Just call parse_symbol() after
1698 making sure we know where the aux are for it. For procedures,
1699 parsing of the PDRs has already provided all the needed
1700 information, we only parse them if SKIP_PROCEDURES is false,
1701 and only if this causes no symbol duplication.
1702 BIGEND says whether aux entries are big-endian or little-endian.
1704 This routine clobbers top_stack->cur_block and ->cur_st. */
1707 parse_external(es
, skip_procedures
, bigend
)
1709 int skip_procedures
;
1714 if (es
->ifd
!= ifdNil
) {
1716 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
) + cur_fd
;
1717 ax
= (union aux_ext
*)cur_fdr
->iauxBase
;
1719 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
);
1723 /* Reading .o files */
1724 if (es
->asym
.sc
== scUndefined
|| es
->asym
.sc
== scNil
) {
1726 switch (es
->asym
.st
) {
1728 case stProc
: what
= "procedure"; n_undef_procs
++; break;
1729 case stGlobal
: what
= "variable"; n_undef_vars
++; break;
1730 case stLabel
: what
= "label"; n_undef_labels
++; break;
1731 default : what
= "symbol"; break;
1734 /* FIXME: Turn this into a complaint? */
1736 printf_filtered("Warning: %s `%s' is undefined (in %s)\n",
1737 what
, es
->asym
.iss
, fdr_name((char *)cur_fdr
->rss
));
1741 switch (es
->asym
.st
) {
1743 /* If we have full symbols we do not need more */
1744 if (skip_procedures
)
1746 if (mylookup_symbol ((char *)es
->asym
.iss
, top_stack
->cur_block
,
1747 VAR_NAMESPACE
, LOC_BLOCK
))
1753 * Note that the case of a symbol with indexNil
1754 * must be handled anyways by parse_symbol().
1756 parse_symbol(&es
->asym
, ax
, bigend
);
1763 /* Parse the line number info for file descriptor FH into
1764 GDB's linetable LT. MIPS' encoding requires a little bit
1765 of magic to get things out. Note also that MIPS' line
1766 numbers can go back and forth, apparently we can live
1767 with that and do not need to reorder our linetables */
1772 struct linetable
*lt
;
1774 unsigned char *base
= (unsigned char*)fh
->cbLineOffset
;
1776 int delta
, count
, lineno
= 0;
1782 /* Scan by procedure descriptors */
1784 for (pr
= (PDR
*)IPDFIRST(cur_hdr
,fh
); j
< fh
->cpd
; j
++, pr
++) {
1787 /* No code for this one */
1788 if (pr
->iline
== ilineNil
||
1789 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
1792 * Aurgh! To know where to stop expanding we
1795 for (l
= 1; l
< (fh
->cpd
- j
); l
++)
1796 if (pr
[l
].iline
!= -1)
1798 if (l
== (fh
->cpd
- j
))
1803 * When procedures are moved around the linenumbers
1804 * are attributed to the next procedure up
1806 if (pr
->iline
>= halt
) continue;
1808 base
= (unsigned char*)pr
->cbLineOffset
;
1809 l
= pr
->adr
>> 2; /* in words */
1810 halt
+= (pr
->adr
>> 2) - pr
->iline
;
1811 for (lineno
= pr
->lnLow
; l
< halt
;) {
1812 count
= *base
& 0x0f;
1813 delta
= *base
++ >> 4;
1817 delta
= (base
[0] << 8) | base
[1];
1818 if (delta
>= 0x8000)
1822 lineno
+= delta
;/* first delta is 0 */
1823 k
= add_line(lt
, lineno
, l
, k
);
1829 /* Master parsing procedure for first-pass reading of file symbols
1830 into a partial_symtab.
1832 Parses the symtab described by the global symbolic header CUR_HDR.
1833 END_OF_TEXT_SEG gives the address just after the text segment for
1834 the symtab we are reading. */
1837 parse_partial_symbols (end_of_text_seg
, objfile
, section_offsets
)
1838 int end_of_text_seg
;
1839 struct objfile
*objfile
;
1840 struct section_offsets
*section_offsets
;
1843 HDRR
*hdr
= cur_hdr
;
1844 /* Running pointers */
1848 struct partial_symtab
*pst
;
1850 int past_first_source_file
= 0;
1852 /* List of current psymtab's include files */
1853 char **psymtab_include_list
;
1854 int includes_allocated
;
1857 struct pst_map
* fdr_to_pst
;
1858 /* Index within current psymtab dependency list */
1859 struct partial_symtab
**dependency_list
;
1860 int dependencies_used
, dependencies_allocated
;
1861 struct cleanup
*old_chain
;
1864 extern_tab
= (EXTR
**)obstack_alloc (&objfile
->psymbol_obstack
,
1865 sizeof(EXTR
*) * hdr
->iextMax
);
1867 includes_allocated
= 30;
1869 psymtab_include_list
= (char **) alloca (includes_allocated
*
1871 next_symbol_text_func
= mips_next_symbol_text
;
1873 dependencies_allocated
= 30;
1874 dependencies_used
= 0;
1876 (struct partial_symtab
**) alloca (dependencies_allocated
*
1877 sizeof (struct partial_symtab
*));
1879 last_source_file
= NULL
;
1884 * Only parse the Local and External symbols, and the Relative FDR.
1885 * Fixup enough of the loader symtab to be able to use it.
1886 * Allocate space only for the file's portions we need to
1891 max_glevel
= MIN_GLEVEL
;
1893 /* Allocate the map FDR -> PST.
1894 Minor hack: -O3 images might claim some global data belongs
1895 to FDR -1. We`ll go along with that */
1896 fdr_to_pst
= (struct pst_map
*)xzalloc((hdr
->ifdMax
+1) * sizeof *fdr_to_pst
);
1897 old_chain
= make_cleanup (free
, fdr_to_pst
);
1900 struct partial_symtab
* pst
= new_psymtab("", objfile
);
1901 fdr_to_pst
[-1].pst
= pst
;
1905 /* Pass 1 over external syms: Presize and partition the list */
1906 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1907 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1908 fdr_to_pst
[esh
->ifd
].n_globals
++;
1911 /* Pass 1.5 over files: partition out global symbol space */
1913 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++) {
1914 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
1915 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
1916 fdr_to_pst
[f_idx
].n_globals
= 0;
1919 /* Pass 2 over external syms: fill in external symbols */
1920 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1921 enum minimal_symbol_type ms_type
= mst_text
;
1922 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1924 extern_tab
[fdr_to_pst
[esh
->ifd
].globals_offset
1925 + fdr_to_pst
[esh
->ifd
].n_globals
++] = esh
;
1927 if (esh
->asym
.sc
== scUndefined
|| esh
->asym
.sc
== scNil
)
1930 switch (esh
->asym
.st
) {
1939 ms_type
= mst_unknown
;
1940 complain (&unknown_ext_complaint
, esh
->asym
.iss
);
1942 name
= (char *)esh
->asym
.iss
;
1943 prim_record_minimal_symbol (name
, esh
->asym
.value
, ms_type
);
1946 /* Pass 3 over files, over local syms: fill in static symbols */
1947 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
1948 struct partial_symtab
*save_pst
;
1951 cur_fdr
= fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
1953 if (fh
->csym
== 0) {
1954 fdr_to_pst
[f_idx
].pst
= NULL
;
1957 pst
= start_psymtab_common (objfile
, section_offsets
, (char*)fh
->rss
,
1958 fh
->cpd
? fh
->adr
: 0,
1959 objfile
->global_psymbols
.next
,
1960 objfile
->static_psymbols
.next
);
1961 pst
->read_symtab_private
= (char *)
1962 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
1965 /* Make everything point to everything. */
1966 FDR_IDX(pst
) = f_idx
;
1967 fdr_to_pst
[f_idx
].pst
= pst
;
1968 fh
->ioptBase
= (int)pst
;
1970 CUR_HDR(pst
) = cur_hdr
;
1972 /* The way to turn this into a symtab is to call... */
1973 pst
->read_symtab
= mipscoff_psymtab_to_symtab
;
1975 pst
->texthigh
= pst
->textlow
;
1977 /* For stabs-in-ecoff files, the second symbol must be @stab.
1978 This symbol is emitted by mips-tfile to signal
1979 that the current object file uses encapsulated stabs
1980 instead of mips ecoff for local symbols.
1981 (It is the second symbol because the first symbol is
1982 the stFile used to signal the start of a file). */
1984 && STREQ((char *)(((SYMR
*)fh
->isymBase
)[1].iss
), stabs_symbol
)) {
1985 processing_gcc_compilation
= 2;
1986 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
1989 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
1990 type_code
= MIPS_UNMARK_STAB(sh
->index
);
1991 if (!MIPS_IS_STAB(sh
)) {
1992 if (sh
->st
== stProc
|| sh
->st
== stStaticProc
) {
1993 long procaddr
= sh
->value
;
1994 sh
= AUX_GET_ISYM (fh
->fBigendian
,
1995 sh
->index
+ (union aux_ext
*)(fh
->iauxBase
))
1996 + (SYMR
*) fh
->isymBase
- 1;
1997 if (sh
->st
== stEnd
) {
1998 long high
= procaddr
+ sh
->value
;
1999 if (high
> pst
->texthigh
)
2000 pst
->texthigh
= high
;
2005 #define SET_NAMESTRING() namestring = (char*)sh->iss
2006 #define CUR_SYMBOL_TYPE type_code
2007 #define CUR_SYMBOL_VALUE sh->value
2008 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
2010 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
2011 #define HANDLE_RBRAC(val) \
2012 if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
2013 #include "partial-stab.h"
2017 processing_gcc_compilation
= 0;
2018 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2020 enum address_class
class;
2021 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2023 if (MIPS_IS_STAB(sh
)) {
2028 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
2029 sh
->index
== 0xfffff) {
2030 /* FIXME, premature? */
2035 name
= (char *)(sh
->iss
);
2042 case stProc
: /* Asm labels apparently */
2043 case stStaticProc
: /* Function */
2044 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2045 VAR_NAMESPACE
, LOC_BLOCK
,
2046 objfile
->static_psymbols
, sh
->value
,
2047 psymtab_language
, objfile
);
2048 /* Skip over procedure to next one. */
2049 if (sh
->index
>= hdr
->iauxMax
)
2051 /* Should not happen, but does when cross-compiling
2052 with the MIPS compiler. FIXME -- pull later. */
2053 complain (&index_complaint
, name
);
2054 new_sdx
= cur_sdx
+1; /* Don't skip at all */
2057 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2058 sh
->index
+ (union aux_ext
*)fh
->iauxBase
);
2059 procaddr
= sh
->value
;
2061 if (new_sdx
<= cur_sdx
)
2063 /* This should not happen either... FIXME. */
2064 complain (&aux_index_complaint
, name
);
2065 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2069 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
- 1;
2070 if (sh
->st
!= stEnd
)
2072 high
= procaddr
+ sh
->value
;
2073 if (high
> pst
->texthigh
)
2074 pst
->texthigh
= high
;
2077 case stStatic
: /* Variable */
2081 case stTypedef
: /* Typedef */
2082 class = LOC_TYPEDEF
;
2085 case stConstant
: /* Constant decl */
2092 case stBlock
: /* { }, str, un, enum*/
2093 if (sh
->sc
== scInfo
) {
2094 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2095 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2096 objfile
->static_psymbols
,
2098 psymtab_language
, objfile
);
2100 /* Skip over the block */
2101 new_sdx
= sh
->index
;
2102 if (new_sdx
<= cur_sdx
)
2104 /* This happens with the Ultrix kernel. */
2105 complain (&block_index_complaint
, name
);
2106 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2111 case stFile
: /* File headers */
2112 case stLabel
: /* Labels */
2113 case stEnd
: /* Ends of files */
2116 case stLocal
: /* Local variables */
2117 /* Normally these are skipped because we skip over
2118 all blocks we see. However, these can occur
2119 as visible symbols in a .h file that contains code. */
2123 /* Both complaints are valid: one gives symbol name,
2124 the other the offending symbol type. */
2125 complain (&unknown_sym_complaint
, sh
->iss
);
2126 complain (&unknown_st_complaint
, sh
->st
);
2130 /* Use this gdb symbol */
2131 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2132 VAR_NAMESPACE
, class,
2133 objfile
->static_psymbols
, sh
->value
,
2134 psymtab_language
, objfile
);
2136 cur_sdx
++; /* Go to next file symbol */
2139 /* Now do enter the external symbols. */
2140 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2141 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2142 PST_PRIVATE(save_pst
)->extern_count
= cur_sdx
;
2143 PST_PRIVATE(save_pst
)->extern_tab
= ext_ptr
;
2144 for (; --cur_sdx
>= 0; ext_ptr
++) {
2145 register struct partial_symbol
*psym
;
2146 enum address_class
class;
2148 if ((*ext_ptr
)->ifd
!= f_idx
)
2150 sh
= &(*ext_ptr
)->asym
;
2159 complain (&unknown_ext_complaint
, sh
->iss
);
2160 /* Fall through, pretend it's global. */
2165 if (objfile
->global_psymbols
.next
>=
2166 objfile
->global_psymbols
.list
+ objfile
->global_psymbols
.size
)
2167 extend_psymbol_list (&objfile
->global_psymbols
, objfile
);
2168 psym
= objfile
->global_psymbols
.next
++;
2169 SYMBOL_NAME (psym
) = (char*)sh
->iss
;
2170 SYMBOL_NAMESPACE (psym
) = VAR_NAMESPACE
;
2171 SYMBOL_CLASS (psym
) = class;
2172 SYMBOL_VALUE_ADDRESS (psym
) = (CORE_ADDR
)sh
->value
;
2176 end_psymtab (save_pst
, psymtab_include_list
, includes_used
,
2177 -1, save_pst
->texthigh
,
2178 dependency_list
, dependencies_used
);
2179 if (objfile
-> ei
.entry_point
>= save_pst
->textlow
&&
2180 objfile
-> ei
.entry_point
< save_pst
->texthigh
)
2182 objfile
-> ei
.entry_file_lowpc
= save_pst
->textlow
;
2183 objfile
-> ei
.entry_file_highpc
= save_pst
->texthigh
;
2187 /* Mark the last code address, and remember it for later */
2188 hdr
->cbDnOffset
= end_of_text_seg
;
2190 /* Now scan the FDRs for dependencies */
2191 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
2193 fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
2194 pst
= fdr_to_pst
[f_idx
].pst
;
2196 /* This should catch stabs-in-ecoff. */
2200 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2201 /* ...then presumably a .h file: drop reverse depends .h->.c */
2202 for (; s_id0
< fh
->crfd
; s_id0
++) {
2203 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2205 s_id0
++; /* Skip self-dependency */
2210 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2211 pst
->dependencies
= (struct partial_symtab
**)
2212 obstack_alloc (&objfile
->psymbol_obstack
,
2213 pst
->number_of_dependencies
*
2214 sizeof (struct partial_symtab
*));
2215 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2216 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2217 if (*rh
< 0 || *rh
>= hdr
->ifdMax
)
2218 complain(&bad_file_number_complaint
, *rh
);
2220 pst
->dependencies
[s_idx
-s_id0
] = fdr_to_pst
[*rh
].pst
;
2223 do_cleanups (old_chain
);
2228 /* Do the initial analisys of the F_IDX-th file descriptor.
2229 Allocates a partial symtab for it, and builds the list
2230 of dependent files by recursion. LEV says at which level
2231 of recursion we are called (to pretty up debug traces) */
2233 static struct partial_symtab
*
2234 parse_fdr(f_idx
, lev
, objfile
)
2237 struct objfile
*objfile
;
2240 register struct partial_symtab
*pst
;
2243 fh
= (FDR
*) (cur_hdr
->cbFdOffset
) + f_idx
;
2245 /* Use this to indicate into which symtab this file was parsed */
2247 return (struct partial_symtab
*) fh
->ioptBase
;
2249 /* Debuggability level */
2250 if (compare_glevel(max_glevel
, fh
->glevel
) < 0)
2251 max_glevel
= fh
->glevel
;
2253 /* Make a new partial_symtab */
2254 pst
= new_psymtab(fh
->rss
, objfile
);
2259 pst
->textlow
= fh
->adr
;
2260 pst
->texthigh
= fh
->cpd
; /* To be fixed later */
2263 /* Make everything point to everything. */
2264 FDR_IDX(pst
) = f_idx
;
2265 fdr_to_pst
[f_idx
].pst
= pst
;
2266 fh
->ioptBase
= (int)pst
;
2268 /* Analyze its dependencies */
2273 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2274 /* ...then presumably a .h file: drop reverse depends .h->.c */
2275 for (; s_id0
< fh
->crfd
; s_id0
++) {
2276 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2278 s_id0
++; /* Skip self-dependency */
2283 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2284 pst
->dependencies
= (struct partial_symtab
**)
2285 obstack_alloc (&objfile
->psymbol_obstack
,
2286 pst
->number_of_dependencies
*
2287 sizeof (struct partial_symtab
*));
2288 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2289 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2291 pst
->dependencies
[s_idx
-s_id0
] = parse_fdr(*rh
, lev
+1, objfile
);
2299 mips_next_symbol_text ()
2302 return (char*)((SYMR
*)cur_fdr
->isymBase
)[cur_sdx
].iss
;
2305 /* Ancillary function to psymtab_to_symtab(). Does all the work
2306 for turning the partial symtab PST into a symtab, recurring
2307 first on all dependent psymtabs. The argument FILENAME is
2308 only passed so we can see in debug stack traces what file
2311 This function has a split personality, based on whether the
2312 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
2313 The flow of control and even the memory allocation differs. FIXME. */
2316 psymtab_to_symtab_1(pst
, filename
)
2317 struct partial_symtab
*pst
;
2323 struct linetable
*lines
;
2330 /* Read in all partial symbtabs on which this one is dependent.
2331 NOTE that we do have circular dependencies, sigh. We solved
2332 that by setting pst->readin before this point. */
2334 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
2335 if (!pst
->dependencies
[i
]->readin
) {
2336 /* Inform about additional files to be read in. */
2339 fputs_filtered (" ", stdout
);
2341 fputs_filtered ("and ", stdout
);
2343 printf_filtered ("%s...",
2344 pst
->dependencies
[i
]->filename
);
2345 wrap_here (""); /* Flush output */
2348 /* We only pass the filename for debug purposes */
2349 psymtab_to_symtab_1(pst
->dependencies
[i
],
2350 pst
->dependencies
[i
]->filename
);
2353 /* Now read the symbols for this symtab */
2355 current_objfile
= pst
->objfile
;
2356 cur_fd
= FDR_IDX(pst
);
2357 fh
= (cur_fd
== -1) ? 0 : (FDR
*) (cur_hdr
->cbFdOffset
) + FDR_IDX(pst
);
2360 /* BOUND is the highest core address of this file's procedures */
2361 bound
= (cur_fd
== cur_hdr
->ifdMax
- 1) ?
2362 cur_hdr
->cbDnOffset
:
2365 /* See comment in parse_partial_symbols about the @stabs sentinel. */
2366 if (fh
&& fh
->csym
>= 2
2367 && STREQ((char *)(((SYMR
*)fh
->isymBase
)[1].iss
), stabs_symbol
)) {
2370 * This symbol table contains stabs-in-ecoff entries.
2375 /* We indicate that this is a GCC compilation so that certain features
2376 will be enabled in stabsread/dbxread. */
2377 processing_gcc_compilation
= 2;
2378 /* Parse local symbols first */
2380 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
2382 current_objfile
= NULL
;
2385 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
2386 register SYMR
*sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2387 char *name
= (char*)sh
->iss
;
2388 CORE_ADDR valu
= sh
->value
;
2389 if (MIPS_IS_STAB(sh
)) {
2390 int type_code
= MIPS_UNMARK_STAB(sh
->index
);
2391 process_one_symbol (type_code
, 0, valu
, name
,
2392 pst
->section_offsets
, pst
->objfile
);
2393 if (type_code
== N_FUN
) {
2394 /* Make up special symbol to contain
2395 procedure specific info */
2396 struct mips_extra_func_info
*e
=
2397 (struct mips_extra_func_info
*)
2398 obstack_alloc(¤t_objfile
->symbol_obstack
,
2399 sizeof(struct mips_extra_func_info
));
2400 struct symbol
*s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
2401 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
2402 SYMBOL_CLASS(s
) = LOC_CONST
;
2403 SYMBOL_TYPE(s
) = builtin_type_void
;
2404 SYMBOL_VALUE(s
) = (int)e
;
2405 add_symbol_to_list (s
, &local_symbols
);
2408 else if (sh
->st
== stLabel
&& sh
->index
!= indexNil
) {
2409 /* Handle encoded stab line number. */
2410 record_line (current_subfile
, sh
->index
, valu
);
2412 else complain (&stab_unknown_complaint
, sh
->iss
);
2414 st
= end_symtab (pst
->texthigh
, 0, 0, pst
->objfile
);
2417 /* Sort the symbol table now, we are done adding symbols to it.
2418 We must do this before parse_procedure calls lookup_symbol. */
2419 sort_symtab_syms(st
);
2421 /* This may not be necessary for stabs symtabs. FIXME. */
2424 /* Fill in procedure info next. We need to look-ahead to
2425 find out where each procedure's code ends. */
2427 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2428 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2429 parse_procedure (pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 1);
2434 * This symbol table contains ordinary ecoff entries.
2437 /* FIXME: doesn't use pst->section_offsets. */
2443 processing_gcc_compilation
= 0;
2445 /* How many symbols will we need */
2446 /* FIXME, this does not count enum values. */
2447 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
2450 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
2452 f_max
+= fh
->csym
+ fh
->cpd
;
2453 maxlines
= 2 * fh
->cline
;
2454 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
2457 lines
= LINETABLE(st
);
2458 pending_list
= (struct mips_pending
**) cur_hdr
->cbOptOffset
;
2459 if (pending_list
== 0) {
2460 pending_list
= (struct mips_pending
**)
2461 xzalloc(cur_hdr
->ifdMax
* sizeof(struct mips_pending
*));
2462 cur_hdr
->cbOptOffset
= (int)pending_list
;
2465 /* Get a new lexical context */
2468 top_stack
->cur_st
= st
;
2469 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(st
),
2471 BLOCK_START(top_stack
->cur_block
) = fh
? fh
->adr
: 0;
2472 BLOCK_END(top_stack
->cur_block
) = 0;
2473 top_stack
->blocktype
= stFile
;
2474 top_stack
->maxsyms
= 2*f_max
;
2475 top_stack
->cur_type
= 0;
2476 top_stack
->procadr
= 0;
2477 top_stack
->numargs
= 0;
2483 /* Parse local symbols first */
2485 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2486 sh
= (SYMR
*) (fh
->isymBase
) + cur_sdx
;
2487 cur_sdx
+= parse_symbol(sh
, (union aux_ext
*)fh
->iauxBase
,
2491 /* Linenumbers. At the end, check if we can save memory */
2493 parse_lines(fh
, lines
);
2494 if (lines
->nitems
< fh
->cline
)
2495 lines
= shrink_linetable(lines
);
2497 /* Fill in procedure info next. We need to look-ahead to
2498 find out where each procedure's code ends. */
2500 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2501 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2502 parse_procedure(pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 0);
2506 LINETABLE(st
) = lines
;
2508 /* .. and our share of externals.
2509 XXX use the global list to speed up things here. how?
2510 FIXME, Maybe quit once we have found the right number of ext's? */
2511 top_stack
->cur_st
= st
;
2512 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
2514 top_stack
->blocktype
= stFile
;
2515 top_stack
->maxsyms
=
2516 cur_hdr
->isymMax
+ cur_hdr
->ipdMax
+ cur_hdr
->iextMax
;
2518 ext_ptr
= PST_PRIVATE(pst
)->extern_tab
;
2519 for (i
= PST_PRIVATE(pst
)->extern_count
; --i
>= 0; ext_ptr
++)
2520 parse_external(*ext_ptr
, 1, fh
->fBigendian
);
2522 /* If there are undefined, tell the user */
2523 if (n_undef_symbols
) {
2524 printf_filtered("File %s contains %d unresolved references:",
2525 st
->filename
, n_undef_symbols
);
2526 printf_filtered("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
2527 n_undef_vars
, n_undef_procs
, n_undef_labels
);
2528 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
2533 /* Sort the symbol table now, we are done adding symbols to it.*/
2534 sort_symtab_syms(st
);
2539 /* Now link the psymtab and the symtab. */
2542 current_objfile
= NULL
;
2545 /* Ancillary parsing procedures. */
2547 /* Lookup the type at relative index RN. Return it in TPP
2548 if found and in any event come up with its name PNAME.
2549 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
2550 Return value says how many aux symbols we ate. */
2553 cross_ref(ax
, tpp
, type_code
, pname
, bigend
)
2556 enum type_code type_code
; /* Use to alloc new type if none is found. */
2564 ecoff_swap_rndx_in (bigend
, ax
, rn
);
2566 /* Escape index means 'the next one' */
2567 if (rn
->rfd
== 0xfff) {
2569 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
2576 *pname
= "<undefined>";
2579 * Find the relative file descriptor and the symbol in it
2581 FDR
*fh
= get_rfd(cur_fd
, rf
);
2586 * If we have processed this symbol then we left a forwarding
2587 * pointer to the corresponding GDB symbol. If not, we`ll put
2588 * it in a list of pending symbols, to be processed later when
2589 * the file f will be. In any event, we collect the name for
2590 * the type here. Which is why we made a first pass at
2593 sh
= (SYMR
*) (fh
->isymBase
) + rn
->index
;
2595 /* Careful, we might be looking at .o files */
2596 *pname
= (UNSAFE_DATA_ADDR(sh
->iss
)) ? "<undefined>" :
2599 /* Have we parsed it ? */
2600 if ((!UNSAFE_DATA_ADDR(sh
->value
)) && (sh
->st
== stParsed
)) {
2601 t
= (struct type
*) sh
->value
;
2604 /* Avoid duplicates */
2605 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
2609 *tpp
= init_type(type_code
, 0, 0, (char *) NULL
,
2610 (struct objfile
*) NULL
);
2611 add_pending(fh
, sh
, *tpp
);
2616 /* We used one auxent normally, two if we got a "next one" rf. */
2621 /* Quick&dirty lookup procedure, to avoid the MI ones that require
2622 keeping the symtab sorted */
2624 static struct symbol
*
2625 mylookup_symbol (name
, block
, namespace, class)
2627 register struct block
*block
;
2628 enum namespace namespace;
2629 enum address_class
class;
2631 register int bot
, top
, inc
;
2632 register struct symbol
*sym
;
2635 top
= BLOCK_NSYMS(block
);
2638 sym
= BLOCK_SYM(block
, bot
);
2639 if (SYMBOL_NAME(sym
)[0] == inc
2640 && SYMBOL_NAMESPACE(sym
) == namespace
2641 && SYMBOL_CLASS(sym
) == class
2642 && STREQ(SYMBOL_NAME(sym
), name
))
2646 block
= BLOCK_SUPERBLOCK (block
);
2648 return mylookup_symbol (name
, block
, namespace, class);
2653 /* Add a new symbol S to a block B.
2654 Infrequently, we will need to reallocate the block to make it bigger.
2655 We only detect this case when adding to top_stack->cur_block, since
2656 that's the only time we know how big the block is. FIXME. */
2663 int nsyms
= BLOCK_NSYMS(b
)++;
2664 struct block
*origb
;
2665 struct parse_stack
*stackp
;
2667 if (b
== top_stack
->cur_block
&&
2668 nsyms
>= top_stack
->maxsyms
) {
2669 complain (&block_overflow_complaint
, SYMBOL_NAME (s
));
2670 /* In this case shrink_block is actually grow_block, since
2671 BLOCK_NSYMS(b) is larger than its current size. */
2673 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
2675 /* Now run through the stack replacing pointers to the
2676 original block. shrink_block has already done this
2677 for the blockvector and BLOCK_FUNCTION. */
2678 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
) {
2679 if (stackp
->cur_block
== origb
) {
2680 stackp
->cur_block
= b
;
2681 stackp
->maxsyms
= BLOCK_NSYMS (b
);
2685 BLOCK_SYM(b
,nsyms
) = s
;
2688 /* Add a new block B to a symtab S */
2695 struct blockvector
*bv
= BLOCKVECTOR(s
);
2697 bv
= (struct blockvector
*)xrealloc((PTR
) bv
,
2698 sizeof(struct blockvector
) +
2699 BLOCKVECTOR_NBLOCKS(bv
)
2700 * sizeof(bv
->block
));
2701 if (bv
!= BLOCKVECTOR(s
))
2702 BLOCKVECTOR(s
) = bv
;
2704 BLOCKVECTOR_BLOCK(bv
, BLOCKVECTOR_NBLOCKS(bv
)++) = b
;
2707 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
2708 MIPS' linenumber encoding might need more than one byte
2709 to describe it, LAST is used to detect these continuation lines */
2712 add_line(lt
, lineno
, adr
, last
)
2713 struct linetable
*lt
;
2719 last
= -2; /* make sure we record first line */
2721 if (last
== lineno
) /* skip continuation lines */
2724 lt
->item
[lt
->nitems
].line
= lineno
;
2725 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
2729 /* Sorting and reordering procedures */
2731 /* Blocks with a smaller low bound should come first */
2734 compare_blocks(arg1
, arg2
)
2735 const void *arg1
, *arg2
;
2737 register int addr_diff
;
2738 struct block
**b1
= (struct block
**) arg1
;
2739 struct block
**b2
= (struct block
**) arg2
;
2741 addr_diff
= (BLOCK_START((*b1
))) - (BLOCK_START((*b2
)));
2743 return (BLOCK_END((*b1
))) - (BLOCK_END((*b2
)));
2747 /* Sort the blocks of a symtab S.
2748 Reorder the blocks in the blockvector by code-address,
2749 as required by some MI search routines */
2755 struct blockvector
*bv
= BLOCKVECTOR(s
);
2757 if (BLOCKVECTOR_NBLOCKS(bv
) <= 2) {
2759 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) == 0)
2760 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = 0;
2761 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) == 0)
2762 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) = 0;
2766 * This is very unfortunate: normally all functions are compiled in
2767 * the order they are found, but if the file is compiled -O3 things
2768 * are very different. It would be nice to find a reliable test
2769 * to detect -O3 images in advance.
2771 if (BLOCKVECTOR_NBLOCKS(bv
) > 3)
2772 qsort(&BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
),
2773 BLOCKVECTOR_NBLOCKS(bv
) - FIRST_LOCAL_BLOCK
,
2774 sizeof(struct block
*),
2778 register CORE_ADDR high
= 0;
2779 register int i
, j
= BLOCKVECTOR_NBLOCKS(bv
);
2781 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
2782 if (high
< BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
)))
2783 high
= BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
));
2784 BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = high
;
2787 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) =
2788 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
));
2790 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2791 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2792 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2793 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2797 /* Constructor/restructor/destructor procedures */
2799 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
2800 MAXSYMS and linenumbers MAXLINES we'll put in it */
2802 static struct symtab
*
2803 new_symtab(name
, maxsyms
, maxlines
, objfile
)
2807 struct objfile
*objfile
;
2809 struct symtab
*s
= allocate_symtab (name
, objfile
);
2811 LINETABLE(s
) = new_linetable(maxlines
);
2813 /* All symtabs must have at least two blocks */
2814 BLOCKVECTOR(s
) = new_bvect(2);
2815 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
) = new_block(maxsyms
);
2816 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), STATIC_BLOCK
) = new_block(maxsyms
);
2817 BLOCK_SUPERBLOCK( BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
),STATIC_BLOCK
)) =
2818 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
);
2820 s
->free_code
= free_linetable
;
2825 /* Allocate a new partial_symtab NAME */
2827 static struct partial_symtab
*
2828 new_psymtab(name
, objfile
)
2830 struct objfile
*objfile
;
2832 struct partial_symtab
*psymtab
;
2834 /* FIXME -- why (char *) -1 rather than NULL? */
2835 psymtab
= allocate_psymtab (name
== (char *) -1 ? "<no name>" : name
,
2838 /* Keep a backpointer to the file's symbols */
2840 psymtab
-> read_symtab_private
= (char *)
2841 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2842 CUR_HDR(psymtab
) = cur_hdr
;
2844 /* The way to turn this into a symtab is to call... */
2845 psymtab
->read_symtab
= mipscoff_psymtab_to_symtab
;
2850 /* Allocate a linetable array of the given SIZE. Since the struct
2851 already includes one item, we subtract one when calculating the
2852 proper size to allocate. */
2854 static struct linetable
*
2858 struct linetable
*l
;
2860 size
= (size
-1) * sizeof(l
->item
) + sizeof(struct linetable
);
2861 l
= (struct linetable
*)xmalloc(size
);
2866 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
2867 I am not so sure about the 3.4 ones.
2869 Since the struct linetable already includes one item, we subtract one when
2870 calculating the proper size to allocate. */
2872 static struct linetable
*
2873 shrink_linetable(lt
)
2874 struct linetable
* lt
;
2877 return (struct linetable
*) xrealloc ((PTR
)lt
,
2878 sizeof(struct linetable
)
2879 + (lt
->nitems
- 1) * sizeof(lt
->item
));
2882 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
2884 static struct blockvector
*
2888 struct blockvector
*bv
;
2891 size
= sizeof(struct blockvector
) + nblocks
* sizeof(struct block
*);
2892 bv
= (struct blockvector
*) xzalloc(size
);
2894 BLOCKVECTOR_NBLOCKS(bv
) = nblocks
;
2899 /* Allocate and zero a new block of MAXSYMS symbols */
2901 static struct block
*
2905 int size
= sizeof(struct block
) + (maxsyms
-1) * sizeof(struct symbol
*);
2907 return (struct block
*)xzalloc (size
);
2910 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
2911 Shrink_block can also be used by add_symbol to grow a block. */
2913 static struct block
*
2919 struct blockvector
*bv
= BLOCKVECTOR(s
);
2922 /* Just reallocate it and fix references to the old one */
2924 new = (struct block
*) xrealloc ((PTR
)b
, sizeof(struct block
) +
2925 (BLOCK_NSYMS(b
)-1) * sizeof(struct symbol
*));
2927 /* Should chase pointers to old one. Fortunately, that`s just
2928 the block`s function and inferior blocks */
2929 if (BLOCK_FUNCTION(new) && SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) == b
)
2930 SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) = new;
2931 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++)
2932 if (BLOCKVECTOR_BLOCK(bv
,i
) == b
)
2933 BLOCKVECTOR_BLOCK(bv
,i
) = new;
2934 else if (BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) == b
)
2935 BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) = new;
2939 /* Create a new symbol with printname NAME */
2941 static struct symbol
*
2945 struct symbol
*s
= (struct symbol
*)
2946 obstack_alloc (¤t_objfile
->symbol_obstack
, sizeof (struct symbol
));
2948 memset ((PTR
)s
, 0, sizeof (*s
));
2949 SYMBOL_NAME(s
) = name
;
2953 /* Create a new type with printname NAME */
2955 static struct type
*
2961 t
= alloc_type (current_objfile
);
2962 TYPE_NAME(t
) = name
;
2963 TYPE_CPLUS_SPECIFIC(t
) = (struct cplus_struct_type
*)
2964 &cplus_struct_default
;
2969 /* Things used for calling functions in the inferior.
2970 These functions are exported to our companion
2971 mips-tdep.c file and are here because they play
2972 with the symbol-table explicitly. */
2974 /* Sigtramp: make sure we have all the necessary information
2975 about the signal trampoline code. Since the official code
2976 from MIPS does not do so, we make up that information ourselves.
2977 If they fix the library (unlikely) this code will neutralize itself. */
2984 struct block
*b
, *b0
;
2986 sigtramp_address
= -1;
2988 /* We know it is sold as sigvec */
2989 s
= lookup_symbol("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
2991 /* Most programs do not play with signals */
2993 s
= lookup_symbol("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
2996 b0
= SYMBOL_BLOCK_VALUE(s
);
2998 /* A label of sigvec, to be more precise */
2999 s
= lookup_symbol("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
3002 /* But maybe this program uses its own version of sigvec */
3006 /* Did we or MIPSco fix the library ? */
3007 if (SYMBOL_CLASS(s
) == LOC_BLOCK
)
3009 sigtramp_address
= BLOCK_START(SYMBOL_BLOCK_VALUE(s
));
3010 sigtramp_end
= BLOCK_END(SYMBOL_BLOCK_VALUE(s
));
3014 sigtramp_address
= SYMBOL_VALUE(s
);
3015 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
3017 /* But what symtab does it live in ? */
3018 st
= find_pc_symtab(SYMBOL_VALUE(s
));
3021 * Ok, there goes the fix: turn it into a procedure, with all the
3022 * needed info. Note we make it a nested procedure of sigvec,
3023 * which is the way the (assembly) code is actually written.
3025 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
3026 SYMBOL_CLASS(s
) = LOC_BLOCK
;
3027 SYMBOL_TYPE(s
) = init_type(TYPE_CODE_FUNC
, 4, 0, (char *) NULL
,
3028 (struct objfile
*) NULL
);
3029 TYPE_TARGET_TYPE(SYMBOL_TYPE(s
)) = builtin_type_void
;
3031 /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
3033 SYMBOL_BLOCK_VALUE(s
) = b
;
3034 BLOCK_START(b
) = sigtramp_address
;
3035 BLOCK_END(b
) = sigtramp_end
;
3036 BLOCK_FUNCTION(b
) = s
;
3037 BLOCK_SUPERBLOCK(b
) = BLOCK_SUPERBLOCK(b0
);
3041 /* Make a MIPS_EFI_SYMBOL_NAME entry for it */
3043 struct mips_extra_func_info
*e
=
3044 (struct mips_extra_func_info
*)
3045 xzalloc(sizeof(struct mips_extra_func_info
));
3047 e
->numargs
= 0; /* the kernel thinks otherwise */
3048 /* align_longword(sigcontext + SIGFRAME) */
3049 e
->pdr
.frameoffset
= 0x150;
3050 e
->pdr
.framereg
= SP_REGNUM
;
3052 e
->pdr
.regmask
= -2;
3053 e
->pdr
.regoffset
= -(41 * sizeof(int));
3054 e
->pdr
.fregmask
= -1;
3055 e
->pdr
.fregoffset
= -(37 * sizeof(int));
3056 e
->pdr
.isym
= (long)s
;
3058 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
3059 s
= new_symbol(MIPS_EFI_SYMBOL_NAME
);
3060 SYMBOL_VALUE(s
) = (int) e
;
3061 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
3062 SYMBOL_CLASS(s
) = LOC_CONST
;
3063 SYMBOL_TYPE(s
) = builtin_type_void
;
3064 current_objfile
= NULL
;
3067 BLOCK_SYM(b
,BLOCK_NSYMS(b
)++) = s
;
3071 /* Fake up identical offsets for all sections. */
3073 struct section_offsets
*
3074 mipscoff_symfile_offsets (objfile
, addr
)
3075 struct objfile
*objfile
;
3078 struct section_offsets
*section_offsets
;
3081 section_offsets
= (struct section_offsets
*)
3082 obstack_alloc (&objfile
-> psymbol_obstack
,
3083 sizeof (struct section_offsets
) +
3084 sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
3086 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
3087 ANOFFSET (section_offsets
, i
) = addr
;
3089 return section_offsets
;
3092 /* Initialization */
3094 static struct sym_fns ecoff_sym_fns
=
3096 "ecoff", /* sym_name: name or name prefix of BFD target type */
3097 5, /* sym_namelen: number of significant sym_name chars */
3098 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
3099 mipscoff_symfile_init
,/* sym_init: read initial info, setup for sym_read() */
3100 mipscoff_symfile_read
,/* sym_read: read a symbol file into symtab */
3101 mipscoff_symfile_finish
,/* sym_finish: finished with file, cleanup */
3102 mipscoff_symfile_offsets
,/* sym_offsets: dummy FIXME til implem sym reloc */
3103 NULL
/* next: pointer to next struct sym_fns */
3108 _initialize_mipsread ()
3110 add_symtab_fns (&ecoff_sym_fns
);
3112 /* Missing basic types */
3114 builtin_type_string
=
3115 init_type(TYPE_CODE_STRING
,
3116 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3118 (struct objfile
*) NULL
);
3119 builtin_type_complex
=
3120 init_type(TYPE_CODE_FLT
,
3121 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3123 (struct objfile
*) NULL
);
3124 builtin_type_double_complex
=
3125 init_type(TYPE_CODE_FLT
,
3126 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3127 0, "double complex",
3128 (struct objfile
*) NULL
);
3129 builtin_type_fixed_dec
=
3130 init_type(TYPE_CODE_INT
,
3131 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3133 (struct objfile
*) NULL
);
3134 builtin_type_float_dec
=
3135 init_type(TYPE_CODE_FLT
,
3136 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3137 0, "floating decimal",
3138 (struct objfile
*) NULL
);