1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993 Free Software
4 Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work
5 by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* This module provides three functions: mipscoff_symfile_init,
24 which initializes to read a symbol file; mipscoff_new_init, which
25 discards existing cached information when all symbols are being
26 discarded; and mipscoff_symfile_read, which reads a symbol table
29 mipscoff_symfile_read only does the minimum work necessary for letting the
30 user "name" things symbolically; it does not read the entire symtab.
31 Instead, it reads the external and static symbols and puts them in partial
32 symbol tables. When more extensive information is requested of a
33 file, the corresponding partial symbol table is mutated into a full
34 fledged symbol table by going back and reading the symbols
35 for real. mipscoff_psymtab_to_symtab() is called indirectly through
36 a pointer in the psymtab to do this.
38 ECOFF symbol tables are mostly written in the byte order of the
39 target machine. However, one section of the table (the auxiliary
40 symbol information) is written in the host byte order. There is a
41 bit in the other symbol info which describes which host byte order
42 was used. ECOFF thereby takes the trophy from Intel `b.out' for
43 the most brain-dead adaptation of a file format to byte order.
45 This module can read all four of the known byte-order combinations,
46 on any type of host. */
56 #include "stabsread.h"
57 #include "complaints.h"
59 /* These are needed if the tm.h file does not contain the necessary
60 mips specific definitions. */
62 #ifndef MIPS_EFI_SYMBOL_NAME
63 #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
65 #include "coff/symconst.h"
66 typedef struct mips_extra_func_info
{
69 } *mips_extra_func_info_t
;
79 #include <sys/types.h>
82 #include <sys/param.h>
87 #include "gdb-stabs.h"
91 #include "coff/internal.h"
92 #include "coff/mips.h" /* COFF-like aspects of ecoff files */
93 #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */
95 /* FIXME: coff/internal.h and aout/aout64.h both define N_ABS. We
96 want the definition from aout/aout64.h. */
98 /* FIXME: coff/mips.h and aout/aout64.h both define ZMAGIC. We don't
102 #include "libaout.h" /* Private BFD a.out information. */
103 #include "aout/aout64.h"
104 #include "aout/stab_gnu.h" /* STABS information */
106 /* FIXME: libcoff.h and libaout.h both define a couple of macros. We
109 #undef obj_sym_filepos
111 #include "libcoff.h" /* Private BFD COFF information. */
112 #include "libecoff.h" /* Private BFD ECOFF information. */
114 #include "expression.h"
115 #include "language.h" /* Needed inside partial-stab.h */
117 /* Each partial symbol table entry contains a pointer to private data
118 for the read_symtab() function to use when expanding a partial
119 symbol table entry to a full symbol table entry.
121 For mipsread this structure contains the index of the FDR that this
122 psymtab represents and a pointer to the BFD that the psymtab was
125 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
126 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
127 #define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
133 EXTR
*extern_tab
; /* Pointer to external symbols for this file. */
134 int extern_count
; /* Size of extern_tab. */
135 struct mips_pending
**pending_list
;
138 /* Things we import explicitly from other modules */
140 extern int info_verbose
;
142 /* Various complaints about symbol reading that don't abort the process */
144 struct complaint bad_file_number_complaint
=
145 {"bad file number %d", 0, 0};
147 struct complaint index_complaint
=
148 {"bad aux index at symbol %s", 0, 0};
150 struct complaint aux_index_complaint
=
151 {"bad proc end in aux found from symbol %s", 0, 0};
153 struct complaint block_index_complaint
=
154 {"bad aux index at block symbol %s", 0, 0};
156 struct complaint unknown_ext_complaint
=
157 {"unknown external symbol %s", 0, 0};
159 struct complaint unknown_sym_complaint
=
160 {"unknown local symbol %s", 0, 0};
162 struct complaint unknown_st_complaint
=
163 {"with type %d", 0, 0};
165 struct complaint block_overflow_complaint
=
166 {"block containing %s overfilled", 0, 0};
168 struct complaint basic_type_complaint
=
169 {"cannot map MIPS basic type 0x%x", 0, 0};
171 struct complaint unknown_type_qual_complaint
=
172 {"unknown type qualifier 0x%x", 0, 0};
174 struct complaint array_bitsize_complaint
=
175 {"size of array target type not known, assuming %d bits", 0, 0};
177 struct complaint bad_tag_guess_complaint
=
178 {"guessed tag type of %s incorrectly", 0, 0};
180 struct complaint block_member_complaint
=
181 {"declaration block contains unhandled symbol type %d", 0, 0};
183 struct complaint stEnd_complaint
=
184 {"stEnd with storage class %d not handled", 0, 0};
186 struct complaint unknown_mips_symtype_complaint
=
187 {"unknown symbol type 0x%x", 0, 0};
189 struct complaint stab_unknown_complaint
=
190 {"unknown stabs symbol %s", 0, 0};
192 struct complaint pdr_for_nonsymbol_complaint
=
193 {"PDR for %s, but no symbol", 0, 0};
195 struct complaint pdr_static_symbol_complaint
=
196 {"can't handle PDR for static proc at 0x%x", 0, 0};
198 struct complaint bad_setjmp_pdr_complaint
=
199 {"fixing bad setjmp PDR from libc", 0, 0};
201 /* Macros and extra defs */
203 /* Already-parsed symbols are marked specially */
205 #define stParsed stType
207 /* Puns: hard to find whether -g was used and how */
209 #define MIN_GLEVEL GLEVEL_0
210 #define compare_glevel(a,b) \
211 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
212 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
214 /* Things that really are local to this module */
216 /* Remember what we deduced to be the source language of this psymtab. */
218 static enum language psymtab_language
= language_unknown
;
224 /* Pointer to current file decriptor record, and its index */
229 /* Index of current symbol */
233 /* Note how much "debuggable" this image is. We would like
234 to see at least one FDR with full symbols */
239 /* When examining .o files, report on undefined symbols */
241 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
243 /* Pseudo symbol to use when putting stabs into the symbol table. */
245 static char stabs_symbol
[] = STABS_SYMBOL
;
247 /* Extra builtin types */
249 struct type
*builtin_type_complex
;
250 struct type
*builtin_type_double_complex
;
251 struct type
*builtin_type_fixed_dec
;
252 struct type
*builtin_type_float_dec
;
253 struct type
*builtin_type_string
;
255 /* Forward declarations */
258 read_mips_symtab
PARAMS ((struct objfile
*, struct section_offsets
*));
261 read_the_mips_symtab
PARAMS ((bfd
*));
264 upgrade_type
PARAMS ((struct type
**, int, union aux_ext
*, int));
267 parse_partial_symbols
PARAMS ((struct objfile
*,
268 struct section_offsets
*));
271 cross_ref
PARAMS ((union aux_ext
*, struct type
**, enum type_code
, char **,
275 fixup_sigtramp
PARAMS ((void));
277 static struct symbol
*
278 new_symbol
PARAMS ((char *));
281 new_type
PARAMS ((char *));
283 static struct block
*
284 new_block
PARAMS ((int));
286 static struct symtab
*
287 new_symtab
PARAMS ((char *, int, int, struct objfile
*));
289 static struct linetable
*
290 new_linetable
PARAMS ((int));
292 static struct blockvector
*
293 new_bvect
PARAMS ((int));
296 parse_type
PARAMS ((union aux_ext
*, int *, int));
298 static struct symbol
*
299 mylookup_symbol
PARAMS ((char *, struct block
*, enum namespace,
300 enum address_class
));
302 static struct block
*
303 shrink_block
PARAMS ((struct block
*, struct symtab
*));
306 xzalloc
PARAMS ((unsigned int));
309 sort_blocks
PARAMS ((struct symtab
*));
312 compare_blocks
PARAMS ((const void *, const void *));
314 static struct partial_symtab
*
315 new_psymtab
PARAMS ((char *, struct objfile
*));
318 static struct partial_symtab
*
319 parse_fdr
PARAMS ((int, int, struct objfile
*));
323 psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*, char *));
326 add_block
PARAMS ((struct block
*, struct symtab
*));
329 add_symbol
PARAMS ((struct symbol
*, struct block
*));
332 add_line
PARAMS ((struct linetable
*, int, CORE_ADDR
, int));
334 static struct linetable
*
335 shrink_linetable
PARAMS ((struct linetable
*));
338 mips_next_symbol_text
PARAMS ((void));
340 /* Things we export to other modules */
342 /* Address bounds for the signal trampoline in inferior, if any */
343 /* FIXME: Nothing really seems to use this. Why is it here? */
345 CORE_ADDR sigtramp_address
, sigtramp_end
;
348 mipscoff_new_init (ignore
)
349 struct objfile
*ignore
;
351 sigtramp_address
= 0;
352 stabsread_new_init ();
353 buildsym_new_init ();
357 mipscoff_symfile_init (objfile
)
358 struct objfile
*objfile
;
360 if (objfile
->sym_private
!= NULL
)
362 mfree (objfile
->md
, objfile
->sym_private
);
364 objfile
->sym_private
= NULL
;
368 mipscoff_symfile_read (objfile
, section_offsets
, mainline
)
369 struct objfile
*objfile
;
370 struct section_offsets
*section_offsets
;
373 init_minimal_symbol_collection ();
374 make_cleanup (discard_minimal_symbols
, 0);
376 /* Now that the executable file is positioned at symbol table,
377 process it and define symbols accordingly. */
379 read_mips_symtab (objfile
, section_offsets
);
381 /* Install any minimal symbols that have been collected as the current
382 minimal symbols for this objfile. */
384 install_minimal_symbols (objfile
);
387 /* Perform any local cleanups required when we are done with a particular
388 objfile. I.E, we are in the process of discarding all symbol information
389 for an objfile, freeing up all memory held for it, and unlinking the
390 objfile struct from the global list of known objfiles. */
393 mipscoff_symfile_finish (objfile
)
394 struct objfile
*objfile
;
396 if (objfile
->sym_private
!= NULL
)
398 mfree (objfile
->md
, objfile
->sym_private
);
404 /* Allocate zeroed memory */
410 PTR p
= xmalloc (size
);
416 /* Exported procedure: Builds a symtab from the PST partial one.
417 Restores the environment in effect when PST was created, delegates
418 most of the work to an ancillary procedure, and sorts
419 and reorders the symtab list at the end */
422 mipscoff_psymtab_to_symtab (pst
)
423 struct partial_symtab
*pst
;
431 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
435 next_symbol_text_func
= mips_next_symbol_text
;
437 psymtab_to_symtab_1 (pst
, pst
->filename
);
439 /* Match with global symbols. This only needs to be done once,
440 after all of the symtabs and dependencies have been read in. */
441 scan_file_globals (pst
->objfile
);
444 printf_filtered ("done.\n");
447 /* Exported procedure: Is PC in the signal trampoline code */
450 in_sigtramp (pc
, ignore
)
452 char *ignore
; /* function name */
454 if (sigtramp_address
== 0)
456 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
459 /* File-level interface functions */
461 /* Read the symtab information from file ABFD into memory. */
464 read_the_mips_symtab (abfd
)
467 if (ecoff_slurp_symbolic_info (abfd
) == false)
468 error ("Error reading symbol table: %s", bfd_errmsg (bfd_error
));
471 /* Find a file descriptor given its index RF relative to a file CF */
481 fdrs
= ecoff_data (cur_bfd
)->fdr
;
483 /* Object files do not have the RFD table, all refs are absolute */
486 ecoff_swap_rfd_in (cur_bfd
,
487 ecoff_data (cur_bfd
)->external_rfd
+ f
->rfdBase
+ rf
,
492 /* Return a safer print NAME for a file descriptor */
499 return "<stripped file>";
502 return ecoff_data (cur_bfd
)->ss
+ f
->issBase
+ f
->rss
;
506 /* Read in and parse the symtab of the file OBJFILE. Symbols from
507 different sections are relocated via the SECTION_OFFSETS. */
510 read_mips_symtab (objfile
, section_offsets
)
511 struct objfile
*objfile
;
512 struct section_offsets
*section_offsets
;
514 cur_bfd
= objfile
->obfd
;
516 read_the_mips_symtab (objfile
->obfd
);
518 parse_partial_symbols (objfile
, section_offsets
);
521 /* Check to make sure file was compiled with -g. If not, warn the
522 user of this limitation. */
523 if (compare_glevel (max_glevel
, GLEVEL_2
) < 0)
525 if (max_gdbinfo
== 0)
526 printf ("\n%s not compiled with -g, debugging support is limited.\n",
528 printf ("You should compile with -g2 or -g3 for best debugging support.\n");
534 /* Local utilities */
536 /* Map of FDR indexes to partial symtabs */
540 struct partial_symtab
*pst
; /* the psymtab proper */
541 int n_globals
; /* exported globals (external symbols) */
542 int globals_offset
; /* cumulative */
546 /* Utility stack, used to nest procedures and blocks properly.
547 It is a doubly linked list, to avoid too many alloc/free.
548 Since we might need it quite a few times it is NOT deallocated
551 static struct parse_stack
553 struct parse_stack
*next
, *prev
;
554 struct symtab
*cur_st
; /* Current symtab. */
555 struct block
*cur_block
; /* Block in it. */
556 int blocktype
; /* What are we parsing. */
557 int maxsyms
; /* Max symbols in this block. */
558 struct type
*cur_type
; /* Type we parse fields for. */
559 int cur_field
; /* Field number in cur_type. */
560 int procadr
; /* Start addres of this procedure */
561 int numargs
; /* Its argument count */
564 *top_stack
; /* Top stack ptr */
567 /* Enter a new lexical context */
572 struct parse_stack
*new;
574 /* Reuse frames if possible */
575 if (top_stack
&& top_stack
->prev
)
576 new = top_stack
->prev
;
578 new = (struct parse_stack
*) xzalloc (sizeof (struct parse_stack
));
579 /* Initialize new frame with previous content */
582 register struct parse_stack
*prev
= new->prev
;
585 top_stack
->prev
= new;
587 new->next
= top_stack
;
592 /* Exit a lexical context */
600 top_stack
= top_stack
->next
;
604 /* Cross-references might be to things we haven't looked at
605 yet, e.g. type references. To avoid too many type
606 duplications we keep a quick fixup table, an array
607 of lists of references indexed by file descriptor */
609 static struct mips_pending
611 struct mips_pending
*next
; /* link */
612 struct sym_ext
*s
; /* the symbol */
613 struct type
*t
; /* its partial type descriptor */
617 /* Check whether we already saw symbol SH in file FH as undefined */
619 static struct mips_pending
*
620 is_pending_symbol (fh
, sh
)
624 int f_idx
= fh
- ecoff_data (cur_bfd
)->fdr
;
625 register struct mips_pending
*p
;
627 /* Linear search is ok, list is typically no more than 10 deep */
628 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
634 /* Add a new undef symbol SH of type T */
637 add_pending (fh
, sh
, t
)
642 int f_idx
= fh
- ecoff_data (cur_bfd
)->fdr
;
643 struct mips_pending
*p
= is_pending_symbol (fh
, sh
);
645 /* Make sure we do not make duplicates */
648 p
= (struct mips_pending
*) xmalloc (sizeof (*p
));
651 p
->next
= pending_list
[f_idx
];
652 pending_list
[f_idx
] = p
;
656 /* Throw away undef entries when done with file index F_IDX */
657 /* FIXME -- storage leak. This is never called!!! --gnu */
665 register struct mips_pending
*p
, *q
;
667 for (p
= pending_list
[f_idx
]; p
; p
= q
)
672 pending_list
[f_idx
] = 0;
679 /* Parsing Routines proper. */
681 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
682 For blocks, procedures and types we open a new lexical context.
683 This is basically just a big switch on the symbol's type. Argument
684 AX is the base pointer of aux symbols for this file (fh->iauxBase).
685 EXT_SH points to the unswapped symbol, which is needed for struct,
686 union, etc., types; it is NULL for an EXTR. BIGEND says whether
687 aux symbols are big-endian or little-endian. Return count of
688 SYMR's handled (normally one).
690 FIXME: This modifies the symbol, but the only way we have to save
691 the modified information is to stuff it back into the BFD data. */
694 parse_symbol (sh
, ax
, ext_sh
, bigend
)
697 struct sym_ext
*ext_sh
;
703 struct mips_pending
*pend
;
707 enum address_class
class;
710 if (ext_sh
== (struct sym_ext
*) NULL
)
711 name
= ecoff_data (cur_bfd
)->ssext
+ sh
->iss
;
713 name
= ecoff_data (cur_bfd
)->ss
+ cur_fdr
->issBase
+ sh
->iss
;
720 case stGlobal
: /* external symbol, goes into global block */
722 b
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
724 s
= new_symbol (name
);
725 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
728 case stStatic
: /* static data, goes into current block. */
730 b
= top_stack
->cur_block
;
731 s
= new_symbol (name
);
732 if (sh
->sc
== scCommon
)
734 /* It is a FORTRAN common block. At least for SGI Fortran the
735 address is not in the symbol; we need to fix it later in
736 scan_file_globals. */
737 int bucket
= hashname (SYMBOL_NAME (s
));
738 SYMBOL_VALUE_CHAIN (s
) = global_sym_chain
[bucket
];
739 global_sym_chain
[bucket
] = s
;
742 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
745 case stLocal
: /* local variable, goes into current block */
746 if (sh
->sc
== scRegister
)
748 class = LOC_REGISTER
;
750 sh
->value
+= FP0_REGNUM
- 32;
754 b
= top_stack
->cur_block
;
755 s
= new_symbol (name
);
756 SYMBOL_VALUE (s
) = sh
->value
;
758 data
: /* Common code for symbols describing data */
759 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
760 SYMBOL_CLASS (s
) = class;
763 /* Type could be missing in a number of cases */
764 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
765 sh
->index
== 0xfffff)
766 SYMBOL_TYPE (s
) = builtin_type_int
; /* undefined? */
768 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
769 /* Value of a data symbol is its memory address */
772 case stParam
: /* arg to procedure, goes into current block */
774 top_stack
->numargs
++;
776 /* Special GNU C++ name. */
777 if (name
[0] == CPLUS_MARKER
&& name
[1] == 't' && name
[2] == 0)
778 name
= "this"; /* FIXME, not alloc'd in obstack */
779 s
= new_symbol (name
);
781 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
785 /* Pass by value in register. */
786 SYMBOL_CLASS(s
) = LOC_REGPARM
;
788 sh
->value
+= FP0_REGNUM
-32;
791 /* Pass by reference on stack. */
792 SYMBOL_CLASS(s
) = LOC_REF_ARG
;
795 /* Pass by reference in register. */
796 SYMBOL_CLASS(s
) = LOC_REGPARM_ADDR
;
799 /* Pass by value on stack. */
800 SYMBOL_CLASS(s
) = LOC_ARG
;
803 SYMBOL_VALUE (s
) = sh
->value
;
804 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
805 add_symbol (s
, top_stack
->cur_block
);
807 /* FIXME: This has not been tested. See dbxread.c */
808 /* Add the type of this parameter to the function/procedure
809 type of this block. */
810 add_param_to_type (&top_stack
->cur_block
->function
->type
, s
);
814 case stLabel
: /* label, goes into current block */
815 s
= new_symbol (name
);
816 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
; /* so that it can be used */
817 SYMBOL_CLASS (s
) = LOC_LABEL
; /* but not misused */
818 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
819 SYMBOL_TYPE (s
) = builtin_type_int
;
820 add_symbol (s
, top_stack
->cur_block
);
823 case stProc
: /* Procedure, usually goes into global block */
824 case stStaticProc
: /* Static procedure, goes into current block */
825 s
= new_symbol (name
);
826 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
827 SYMBOL_CLASS (s
) = LOC_BLOCK
;
828 /* Type of the return value */
829 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
830 t
= builtin_type_int
;
832 t
= parse_type (ax
+ sh
->index
+ 1, 0, bigend
);
833 b
= top_stack
->cur_block
;
834 if (sh
->st
== stProc
)
836 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
837 /* The next test should normally be true,
838 but provides a hook for nested functions
839 (which we don't want to make global). */
840 if (b
== BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
))
841 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
845 /* Make a type for the procedure itself */
847 /* FIXME: This has not been tested yet! See dbxread.c */
848 /* Generate a template for the type of this function. The
849 types of the arguments will be added as we read the symbol
851 bcopy (SYMBOL_TYPE (s
), lookup_function_type (t
), sizeof (struct type
));
853 SYMBOL_TYPE (s
) = lookup_function_type (t
);
856 /* Create and enter a new lexical context */
857 b
= new_block (top_stack
->maxsyms
);
858 SYMBOL_BLOCK_VALUE (s
) = b
;
859 BLOCK_FUNCTION (b
) = s
;
860 BLOCK_START (b
) = BLOCK_END (b
) = sh
->value
;
861 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
862 add_block (b
, top_stack
->cur_st
);
864 /* Not if we only have partial info */
865 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
869 top_stack
->cur_block
= b
;
870 top_stack
->blocktype
= sh
->st
;
871 top_stack
->cur_type
= SYMBOL_TYPE (s
);
872 top_stack
->cur_field
= -1;
873 top_stack
->procadr
= sh
->value
;
874 top_stack
->numargs
= 0;
876 sh
->value
= (long) SYMBOL_TYPE (s
);
879 /* Beginning of code for structure, union, and enum definitions.
880 They all share a common set of local variables, defined here. */
882 enum type_code type_code
;
883 struct sym_ext
*ext_tsym
;
888 case stStruct
: /* Start a block defining a struct type */
889 type_code
= TYPE_CODE_STRUCT
;
890 goto structured_common
;
892 case stUnion
: /* Start a block defining a union type */
893 type_code
= TYPE_CODE_UNION
;
894 goto structured_common
;
896 case stEnum
: /* Start a block defining an enum type */
897 type_code
= TYPE_CODE_ENUM
;
898 goto structured_common
;
900 case stBlock
: /* Either a lexical block, or some type */
901 if (sh
->sc
!= scInfo
&& sh
->sc
!= scCommon
)
902 goto case_stBlock_code
; /* Lexical block */
904 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
906 /* Common code for handling struct, union, enum, and/or as-yet-
907 unknown-type blocks of info about structured data. `type_code'
908 has been set to the proper TYPE_CODE, if we know it. */
911 top_stack
->blocktype
= stBlock
;
913 s
= new_symbol (name
);
914 SYMBOL_NAMESPACE (s
) = STRUCT_NAMESPACE
;
915 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
916 SYMBOL_VALUE (s
) = 0;
917 add_symbol (s
, top_stack
->cur_block
);
919 /* First count the number of fields and the highest value. */
922 for (ext_tsym
= ext_sh
+ 1; ; ext_tsym
++)
926 ecoff_swap_sym_in (cur_bfd
, ext_tsym
, &tsym
);
928 if (tsym
.st
== stEnd
)
931 if (tsym
.st
== stMember
)
933 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
934 /* If the type of the member is Nil (or Void),
935 without qualifiers, assume the tag is an
937 if (tsym
.index
== indexNil
)
938 type_code
= TYPE_CODE_ENUM
;
941 ecoff_swap_tir_in (bigend
,
942 &ax
[tsym
.index
].a_ti
,
944 if ((tir
.bt
== btNil
|| tir
.bt
== btVoid
)
946 type_code
= TYPE_CODE_ENUM
;
949 if (tsym
.value
> max_value
)
950 max_value
= tsym
.value
;
952 else if (tsym
.st
== stBlock
953 || tsym
.st
== stUnion
955 || tsym
.st
== stStruct
956 || tsym
.st
== stParsed
)
958 if (tsym
.sc
== scVariant
); /*UNIMPLEMENTED*/
961 /* This is something like a struct within a
962 struct. Skip over the fields of the inner
963 struct. The -1 is because the for loop will
964 increment ext_tsym. */
965 ext_tsym
= (ecoff_data (cur_bfd
)->external_sym
972 complain (&block_member_complaint
, tsym
.st
);
975 /* In an stBlock, there is no way to distinguish structs,
976 unions, and enums at this point. This is a bug in the
977 original design (that has been fixed with the recent
978 addition of the stStruct, stUnion, and stEnum symbol
979 types.) The way you can tell is if/when you see a variable
980 or field of that type. In that case the variable's type
981 (in the AUX table) says if the type is struct, union, or
982 enum, and points back to the stBlock here. So you can
983 patch the tag kind up later - but only if there actually is
984 a variable or field of that type.
986 So until we know for sure, we will guess at this point.
988 If the first member has index==indexNil or a void type,
989 assume we have an enumeration.
990 Otherwise, if there is more than one member, and all
991 the members have offset 0, assume we have a union.
992 Otherwise, assume we have a struct.
994 The heuristic could guess wrong in the case of of an
995 enumeration with no members or a union with one (or zero)
996 members, or when all except the last field of a struct have
997 width zero. These are uncommon and/or illegal situations,
998 and in any case guessing wrong probably doesn't matter
1001 But if we later do find out we were wrong, we fixup the tag
1002 kind. Members of an enumeration must be handled
1003 differently from struct/union fields, and that is harder to
1004 patch up, but luckily we shouldn't need to. (If there are
1005 any enumeration members, we can tell for sure it's an enum
1008 if (type_code
== TYPE_CODE_UNDEF
)
1009 if (nfields
> 1 && max_value
== 0)
1010 type_code
= TYPE_CODE_UNION
;
1012 type_code
= TYPE_CODE_STRUCT
;
1014 /* If this type was expected, use its partial definition */
1015 pend
= is_pending_symbol (cur_fdr
, ext_sh
);
1016 if (pend
!= (struct mips_pending
*) NULL
)
1019 t
= new_type (NULL
);
1021 TYPE_TAG_NAME (t
) = obconcat (¤t_objfile
->symbol_obstack
,
1023 TYPE_CODE (t
) = type_code
;
1024 TYPE_LENGTH (t
) = sh
->value
;
1025 TYPE_NFIELDS (t
) = nfields
;
1026 TYPE_FIELDS (t
) = f
= ((struct field
*)
1028 nfields
* sizeof (struct field
)));
1030 if (type_code
== TYPE_CODE_ENUM
)
1032 /* This is a non-empty enum. */
1033 for (ext_tsym
= ext_sh
+ 1; ; ext_tsym
++)
1036 struct symbol
*enum_sym
;
1038 ecoff_swap_sym_in (cur_bfd
, ext_tsym
, &tsym
);
1040 if (tsym
.st
!= stMember
)
1043 f
->bitpos
= tsym
.value
;
1045 f
->name
= (ecoff_data (cur_bfd
)->ss
1050 enum_sym
= ((struct symbol
*)
1051 obstack_alloc (¤t_objfile
->symbol_obstack
,
1052 sizeof (struct symbol
)));
1053 memset ((PTR
) enum_sym
, 0, sizeof (struct symbol
));
1054 SYMBOL_NAME (enum_sym
) = f
->name
;
1055 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1056 SYMBOL_TYPE (enum_sym
) = t
;
1057 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1058 SYMBOL_VALUE (enum_sym
) = tsym
.value
;
1059 add_symbol (enum_sym
, top_stack
->cur_block
);
1061 /* Skip the stMembers that we've handled. */
1066 SYMBOL_TYPE (s
) = t
;
1067 /* make this the current type */
1068 top_stack
->cur_type
= t
;
1069 top_stack
->cur_field
= 0;
1070 /* Mark that symbol has a type, and say which one */
1071 sh
->value
= (long) t
;
1074 /* End of local variables shared by struct, union, enum, and
1075 block (as yet unknown struct/union/enum) processing. */
1079 /* beginnning of (code) block. Value of symbol
1080 is the displacement from procedure start */
1081 push_parse_stack ();
1082 top_stack
->blocktype
= stBlock
;
1083 b
= new_block (top_stack
->maxsyms
);
1084 BLOCK_START (b
) = sh
->value
+ top_stack
->procadr
;
1085 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1086 top_stack
->cur_block
= b
;
1087 add_block (b
, top_stack
->cur_st
);
1090 case stEnd
: /* end (of anything) */
1091 if (sh
->sc
== scInfo
|| sh
->sc
== scCommon
)
1093 /* Finished with type */
1094 top_stack
->cur_type
= 0;
1096 else if (sh
->sc
== scText
&&
1097 (top_stack
->blocktype
== stProc
||
1098 top_stack
->blocktype
== stStaticProc
))
1100 /* Finished with procedure */
1101 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
1102 struct mips_extra_func_info
*e
;
1106 BLOCK_END (top_stack
->cur_block
) += sh
->value
; /* size */
1108 /* Make up special symbol to contain procedure specific info */
1109 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
1110 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
1111 SYMBOL_CLASS (s
) = LOC_CONST
;
1112 SYMBOL_TYPE (s
) = builtin_type_void
;
1113 e
= ((struct mips_extra_func_info
*)
1114 obstack_alloc (¤t_objfile
->symbol_obstack
,
1115 sizeof (struct mips_extra_func_info
)));
1116 SYMBOL_VALUE (s
) = (int) e
;
1117 e
->numargs
= top_stack
->numargs
;
1118 add_symbol (s
, top_stack
->cur_block
);
1120 /* Reallocate symbols, saving memory */
1121 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1123 /* f77 emits proc-level with address bounds==[0,0],
1124 So look for such child blocks, and patch them. */
1125 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
1127 struct block
*b_bad
= BLOCKVECTOR_BLOCK (bv
, i
);
1128 if (BLOCK_SUPERBLOCK (b_bad
) == b
1129 && BLOCK_START (b_bad
) == top_stack
->procadr
1130 && BLOCK_END (b_bad
) == top_stack
->procadr
)
1132 BLOCK_START (b_bad
) = BLOCK_START (b
);
1133 BLOCK_END (b_bad
) = BLOCK_END (b
);
1137 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
)
1139 /* End of (code) block. The value of the symbol is the
1140 displacement from the procedure`s start address of the
1141 end of this block. */
1142 BLOCK_END (top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1143 shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1145 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stFile
)
1147 /* End of file. Pop parse stack and ignore. Higher
1148 level code deals with this. */
1152 complain (&stEnd_complaint
, sh
->sc
);
1154 pop_parse_stack (); /* restore previous lexical context */
1157 case stMember
: /* member of struct or union */
1158 f
= &TYPE_FIELDS (top_stack
->cur_type
)[top_stack
->cur_field
++];
1160 f
->bitpos
= sh
->value
;
1162 f
->type
= parse_type (ax
+ sh
->index
, &f
->bitsize
, bigend
);
1165 case stTypedef
: /* type definition */
1166 s
= new_symbol (name
);
1167 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1168 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
1169 SYMBOL_BLOCK_VALUE (s
) = top_stack
->cur_block
;
1170 add_symbol (s
, top_stack
->cur_block
);
1171 SYMBOL_TYPE (s
) = parse_type (ax
+ sh
->index
, 0, bigend
);
1172 sh
->value
= (long) SYMBOL_TYPE (s
);
1175 case stFile
: /* file name */
1176 push_parse_stack ();
1177 top_stack
->blocktype
= sh
->st
;
1180 /* I`ve never seen these for C */
1182 break; /* register relocation */
1184 break; /* forwarding address */
1186 break; /* constant */
1188 complain (&unknown_mips_symtype_complaint
, sh
->st
);
1197 /* Parse the type information provided in the raw AX entries for
1198 the symbol SH. Return the bitfield size in BS, in case.
1199 We must byte-swap the AX entries before we use them; BIGEND says whether
1200 they are big-endian or little-endian (from fh->fBigendian). */
1202 static struct type
*
1203 parse_type (ax
, bs
, bigend
)
1208 /* Null entries in this map are treated specially */
1209 static struct type
**map_bt
[] =
1211 &builtin_type_void
, /* btNil */
1213 &builtin_type_char
, /* btChar */
1214 &builtin_type_unsigned_char
,/* btUChar */
1215 &builtin_type_short
, /* btShort */
1216 &builtin_type_unsigned_short
, /* btUShort */
1217 &builtin_type_int
, /* btInt */
1218 &builtin_type_unsigned_int
, /* btUInt */
1219 &builtin_type_long
, /* btLong */
1220 &builtin_type_unsigned_long
,/* btULong */
1221 &builtin_type_float
, /* btFloat */
1222 &builtin_type_double
, /* btDouble */
1229 &builtin_type_complex
, /* btComplex */
1230 &builtin_type_double_complex
, /* btDComplex */
1232 &builtin_type_fixed_dec
, /* btFixedDec */
1233 &builtin_type_float_dec
, /* btFloatDec */
1234 &builtin_type_string
, /* btString */
1237 &builtin_type_void
, /* btVoid */
1238 &builtin_type_long_long
, /* btLongLong */
1239 &builtin_type_unsigned_long_long
, /* btULongLong */
1243 struct type
*tp
= 0;
1246 enum type_code type_code
= TYPE_CODE_UNDEF
;
1248 /* Use aux as a type information record, map its basic type. */
1250 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1251 if (t
->bt
> (sizeof (map_bt
) / sizeof (*map_bt
)))
1253 complain (&basic_type_complaint
, t
->bt
);
1254 return builtin_type_int
;
1258 tp
= *map_bt
[t
->bt
];
1263 /* Cannot use builtin types -- build our own */
1267 tp
= lookup_pointer_type (builtin_type_void
);
1270 type_code
= TYPE_CODE_STRUCT
;
1273 type_code
= TYPE_CODE_UNION
;
1276 type_code
= TYPE_CODE_ENUM
;
1279 type_code
= TYPE_CODE_RANGE
;
1282 type_code
= TYPE_CODE_SET
;
1286 complain (&basic_type_complaint
, t
->bt
);
1287 return builtin_type_int
;
1291 /* Skip over any further type qualifiers (FIXME). */
1294 /* This is the way it would work if the compiler worked */
1299 ecoff_swap_tir_in (bigend
, &ax
->a_ti
, t1
);
1301 while (t1
->continued
);
1304 /* Move on to next aux */
1309 *bs
= AUX_GET_WIDTH (bigend
, ax
);
1313 /* All these types really point to some (common) MIPS type
1314 definition, and only the type-qualifiers fully identify
1315 them. We'll make the same effort at sharing. */
1316 if (t
->bt
== btStruct
||
1320 /* btSet (I think) implies that the name is a tag name, not a typedef
1321 name. This apparently is a MIPS extension for C sets. */
1326 /* Try to cross reference this type */
1327 ax
+= cross_ref (ax
, &tp
, type_code
, &name
, bigend
);
1328 /* reading .o file ? */
1329 if (tp
== (struct type
*) NULL
)
1330 tp
= init_type (type_code
, 0, 0, (char *) NULL
,
1331 (struct objfile
*) NULL
);
1333 /* Usually, TYPE_CODE(tp) is already type_code. The main
1334 exception is if we guessed wrong re struct/union/enum. */
1335 if (TYPE_CODE (tp
) != type_code
)
1337 complain (&bad_tag_guess_complaint
, name
);
1338 TYPE_CODE (tp
) = type_code
;
1340 if (TYPE_TAG_NAME (tp
) == NULL
|| !STREQ (TYPE_TAG_NAME (tp
), name
))
1341 TYPE_TAG_NAME (tp
) = obsavestring (name
, strlen (name
),
1342 ¤t_objfile
->type_obstack
);
1345 /* All these types really point to some (common) MIPS type
1346 definition, and only the type-qualifiers fully identify
1347 them. We'll make the same effort at sharing. */
1348 if (t
->bt
== btIndirect
||
1353 /* Try to cross reference this type */
1354 ax
+= cross_ref (ax
, &tp
, type_code
, &name
, bigend
);
1355 /* reading .o file ? */
1356 if (tp
== (struct type
*) NULL
)
1357 tp
= init_type (type_code
, 0, 0, (char *) NULL
,
1358 (struct objfile
*) NULL
);
1360 /* Usually, TYPE_CODE(tp) is already type_code. The main
1361 exception is if we guessed wrong re struct/union/enum. */
1362 if (TYPE_CODE (tp
) != type_code
)
1364 complain (&bad_tag_guess_complaint
, name
);
1365 TYPE_CODE (tp
) = type_code
;
1367 if (TYPE_NAME (tp
) == NULL
|| !STREQ (TYPE_NAME (tp
), name
))
1368 TYPE_NAME (tp
) = obsavestring (name
, strlen (name
),
1369 ¤t_objfile
->type_obstack
);
1372 /* Deal with range types */
1373 if (t
->bt
== btRange
)
1375 TYPE_NFIELDS (tp
) = 2;
1376 TYPE_FIELDS (tp
) = ((struct field
*)
1377 TYPE_ALLOC (tp
, 2 * sizeof (struct field
)));
1378 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1379 ¤t_objfile
->type_obstack
);
1380 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1382 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1383 ¤t_objfile
->type_obstack
);
1384 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1388 /* Parse all the type qualifiers now. If there are more
1389 than 6 the game will continue in the next aux */
1391 #define PARSE_TQ(tq) \
1392 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend);
1394 again
:PARSE_TQ (tq0
);
1405 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1411 /* Make up a complex type from a basic one. Type is passed by
1412 reference in TPP and side-effected as necessary. The type
1413 qualifier TQ says how to handle the aux symbols at AX for
1414 the symbol SX we are currently analyzing. BIGEND says whether
1415 aux symbols are big-endian or little-endian.
1416 Returns the number of aux symbols we parsed. */
1419 upgrade_type (tpp
, tq
, ax
, bigend
)
1428 /* Used in array processing */
1439 t
= lookup_pointer_type (*tpp
);
1444 t
= lookup_function_type (*tpp
);
1451 /* Determine and record the domain type (type of index) */
1452 ecoff_swap_rndx_in (bigend
, &ax
->a_rndx
, &rndx
);
1458 rf
= AUX_GET_ISYM (bigend
, ax
);
1461 fh
= get_rfd (cur_fd
, rf
);
1463 indx
= parse_type ((ecoff_data (cur_bfd
)->external_aux
1466 (int *) NULL
, bigend
);
1468 /* Get the bounds, and create the array type. */
1470 lower
= AUX_GET_DNLOW (bigend
, ax
);
1472 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1474 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1476 range
= create_range_type ((struct type
*) NULL
, indx
,
1479 t
= create_array_type ((struct type
*) NULL
, *tpp
, range
);
1481 /* Check whether supplied array element bit size matches
1482 the known size of the element type. If this complaint
1483 ends up not happening, we can remove this code. It's
1484 here because we aren't sure we understand this *&%&$
1486 id
= TYPE_LENGTH (TYPE_TARGET_TYPE (t
)) << 3; /* bitsize */
1489 /* Most likely an undefined type */
1491 TYPE_LENGTH (TYPE_TARGET_TYPE (t
)) = id
>> 3;
1494 complain (&array_bitsize_complaint
, rf
);
1500 /* Volatile -- currently ignored */
1504 /* Const -- currently ignored */
1508 complain (&unknown_type_qual_complaint
, tq
);
1514 /* Parse a procedure descriptor record PR. Note that the procedure is
1515 parsed _after_ the local symbols, now we just insert the extra
1516 information we need into a MIPS_EFI_SYMBOL_NAME symbol that has
1517 already been placed in the procedure's main block. Note also that
1518 images that have been partially stripped (ld -x) have been deprived
1519 of local symbols, and we have to cope with them here. FIRST_OFF is
1520 the offset of the first procedure for this FDR; we adjust the
1521 address by this amount, but I don't know why.
1523 EFI_SYMBOL is the MIPS_EFI_SYMBOL_NAME symbol to use, or NULL which
1524 means to look up the name using the block in top_stack. */
1526 static void parse_procedure
PARAMS ((PDR
*, struct symbol
*, unsigned long));
1529 parse_procedure (pr
, efi_symbol
, first_off
)
1531 struct symbol
*efi_symbol
;
1532 unsigned long first_off
;
1536 struct mips_extra_func_info
*e
;
1539 /* Simple rule to find files linked "-x" */
1540 if (cur_fdr
->rss
== -1)
1544 /* Static procedure at address pr->adr. Sigh. */
1545 complain (&pdr_static_symbol_complaint
, pr
->adr
);
1553 ecoff_swap_ext_in (cur_bfd
,
1554 ecoff_data (cur_bfd
)->external_ext
+ pr
->isym
,
1556 sh_name
= ecoff_data (cur_bfd
)->ssext
+ she
.asym
.iss
;
1564 ecoff_swap_sym_in (cur_bfd
,
1565 (ecoff_data (cur_bfd
)->external_sym
1569 sh_name
= ecoff_data (cur_bfd
)->ss
+ cur_fdr
->issBase
+ sh
.iss
;
1572 if (efi_symbol
== NULL
)
1574 /* OK, first find the function. */
1576 s
= mylookup_symbol (sh_name
, top_stack
->cur_block
,
1577 VAR_NAMESPACE
, LOC_BLOCK
);
1581 b
= SYMBOL_BLOCK_VALUE (s
);
1585 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1589 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1590 s
= new_symbol (sh_name
);
1591 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1592 SYMBOL_CLASS (s
) = LOC_BLOCK
;
1593 /* Donno its type, hope int is ok */
1594 SYMBOL_TYPE (s
) = lookup_function_type (builtin_type_int
);
1595 add_symbol (s
, top_stack
->cur_block
);
1596 /* Wont have symbols for this one */
1598 SYMBOL_BLOCK_VALUE (s
) = b
;
1599 BLOCK_FUNCTION (b
) = s
;
1600 BLOCK_START (b
) = pr
->adr
;
1601 /* BOUND used to be the end of procedure's text, but the
1602 argument is no longer passed in. */
1603 BLOCK_END (b
) = bound
;
1604 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1605 add_block (b
, top_stack
->cur_st
);
1609 efi_symbol
= mylookup_symbol
1610 (MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
, LOC_CONST
);
1615 e
= (struct mips_extra_func_info
*) SYMBOL_VALUE (efi_symbol
);
1617 e
->pdr
.isym
= (long) s
;
1618 e
->pdr
.adr
+= cur_fdr
->adr
- first_off
;
1620 /* Correct incorrect setjmp procedure descriptor from the library
1621 to make backtrace through setjmp work. */
1622 if (e
->pdr
.pcreg
== 0 && strcmp (sh_name
, "setjmp") == 0)
1624 complain (&bad_setjmp_pdr_complaint
, 0);
1625 e
->pdr
.pcreg
= RA_REGNUM
;
1626 e
->pdr
.regmask
= 0x80000000;
1627 e
->pdr
.regoffset
= -4;
1632 /* Parse the external symbol ES. Just call parse_symbol() after
1633 making sure we know where the aux are for it. For procedures,
1634 parsing of the PDRs has already provided all the needed
1635 information, we only parse them if SKIP_PROCEDURES is false,
1636 and only if this causes no symbol duplication.
1637 BIGEND says whether aux entries are big-endian or little-endian.
1639 This routine clobbers top_stack->cur_block and ->cur_st. */
1642 parse_external (es
, skip_procedures
, bigend
)
1644 int skip_procedures
;
1649 if (es
->ifd
!= ifdNil
)
1652 cur_fdr
= ecoff_data (cur_bfd
)->fdr
+ cur_fd
;
1653 ax
= ecoff_data (cur_bfd
)->external_aux
+ cur_fdr
->iauxBase
;
1657 cur_fdr
= ecoff_data (cur_bfd
)->fdr
;
1661 /* Reading .o files */
1662 if (es
->asym
.sc
== scUndefined
|| es
->asym
.sc
== scNil
)
1665 switch (es
->asym
.st
)
1685 /* FIXME: Turn this into a complaint? */
1687 printf_filtered ("Warning: %s `%s' is undefined (in %s)\n",
1689 ecoff_data (cur_bfd
)->ssext
+ es
->asym
.iss
,
1690 fdr_name (cur_fdr
));
1694 switch (es
->asym
.st
)
1697 /* If we have full symbols we do not need more */
1698 if (skip_procedures
)
1700 if (mylookup_symbol (ecoff_data (cur_bfd
)->ssext
+ es
->asym
.iss
,
1701 top_stack
->cur_block
,
1702 VAR_NAMESPACE
, LOC_BLOCK
))
1707 /* Note that the case of a symbol with indexNil must be handled
1708 anyways by parse_symbol(). */
1709 parse_symbol (&es
->asym
, ax
, (struct sym_ext
*) NULL
, bigend
);
1710 /* Note that parse_symbol changed es->asym. */
1717 /* Parse the line number info for file descriptor FH into
1718 GDB's linetable LT. MIPS' encoding requires a little bit
1719 of magic to get things out. Note also that MIPS' line
1720 numbers can go back and forth, apparently we can live
1721 with that and do not need to reorder our linetables */
1724 parse_lines (fh
, pr
, lt
)
1727 struct linetable
*lt
;
1729 unsigned char *base
;
1731 int delta
, count
, lineno
= 0;
1732 unsigned long first_off
= pr
->adr
;
1734 if (fh
->cbLineOffset
== 0)
1737 base
= ecoff_data (cur_bfd
)->line
+ fh
->cbLineOffset
;
1739 /* Scan by procedure descriptors */
1741 for (j
= 0; j
< fh
->cpd
; j
++, pr
++)
1746 /* No code for this one */
1747 if (pr
->iline
== ilineNil
||
1748 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
1751 /* Aurgh! To know where to stop expanding we must look-ahead. */
1752 for (l
= 1; l
< (fh
->cpd
- j
); l
++)
1753 if (pr
[l
].iline
!= -1)
1755 if (l
== (fh
->cpd
- j
))
1760 /* When procedures are moved around the linenumbers are
1761 attributed to the next procedure up. */
1762 if (pr
->iline
>= halt
)
1765 base
= ecoff_data (cur_bfd
)->line
+ fh
->cbLineOffset
+ pr
->cbLineOffset
;
1766 adr
= fh
->adr
+ pr
->adr
- first_off
;
1767 l
= adr
>> 2; /* in words */
1768 halt
+= (adr
>> 2) - pr
->iline
;
1769 for (lineno
= pr
->lnLow
; l
< halt
;)
1771 count
= *base
& 0x0f;
1772 delta
= *base
++ >> 4;
1777 delta
= (base
[0] << 8) | base
[1];
1778 if (delta
>= 0x8000)
1782 lineno
+= delta
; /* first delta is 0 */
1783 k
= add_line (lt
, lineno
, l
, k
);
1789 /* Master parsing procedure for first-pass reading of file symbols
1790 into a partial_symtab. */
1793 parse_partial_symbols (objfile
, section_offsets
)
1794 struct objfile
*objfile
;
1795 struct section_offsets
*section_offsets
;
1798 HDRR
*hdr
= &ecoff_data (cur_bfd
)->symbolic_header
;
1799 /* Running pointers */
1801 struct ext_ext
*ext_out
;
1802 struct ext_ext
*ext_out_end
;
1804 register EXTR
*ext_in
;
1807 struct partial_symtab
*pst
;
1809 int past_first_source_file
= 0;
1811 /* List of current psymtab's include files */
1812 char **psymtab_include_list
;
1813 int includes_allocated
;
1816 struct pst_map
*fdr_to_pst
;
1817 /* Index within current psymtab dependency list */
1818 struct partial_symtab
**dependency_list
;
1819 int dependencies_used
, dependencies_allocated
;
1820 struct cleanup
*old_chain
;
1823 extern_tab
= (EXTR
*) obstack_alloc (&objfile
->psymbol_obstack
,
1824 sizeof (EXTR
) * hdr
->iextMax
);
1826 includes_allocated
= 30;
1828 psymtab_include_list
= (char **) alloca (includes_allocated
*
1830 next_symbol_text_func
= mips_next_symbol_text
;
1832 dependencies_allocated
= 30;
1833 dependencies_used
= 0;
1835 (struct partial_symtab
**) alloca (dependencies_allocated
*
1836 sizeof (struct partial_symtab
*));
1838 last_source_file
= NULL
;
1843 * Only parse the Local and External symbols, and the Relative FDR.
1844 * Fixup enough of the loader symtab to be able to use it.
1845 * Allocate space only for the file's portions we need to
1850 max_glevel
= MIN_GLEVEL
;
1852 /* Allocate the map FDR -> PST.
1853 Minor hack: -O3 images might claim some global data belongs
1854 to FDR -1. We`ll go along with that */
1855 fdr_to_pst
= (struct pst_map
*) xzalloc ((hdr
->ifdMax
+ 1) * sizeof *fdr_to_pst
);
1856 old_chain
= make_cleanup (free
, fdr_to_pst
);
1859 struct partial_symtab
*pst
= new_psymtab ("", objfile
);
1860 fdr_to_pst
[-1].pst
= pst
;
1864 /* Pass 0 over external syms: swap them in. */
1865 ext_block
= (EXTR
*) xmalloc (hdr
->iextMax
* sizeof (EXTR
));
1866 make_cleanup (free
, ext_block
);
1868 ext_out
= ecoff_data (cur_bfd
)->external_ext
;
1869 ext_out_end
= ext_out
+ hdr
->iextMax
;
1871 for (; ext_out
< ext_out_end
; ext_out
++, ext_in
++)
1872 ecoff_swap_ext_in (cur_bfd
, ext_out
, ext_in
);
1874 /* Pass 1 over external syms: Presize and partition the list */
1876 ext_in_end
= ext_in
+ hdr
->iextMax
;
1877 for (; ext_in
< ext_in_end
; ext_in
++)
1878 fdr_to_pst
[ext_in
->ifd
].n_globals
++;
1880 /* Pass 1.5 over files: partition out global symbol space */
1882 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++)
1884 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
1885 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
1886 fdr_to_pst
[f_idx
].n_globals
= 0;
1889 /* Pass 2 over external syms: fill in external symbols */
1891 ext_in_end
= ext_in
+ hdr
->iextMax
;
1892 for (; ext_in
< ext_in_end
; ext_in
++)
1894 enum minimal_symbol_type ms_type
= mst_text
;
1896 extern_tab
[fdr_to_pst
[ext_in
->ifd
].globals_offset
1897 + fdr_to_pst
[ext_in
->ifd
].n_globals
++] = *ext_in
;
1899 if (ext_in
->asym
.sc
== scUndefined
|| ext_in
->asym
.sc
== scNil
)
1902 name
= ecoff_data (cur_bfd
)->ssext
+ ext_in
->asym
.iss
;
1903 switch (ext_in
->asym
.st
)
1913 ms_type
= mst_unknown
;
1914 complain (&unknown_ext_complaint
, name
);
1916 prim_record_minimal_symbol (name
, ext_in
->asym
.value
, ms_type
);
1919 /* Pass 3 over files, over local syms: fill in static symbols */
1920 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
1922 struct partial_symtab
*save_pst
;
1925 cur_fdr
= fh
= ecoff_data (cur_bfd
)->fdr
+ f_idx
;
1929 fdr_to_pst
[f_idx
].pst
= NULL
;
1932 pst
= start_psymtab_common (objfile
, section_offsets
,
1934 fh
->cpd
? fh
->adr
: 0,
1935 objfile
->global_psymbols
.next
,
1936 objfile
->static_psymbols
.next
);
1937 pst
->read_symtab_private
= ((char *)
1938 obstack_alloc (&objfile
->psymbol_obstack
,
1939 sizeof (struct symloc
)));
1940 memset ((PTR
) pst
->read_symtab_private
, 0, sizeof (struct symloc
));
1943 /* Make everything point to everything. */
1944 FDR_IDX (pst
) = f_idx
;
1945 fdr_to_pst
[f_idx
].pst
= pst
;
1947 /* FIXME: This tampers with data from BFD. */
1948 fh
->ioptBase
= (int) pst
;
1950 CUR_BFD (pst
) = cur_bfd
;
1952 /* The way to turn this into a symtab is to call... */
1953 pst
->read_symtab
= mipscoff_psymtab_to_symtab
;
1955 pst
->texthigh
= pst
->textlow
;
1957 /* For stabs-in-ecoff files, the second symbol must be @stab.
1958 This symbol is emitted by mips-tfile to signal that the
1959 current object file uses encapsulated stabs instead of mips
1960 ecoff for local symbols. (It is the second symbol because
1961 the first symbol is the stFile used to signal the start of a
1963 processing_gcc_compilation
= 0;
1966 ecoff_swap_sym_in (cur_bfd
,
1967 (ecoff_data (cur_bfd
)->external_sym
1971 if (STREQ (ecoff_data (cur_bfd
)->ss
+ fh
->issBase
+ sh
.iss
,
1973 processing_gcc_compilation
= 2;
1976 if (processing_gcc_compilation
!= 0)
1978 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
1983 ecoff_swap_sym_in (cur_bfd
,
1984 (ecoff_data (cur_bfd
)->external_sym
1988 type_code
= MIPS_UNMARK_STAB (sh
.index
);
1989 if (!MIPS_IS_STAB (&sh
))
1991 if (sh
.st
== stProc
|| sh
.st
== stStaticProc
)
1993 long procaddr
= sh
.value
;
1997 isym
= AUX_GET_ISYM (fh
->fBigendian
,
1998 (ecoff_data (cur_bfd
)->external_aux
2001 ecoff_swap_sym_in (cur_bfd
,
2002 (ecoff_data (cur_bfd
)->external_sym
2009 long high
= procaddr
+ sh
.value
;
2010 if (high
> pst
->texthigh
)
2011 pst
->texthigh
= high
;
2016 #define SET_NAMESTRING() \
2017 namestring = ecoff_data (cur_bfd)->ss + fh->issBase + sh.iss
2018 #define CUR_SYMBOL_TYPE type_code
2019 #define CUR_SYMBOL_VALUE sh.value
2020 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
2022 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
2023 #define HANDLE_RBRAC(val) \
2024 if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
2025 #include "partial-stab.h"
2030 for (cur_sdx
= 0; cur_sdx
< fh
->csym
;)
2033 enum address_class
class;
2035 ecoff_swap_sym_in (cur_bfd
,
2036 (ecoff_data (cur_bfd
)->external_sym
2041 if (MIPS_IS_STAB (&sh
))
2047 if (sh
.sc
== scUndefined
|| sh
.sc
== scNil
||
2048 sh
.index
== 0xfffff)
2050 /* FIXME, premature? */
2055 name
= ecoff_data (cur_bfd
)->ss
+ fh
->issBase
+ sh
.iss
;
2063 case stProc
: /* Asm labels apparently */
2064 case stStaticProc
: /* Function */
2065 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2066 VAR_NAMESPACE
, LOC_BLOCK
,
2067 objfile
->static_psymbols
, sh
.value
,
2068 psymtab_language
, objfile
);
2069 /* Skip over procedure to next one. */
2070 if (sh
.index
>= hdr
->iauxMax
)
2072 /* Should not happen, but does when cross-compiling
2073 with the MIPS compiler. FIXME -- pull later. */
2074 complain (&index_complaint
, name
);
2075 new_sdx
= cur_sdx
+ 1; /* Don't skip at all */
2078 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2079 (ecoff_data (cur_bfd
)->external_aux
2082 procaddr
= sh
.value
;
2084 if (new_sdx
<= cur_sdx
)
2086 /* This should not happen either... FIXME. */
2087 complain (&aux_index_complaint
, name
);
2088 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2092 ecoff_swap_sym_in (cur_bfd
,
2093 (ecoff_data (cur_bfd
)->external_sym
2100 high
= procaddr
+ sh
.value
;
2101 if (high
> pst
->texthigh
)
2102 pst
->texthigh
= high
;
2105 case stStatic
: /* Variable */
2109 case stTypedef
:/* Typedef */
2110 class = LOC_TYPEDEF
;
2113 case stConstant
: /* Constant decl */
2120 case stBlock
: /* { }, str, un, enum*/
2121 if (sh
.sc
== scInfo
|| sh
.sc
== scCommon
)
2123 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2124 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2125 objfile
->static_psymbols
,
2127 psymtab_language
, objfile
);
2129 /* Skip over the block */
2131 if (new_sdx
<= cur_sdx
)
2133 /* This happens with the Ultrix kernel. */
2134 complain (&block_index_complaint
, name
);
2135 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2140 case stFile
: /* File headers */
2141 case stLabel
: /* Labels */
2142 case stEnd
: /* Ends of files */
2145 case stLocal
: /* Local variables */
2146 /* Normally these are skipped because we skip over
2147 all blocks we see. However, these can occur
2148 as visible symbols in a .h file that contains code. */
2152 /* Both complaints are valid: one gives symbol name,
2153 the other the offending symbol type. */
2154 complain (&unknown_sym_complaint
, name
);
2155 complain (&unknown_st_complaint
, sh
.st
);
2159 /* Use this gdb symbol */
2160 ADD_PSYMBOL_TO_LIST (name
, strlen (name
),
2161 VAR_NAMESPACE
, class,
2162 objfile
->static_psymbols
, sh
.value
,
2163 psymtab_language
, objfile
);
2165 cur_sdx
++; /* Go to next file symbol */
2168 /* Now do enter the external symbols. */
2169 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2170 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2171 PST_PRIVATE (save_pst
)->extern_count
= cur_sdx
;
2172 PST_PRIVATE (save_pst
)->extern_tab
= ext_ptr
;
2173 for (; --cur_sdx
>= 0; ext_ptr
++)
2175 register struct partial_symbol
*psym
;
2176 enum address_class
class;
2180 if (ext_ptr
->ifd
!= f_idx
)
2182 psh
= &ext_ptr
->asym
;
2192 complain (&unknown_ext_complaint
,
2193 ecoff_data (cur_bfd
)->ssext
+ psh
->iss
);
2194 /* Fall through, pretend it's global. */
2199 name
= ecoff_data (cur_bfd
)->ssext
+ psh
->iss
;
2200 ADD_PSYMBOL_ADDR_TO_LIST (name
, strlen (name
),
2201 VAR_NAMESPACE
, class,
2202 objfile
->global_psymbols
, (CORE_ADDR
) psh
->value
,
2203 psymtab_language
, objfile
);
2207 end_psymtab (save_pst
, psymtab_include_list
, includes_used
,
2208 -1, save_pst
->texthigh
,
2209 dependency_list
, dependencies_used
);
2210 if (objfile
->ei
.entry_point
>= save_pst
->textlow
&&
2211 objfile
->ei
.entry_point
< save_pst
->texthigh
)
2213 objfile
->ei
.entry_file_lowpc
= save_pst
->textlow
;
2214 objfile
->ei
.entry_file_highpc
= save_pst
->texthigh
;
2218 /* Now scan the FDRs for dependencies */
2219 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
2222 fh
= f_idx
+ ecoff_data (cur_bfd
)->fdr
;
2223 pst
= fdr_to_pst
[f_idx
].pst
;
2225 /* This should catch stabs-in-ecoff. */
2230 { /* If there are no functions defined here ... */
2231 /* ...then presumably a .h file: drop reverse depends .h->.c */
2232 for (; s_id0
< fh
->crfd
; s_id0
++)
2236 ecoff_swap_rfd_in (cur_bfd
,
2237 (ecoff_data (cur_bfd
)->external_rfd
2243 s_id0
++; /* Skip self-dependency */
2248 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2250 ((struct partial_symtab
**)
2251 obstack_alloc (&objfile
->psymbol_obstack
,
2252 (pst
->number_of_dependencies
2253 * sizeof (struct partial_symtab
*))));
2254 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++)
2258 ecoff_swap_rfd_in (cur_bfd
,
2259 (ecoff_data (cur_bfd
)->external_rfd
2263 if (rh
< 0 || rh
>= hdr
->ifdMax
)
2264 complain (&bad_file_number_complaint
, rh
);
2266 pst
->dependencies
[s_idx
- s_id0
] = fdr_to_pst
[rh
].pst
;
2269 do_cleanups (old_chain
);
2274 /* Do the initial analisys of the F_IDX-th file descriptor.
2275 Allocates a partial symtab for it, and builds the list
2276 of dependent files by recursion. LEV says at which level
2277 of recursion we are called (to pretty up debug traces) */
2279 static struct partial_symtab
*
2280 parse_fdr (f_idx
, lev
, objfile
)
2283 struct objfile
*objfile
;
2286 register struct partial_symtab
*pst
;
2289 fh
= ecoff_data (cur_bfd
)->fdr
+ f_idx
;
2291 /* Use this to indicate into which symtab this file was parsed */
2293 return (struct partial_symtab
*) fh
->ioptBase
;
2295 /* Debuggability level */
2296 if (compare_glevel (max_glevel
, fh
->glevel
) < 0)
2297 max_glevel
= fh
->glevel
;
2299 /* Make a new partial_symtab */
2300 pst
= new_psymtab (fdr_name (fh
), objfile
);
2308 pst
->textlow
= fh
->adr
;
2309 pst
->texthigh
= fh
->cpd
; /* To be fixed later */
2312 /* Make everything point to everything. */
2313 FDR_IDX (pst
) = f_idx
;
2314 fdr_to_pst
[f_idx
].pst
= pst
;
2315 fh
->ioptBase
= (int) pst
;
2317 /* Analyze its dependencies */
2323 { /* If there are no functions defined here ... */
2324 /* ...then presumably a .h file: drop reverse depends .h->.c */
2325 for (; s_id0
< fh
->crfd
; s_id0
++)
2329 ecoff_swap_rfd_in (cur_bfd
,
2330 (ecoff_data (cur_bfd
)->external_rfd
2336 s_id0
++; /* Skip self-dependency */
2341 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2342 pst
->dependencies
= ((struct partial_symtab
**)
2343 obstack_alloc (&objfile
->psymbol_obstack
,
2344 (pst
->number_of_dependencies
2345 * sizeof (struct partial_symtab
*))));
2346 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++)
2350 ecoff_swap_rfd_in (cur_bfd
,
2351 (ecoff_data (cur_bfd
)->external_rfd
2355 pst
->dependencies
[s_idx
- s_id0
] = parse_fdr (rh
, lev
+ 1, objfile
);
2364 mips_next_symbol_text ()
2369 ecoff_swap_sym_in (cur_bfd
,
2370 (ecoff_data (cur_bfd
)->external_sym
2374 return ecoff_data (cur_bfd
)->ss
+ cur_fdr
->issBase
+ sh
.iss
;
2377 /* Ancillary function to psymtab_to_symtab(). Does all the work
2378 for turning the partial symtab PST into a symtab, recurring
2379 first on all dependent psymtabs. The argument FILENAME is
2380 only passed so we can see in debug stack traces what file
2383 This function has a split personality, based on whether the
2384 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
2385 The flow of control and even the memory allocation differs. FIXME. */
2388 psymtab_to_symtab_1 (pst
, filename
)
2389 struct partial_symtab
*pst
;
2395 struct linetable
*lines
;
2401 /* Read in all partial symbtabs on which this one is dependent.
2402 NOTE that we do have circular dependencies, sigh. We solved
2403 that by setting pst->readin before this point. */
2405 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
2406 if (!pst
->dependencies
[i
]->readin
)
2408 /* Inform about additional files to be read in. */
2411 fputs_filtered (" ", stdout
);
2413 fputs_filtered ("and ", stdout
);
2415 printf_filtered ("%s...",
2416 pst
->dependencies
[i
]->filename
);
2417 wrap_here (""); /* Flush output */
2420 /* We only pass the filename for debug purposes */
2421 psymtab_to_symtab_1 (pst
->dependencies
[i
],
2422 pst
->dependencies
[i
]->filename
);
2425 /* Do nothing if this is a dummy psymtab. */
2427 if (pst
->n_global_syms
== 0 && pst
->n_static_syms
== 0
2428 && pst
->textlow
== 0 && pst
->texthigh
== 0)
2431 /* Now read the symbols for this symtab */
2433 cur_bfd
= CUR_BFD (pst
);
2434 current_objfile
= pst
->objfile
;
2435 cur_fd
= FDR_IDX (pst
);
2436 fh
= (cur_fd
== -1) ? (FDR
*) NULL
: ecoff_data (cur_bfd
)->fdr
+ cur_fd
;
2439 /* See comment in parse_partial_symbols about the @stabs sentinel. */
2440 processing_gcc_compilation
= 0;
2441 if (fh
!= (FDR
*) NULL
&& fh
->csym
>= 2)
2445 ecoff_swap_sym_in (cur_bfd
,
2446 (ecoff_data (cur_bfd
)->external_sym
2450 if (STREQ (ecoff_data (cur_bfd
)->ss
+ fh
->issBase
+ sh
.iss
,
2453 /* We indicate that this is a GCC compilation so that certain
2454 features will be enabled in stabsread/dbxread. */
2455 processing_gcc_compilation
= 2;
2459 if (processing_gcc_compilation
!= 0)
2461 /* This symbol table contains stabs-in-ecoff entries. */
2463 struct pdr_ext
*pdr_ptr
;
2464 struct pdr_ext
*pdr_end
;
2466 unsigned long first_off
;
2467 struct cleanup
*old_cleanups
;
2469 /* Given a symbol index in the symbol file, find the
2470 MIPS_EFI_SYMBOL_NAME symbol which goes with it. If this is taking
2471 up too much memory, we could get fancy with hash tables or some
2473 struct symbol
**mips_func_info_by_isym
;
2475 mips_func_info_by_isym
= (struct symbol
**)
2476 xmalloc (fh
->csym
* sizeof (*mips_func_info_by_isym
));
2477 old_cleanups
= make_cleanup (free
, mips_func_info_by_isym
);
2479 /* Parse local symbols first */
2481 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
2483 current_objfile
= NULL
;
2486 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
2492 ecoff_swap_sym_in (cur_bfd
,
2493 (ecoff_data (cur_bfd
)->external_sym
2497 name
= ecoff_data (cur_bfd
)->ss
+ fh
->issBase
+ sh
.iss
;
2499 if (MIPS_IS_STAB (&sh
))
2501 int type_code
= MIPS_UNMARK_STAB (sh
.index
);
2502 process_one_symbol (type_code
, 0, valu
, name
,
2503 pst
->section_offsets
, pst
->objfile
);
2504 if (type_code
== N_FUN
)
2506 /* Make up special symbol to contain
2507 procedure specific info */
2508 struct mips_extra_func_info
*e
=
2509 ((struct mips_extra_func_info
*)
2510 obstack_alloc (¤t_objfile
->symbol_obstack
,
2511 sizeof (struct mips_extra_func_info
)));
2512 struct symbol
*s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
2513 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
2514 SYMBOL_CLASS (s
) = LOC_CONST
;
2515 SYMBOL_TYPE (s
) = builtin_type_void
;
2516 SYMBOL_VALUE (s
) = (int) e
;
2517 add_symbol_to_list (s
, &local_symbols
);
2518 mips_func_info_by_isym
[cur_sdx
] = s
;
2521 else if (sh
.st
== stLabel
&& sh
.index
!= indexNil
)
2523 /* Handle encoded stab line number. */
2524 record_line (current_subfile
, sh
.index
, valu
);
2526 else if (sh
.st
== stProc
|| sh
.st
== stStaticProc
|| sh
.st
== stEnd
)
2527 /* These are generated by gcc-2.x, do not complain */
2530 complain (&stab_unknown_complaint
, name
);
2532 st
= end_symtab (pst
->texthigh
, 0, 0, pst
->objfile
, SECT_OFF_TEXT
);
2535 /* Sort the symbol table now, we are done adding symbols to it.
2536 We must do this before parse_procedure calls lookup_symbol. */
2537 sort_symtab_syms (st
);
2539 /* This may not be necessary for stabs symtabs. FIXME. */
2542 /* Fill in procedure info next. */
2544 pdr_ptr
= ecoff_data (cur_bfd
)->external_pdr
+ fh
->ipdFirst
;
2545 pdr_end
= pdr_ptr
+ fh
->cpd
;
2546 for (; pdr_ptr
< pdr_end
; pdr_ptr
++)
2550 ecoff_swap_pdr_in (cur_bfd
, pdr_ptr
, &pr
);
2556 parse_procedure (&pr
, mips_func_info_by_isym
[pr
.isym
], first_off
);
2559 do_cleanups (old_cleanups
);
2563 /* This symbol table contains ordinary ecoff entries. */
2565 /* FIXME: doesn't use pst->section_offsets. */
2571 /* How many symbols will we need */
2572 /* FIXME, this does not count enum values. */
2573 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
2577 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
2581 f_max
+= fh
->csym
+ fh
->cpd
;
2582 maxlines
= 2 * fh
->cline
;
2583 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
2586 lines
= LINETABLE (st
);
2587 pending_list
= PST_PRIVATE (pst
)->pending_list
;
2588 if (pending_list
== 0)
2590 pending_list
= ((struct mips_pending
**)
2591 xzalloc (ecoff_data (cur_bfd
)->symbolic_header
.ifdMax
2592 * sizeof (struct mips_pending
*)));
2593 PST_PRIVATE (pst
)->pending_list
= pending_list
;
2596 /* Get a new lexical context */
2598 push_parse_stack ();
2599 top_stack
->cur_st
= st
;
2600 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (st
),
2602 BLOCK_START (top_stack
->cur_block
) = fh
? fh
->adr
: 0;
2603 BLOCK_END (top_stack
->cur_block
) = 0;
2604 top_stack
->blocktype
= stFile
;
2605 top_stack
->maxsyms
= 2 * f_max
;
2606 top_stack
->cur_type
= 0;
2607 top_stack
->procadr
= 0;
2608 top_stack
->numargs
= 0;
2612 struct sym_ext
*sym_ptr
;
2613 struct sym_ext
*sym_end
;
2615 /* Parse local symbols first */
2616 sym_ptr
= ecoff_data (cur_bfd
)->external_sym
+ fh
->isymBase
;
2617 sym_end
= sym_ptr
+ fh
->csym
;
2618 while (sym_ptr
< sym_end
)
2623 ecoff_swap_sym_in (cur_bfd
, sym_ptr
, &sh
);
2624 c
= parse_symbol (&sh
,
2625 (ecoff_data (cur_bfd
)->external_aux
2627 sym_ptr
, fh
->fBigendian
);
2628 /* FIXME: We must swap the modified symbol back out,
2629 although we would rather not. See parse_symbol. */
2630 ecoff_swap_sym_out (cur_bfd
, &sh
, sym_ptr
);
2634 /* Linenumbers. At the end, check if we can save memory.
2635 parse_lines has to look ahead an arbitrary number of PDR
2636 structures, so we swap them all first. */
2640 struct cleanup
*old_chain
;
2641 struct pdr_ext
*pdr_ptr
;
2642 struct pdr_ext
*pdr_end
;
2646 pr_block
= (PDR
*) xmalloc (fh
->cpd
* sizeof (PDR
));
2648 old_chain
= make_cleanup (free
, pr_block
);
2650 pdr_ptr
= ecoff_data (cur_bfd
)->external_pdr
+ fh
->ipdFirst
;
2651 pdr_end
= pdr_ptr
+ fh
->cpd
;
2653 for (; pdr_ptr
< pdr_end
; pdr_ptr
++, pdr_in
++)
2654 ecoff_swap_pdr_in (cur_bfd
, pdr_ptr
, pdr_in
);
2656 parse_lines (fh
, pr_block
, lines
);
2657 if (lines
->nitems
< fh
->cline
)
2658 lines
= shrink_linetable (lines
);
2660 /* Fill in procedure info next. */
2662 pdr_in_end
= pdr_in
+ fh
->cpd
;
2663 for (; pdr_in
< pdr_in_end
; pdr_in
++)
2664 parse_procedure (pdr_in
, 0, pr_block
->adr
);
2666 do_cleanups (old_chain
);
2670 LINETABLE (st
) = lines
;
2672 /* .. and our share of externals.
2673 XXX use the global list to speed up things here. how?
2674 FIXME, Maybe quit once we have found the right number of ext's? */
2675 top_stack
->cur_st
= st
;
2676 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
2678 top_stack
->blocktype
= stFile
;
2679 top_stack
->maxsyms
= (ecoff_data (cur_bfd
)->symbolic_header
.isymMax
2680 + ecoff_data (cur_bfd
)->symbolic_header
.ipdMax
2681 + ecoff_data (cur_bfd
)->symbolic_header
.iextMax
);
2683 ext_ptr
= PST_PRIVATE (pst
)->extern_tab
;
2684 for (i
= PST_PRIVATE (pst
)->extern_count
; --i
>= 0; ext_ptr
++)
2685 parse_external (ext_ptr
, 1, fh
->fBigendian
);
2687 /* If there are undefined, tell the user */
2688 if (n_undef_symbols
)
2690 printf_filtered ("File %s contains %d unresolved references:",
2691 st
->filename
, n_undef_symbols
);
2692 printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
2693 n_undef_vars
, n_undef_procs
, n_undef_labels
);
2694 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
2699 /* Sort the symbol table now, we are done adding symbols to it.*/
2700 sort_symtab_syms (st
);
2705 /* Now link the psymtab and the symtab. */
2708 current_objfile
= NULL
;
2711 /* Ancillary parsing procedures. */
2713 /* Lookup the type at relative index RN. Return it in TPP
2714 if found and in any event come up with its name PNAME.
2715 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
2716 Return value says how many aux symbols we ate. */
2719 cross_ref (ax
, tpp
, type_code
, pname
, bigend
)
2722 enum type_code type_code
; /* Use to alloc new type if none is found. */
2730 ecoff_swap_rndx_in (bigend
, &ax
->a_rndx
, rn
);
2732 /* Escape index means 'the next one' */
2733 if (rn
->rfd
== 0xfff)
2736 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
2746 *pname
= "<undefined>";
2751 * Find the relative file descriptor and the symbol in it
2753 FDR
*fh
= get_rfd (cur_fd
, rf
);
2754 struct sym_ext
*esh
;
2758 /* If we have processed this symbol then we left a forwarding
2759 pointer to the corresponding GDB symbol. If not, we`ll put
2760 it in a list of pending symbols, to be processed later when
2761 the file will be. In any event, we collect the name for the
2762 type here. Which is why we made a first pass at strings. */
2764 esh
= ecoff_data (cur_bfd
)->external_sym
+ fh
->isymBase
+ rn
->index
;
2765 ecoff_swap_sym_in (cur_bfd
, esh
, &sh
);
2767 /* Careful, we might be looking at .o files */
2769 *pname
= "<undefined>";
2770 else if (rn
->rfd
== 0xfff && rn
->index
== 0)
2771 /* For structs, unions and enums, rn->rfd is 0xfff and the index
2772 is a relative symbol number for the type, but an index of 0
2773 seems to mean that we don't know. This is said to fix a problem
2774 with "info func opendir" on an SGI showing
2775 "struct BSDopendir.c *BSDopendir();". */
2776 *pname
= "<unknown>";
2778 *pname
= ecoff_data (cur_bfd
)->ss
+ fh
->issBase
+ sh
.iss
;
2780 /* Have we parsed it ? */
2781 if (sh
.value
!= 0 && sh
.st
== stParsed
)
2783 t
= (struct type
*) sh
.value
;
2788 /* Avoid duplicates */
2789 struct mips_pending
*p
= is_pending_symbol (fh
, esh
);
2794 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
,
2795 (struct objfile
*) NULL
);
2796 add_pending (fh
, esh
, *tpp
);
2801 /* We used one auxent normally, two if we got a "next one" rf. */
2806 /* Quick&dirty lookup procedure, to avoid the MI ones that require
2807 keeping the symtab sorted */
2809 static struct symbol
*
2810 mylookup_symbol (name
, block
, namespace, class)
2812 register struct block
*block
;
2813 enum namespace namespace;
2814 enum address_class
class;
2816 register int bot
, top
, inc
;
2817 register struct symbol
*sym
;
2820 top
= BLOCK_NSYMS (block
);
2824 sym
= BLOCK_SYM (block
, bot
);
2825 if (SYMBOL_NAME (sym
)[0] == inc
2826 && SYMBOL_NAMESPACE (sym
) == namespace
2827 && SYMBOL_CLASS (sym
) == class
2828 && strcmp (SYMBOL_NAME (sym
), name
) == 0)
2832 block
= BLOCK_SUPERBLOCK (block
);
2834 return mylookup_symbol (name
, block
, namespace, class);
2839 /* Add a new symbol S to a block B.
2840 Infrequently, we will need to reallocate the block to make it bigger.
2841 We only detect this case when adding to top_stack->cur_block, since
2842 that's the only time we know how big the block is. FIXME. */
2849 int nsyms
= BLOCK_NSYMS (b
)++;
2850 struct block
*origb
;
2851 struct parse_stack
*stackp
;
2853 if (b
== top_stack
->cur_block
&&
2854 nsyms
>= top_stack
->maxsyms
)
2856 complain (&block_overflow_complaint
, SYMBOL_NAME (s
));
2857 /* In this case shrink_block is actually grow_block, since
2858 BLOCK_NSYMS(b) is larger than its current size. */
2860 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
2862 /* Now run through the stack replacing pointers to the
2863 original block. shrink_block has already done this
2864 for the blockvector and BLOCK_FUNCTION. */
2865 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
)
2867 if (stackp
->cur_block
== origb
)
2869 stackp
->cur_block
= b
;
2870 stackp
->maxsyms
= BLOCK_NSYMS (b
);
2874 BLOCK_SYM (b
, nsyms
) = s
;
2877 /* Add a new block B to a symtab S */
2884 struct blockvector
*bv
= BLOCKVECTOR (s
);
2886 bv
= (struct blockvector
*) xrealloc ((PTR
) bv
,
2887 (sizeof (struct blockvector
)
2888 + BLOCKVECTOR_NBLOCKS (bv
)
2889 * sizeof (bv
->block
)));
2890 if (bv
!= BLOCKVECTOR (s
))
2891 BLOCKVECTOR (s
) = bv
;
2893 BLOCKVECTOR_BLOCK (bv
, BLOCKVECTOR_NBLOCKS (bv
)++) = b
;
2896 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
2897 MIPS' linenumber encoding might need more than one byte
2898 to describe it, LAST is used to detect these continuation lines.
2900 Combining lines with the same line number seems like a bad idea.
2901 E.g: There could be a line number entry with the same line number after the
2902 prologue and GDB should not ignore it (this is a better way to find
2903 a prologue than mips_skip_prologue).
2904 But due to the compressed line table format there are line number entries
2905 for the same line which are needed to bridge the gap to the next
2906 line number entry. These entries have a bogus address info with them
2907 and we are unable to tell them from intended duplicate line number
2909 This is another reason why -ggdb debugging format is preferable. */
2912 add_line (lt
, lineno
, adr
, last
)
2913 struct linetable
*lt
;
2919 last
= -2; /* make sure we record first line */
2921 if (last
== lineno
) /* skip continuation lines */
2924 lt
->item
[lt
->nitems
].line
= lineno
;
2925 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
2929 /* Sorting and reordering procedures */
2931 /* Blocks with a smaller low bound should come first */
2934 compare_blocks (arg1
, arg2
)
2935 const void *arg1
, *arg2
;
2937 register int addr_diff
;
2938 struct block
**b1
= (struct block
**) arg1
;
2939 struct block
**b2
= (struct block
**) arg2
;
2941 addr_diff
= (BLOCK_START ((*b1
))) - (BLOCK_START ((*b2
)));
2943 return (BLOCK_END ((*b2
))) - (BLOCK_END ((*b1
)));
2947 /* Sort the blocks of a symtab S.
2948 Reorder the blocks in the blockvector by code-address,
2949 as required by some MI search routines */
2955 struct blockvector
*bv
= BLOCKVECTOR (s
);
2957 if (BLOCKVECTOR_NBLOCKS (bv
) <= 2)
2960 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) == 0)
2961 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = 0;
2962 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) == 0)
2963 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) = 0;
2967 * This is very unfortunate: normally all functions are compiled in
2968 * the order they are found, but if the file is compiled -O3 things
2969 * are very different. It would be nice to find a reliable test
2970 * to detect -O3 images in advance.
2972 if (BLOCKVECTOR_NBLOCKS (bv
) > 3)
2973 qsort (&BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
),
2974 BLOCKVECTOR_NBLOCKS (bv
) - FIRST_LOCAL_BLOCK
,
2975 sizeof (struct block
*),
2979 register CORE_ADDR high
= 0;
2980 register int i
, j
= BLOCKVECTOR_NBLOCKS (bv
);
2982 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
2983 if (high
< BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
)))
2984 high
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
));
2985 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = high
;
2988 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) =
2989 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
));
2991 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
2992 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
2993 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
2994 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
2998 /* Constructor/restructor/destructor procedures */
3000 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
3001 MAXSYMS and linenumbers MAXLINES we'll put in it */
3003 static struct symtab
*
3004 new_symtab (name
, maxsyms
, maxlines
, objfile
)
3008 struct objfile
*objfile
;
3010 struct symtab
*s
= allocate_symtab (name
, objfile
);
3012 LINETABLE (s
) = new_linetable (maxlines
);
3014 /* All symtabs must have at least two blocks */
3015 BLOCKVECTOR (s
) = new_bvect (2);
3016 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
) = new_block (maxsyms
);
3017 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
) = new_block (maxsyms
);
3018 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
)) =
3019 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
);
3021 s
->free_code
= free_linetable
;
3026 /* Allocate a new partial_symtab NAME */
3028 static struct partial_symtab
*
3029 new_psymtab (name
, objfile
)
3031 struct objfile
*objfile
;
3033 struct partial_symtab
*psymtab
;
3035 psymtab
= allocate_psymtab (name
, objfile
);
3037 /* Keep a backpointer to the file's symbols */
3039 psymtab
->read_symtab_private
= ((char *)
3040 obstack_alloc (&objfile
->psymbol_obstack
,
3041 sizeof (struct symloc
)));
3042 memset ((PTR
) psymtab
->read_symtab_private
, 0, sizeof (struct symloc
));
3043 CUR_BFD (psymtab
) = cur_bfd
;
3045 /* The way to turn this into a symtab is to call... */
3046 psymtab
->read_symtab
= mipscoff_psymtab_to_symtab
;
3051 /* Allocate a linetable array of the given SIZE. Since the struct
3052 already includes one item, we subtract one when calculating the
3053 proper size to allocate. */
3055 static struct linetable
*
3056 new_linetable (size
)
3059 struct linetable
*l
;
3061 size
= (size
- 1) * sizeof (l
->item
) + sizeof (struct linetable
);
3062 l
= (struct linetable
*) xmalloc (size
);
3067 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
3068 I am not so sure about the 3.4 ones.
3070 Since the struct linetable already includes one item, we subtract one when
3071 calculating the proper size to allocate. */
3073 static struct linetable
*
3074 shrink_linetable (lt
)
3075 struct linetable
*lt
;
3078 return (struct linetable
*) xrealloc ((PTR
) lt
,
3079 (sizeof (struct linetable
)
3081 * sizeof (lt
->item
))));
3084 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
3086 static struct blockvector
*
3090 struct blockvector
*bv
;
3093 size
= sizeof (struct blockvector
) + nblocks
* sizeof (struct block
*);
3094 bv
= (struct blockvector
*) xzalloc (size
);
3096 BLOCKVECTOR_NBLOCKS (bv
) = nblocks
;
3101 /* Allocate and zero a new block of MAXSYMS symbols */
3103 static struct block
*
3107 int size
= sizeof (struct block
) + (maxsyms
- 1) * sizeof (struct symbol
*);
3109 return (struct block
*) xzalloc (size
);
3112 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
3113 Shrink_block can also be used by add_symbol to grow a block. */
3115 static struct block
*
3121 struct blockvector
*bv
= BLOCKVECTOR (s
);
3124 /* Just reallocate it and fix references to the old one */
3126 new = (struct block
*) xrealloc ((PTR
) b
,
3127 (sizeof (struct block
)
3128 + ((BLOCK_NSYMS (b
) - 1)
3129 * sizeof (struct symbol
*))));
3131 /* Should chase pointers to old one. Fortunately, that`s just
3132 the block`s function and inferior blocks */
3133 if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b
)
3134 SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
3135 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
3136 if (BLOCKVECTOR_BLOCK (bv
, i
) == b
)
3137 BLOCKVECTOR_BLOCK (bv
, i
) = new;
3138 else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) == b
)
3139 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) = new;
3143 /* Create a new symbol with printname NAME */
3145 static struct symbol
*
3149 struct symbol
*s
= ((struct symbol
*)
3150 obstack_alloc (¤t_objfile
->symbol_obstack
,
3151 sizeof (struct symbol
)));
3153 memset ((PTR
) s
, 0, sizeof (*s
));
3154 SYMBOL_NAME (s
) = name
;
3158 /* Create a new type with printname NAME */
3160 static struct type
*
3166 t
= alloc_type (current_objfile
);
3167 TYPE_NAME (t
) = name
;
3168 TYPE_CPLUS_SPECIFIC (t
) = (struct cplus_struct_type
*) &cplus_struct_default
;
3173 /* Things used for calling functions in the inferior.
3174 These functions are exported to our companion
3175 mips-tdep.c file and are here because they play
3176 with the symbol-table explicitly. */
3178 /* Sigtramp: make sure we have all the necessary information
3179 about the signal trampoline code. Since the official code
3180 from MIPS does not do so, we make up that information ourselves.
3181 If they fix the library (unlikely) this code will neutralize itself. */
3188 struct block
*b
, *b0
;
3190 sigtramp_address
= -1;
3192 /* We have to handle the following cases here:
3193 a) The Mips library has a sigtramp label within sigvec.
3194 b) Irix has a _sigtramp which we want to use, but it also has sigvec. */
3195 s
= lookup_symbol ("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
3198 b0
= SYMBOL_BLOCK_VALUE (s
);
3199 s
= lookup_symbol ("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
3203 /* No sigvec or no sigtramp inside sigvec, try _sigtramp. */
3204 s
= lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
3207 /* But maybe this program uses its own version of sigvec */
3211 /* Did we or MIPSco fix the library ? */
3212 if (SYMBOL_CLASS (s
) == LOC_BLOCK
)
3214 sigtramp_address
= BLOCK_START (SYMBOL_BLOCK_VALUE (s
));
3215 sigtramp_end
= BLOCK_END (SYMBOL_BLOCK_VALUE (s
));
3219 sigtramp_address
= SYMBOL_VALUE (s
);
3220 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
3222 /* But what symtab does it live in ? */
3223 st
= find_pc_symtab (SYMBOL_VALUE (s
));
3226 * Ok, there goes the fix: turn it into a procedure, with all the
3227 * needed info. Note we make it a nested procedure of sigvec,
3228 * which is the way the (assembly) code is actually written.
3230 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
3231 SYMBOL_CLASS (s
) = LOC_BLOCK
;
3232 SYMBOL_TYPE (s
) = init_type (TYPE_CODE_FUNC
, 4, 0, (char *) NULL
,
3233 (struct objfile
*) NULL
);
3234 TYPE_TARGET_TYPE (SYMBOL_TYPE (s
)) = builtin_type_void
;
3236 /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
3238 SYMBOL_BLOCK_VALUE (s
) = b
;
3239 BLOCK_START (b
) = sigtramp_address
;
3240 BLOCK_END (b
) = sigtramp_end
;
3241 BLOCK_FUNCTION (b
) = s
;
3242 BLOCK_SUPERBLOCK (b
) = BLOCK_SUPERBLOCK (b0
);
3246 /* Make a MIPS_EFI_SYMBOL_NAME entry for it */
3248 struct mips_extra_func_info
*e
=
3249 ((struct mips_extra_func_info
*)
3250 xzalloc (sizeof (struct mips_extra_func_info
)));
3252 e
->numargs
= 0; /* the kernel thinks otherwise */
3253 /* align_longword(sigcontext + SIGFRAME) */
3254 e
->pdr
.frameoffset
= 0x150;
3255 e
->pdr
.framereg
= SP_REGNUM
;
3256 /* read_next_frame_reg provides the true pc at the time of signal */
3257 e
->pdr
.pcreg
= PC_REGNUM
;
3258 e
->pdr
.regmask
= -2;
3259 e
->pdr
.regoffset
= -(41 * sizeof (int));
3260 e
->pdr
.fregmask
= -1;
3261 e
->pdr
.fregoffset
= -(7 * sizeof (int));
3262 e
->pdr
.isym
= (long) s
;
3264 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
3265 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
3266 SYMBOL_VALUE (s
) = (int) e
;
3267 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
3268 SYMBOL_CLASS (s
) = LOC_CONST
;
3269 SYMBOL_TYPE (s
) = builtin_type_void
;
3270 current_objfile
= NULL
;
3273 BLOCK_SYM (b
, BLOCK_NSYMS (b
)++) = s
;
3277 /* Fake up identical offsets for all sections. */
3279 struct section_offsets
*
3280 mipscoff_symfile_offsets (objfile
, addr
)
3281 struct objfile
*objfile
;
3284 struct section_offsets
*section_offsets
;
3287 section_offsets
= ((struct section_offsets
*)
3288 obstack_alloc (&objfile
->psymbol_obstack
,
3289 (sizeof (struct section_offsets
)
3290 + (sizeof (section_offsets
->offsets
)
3291 * (SECT_OFF_MAX
- 1)))));
3293 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
3294 ANOFFSET (section_offsets
, i
) = addr
;
3296 return section_offsets
;
3299 /* Initialization */
3301 static struct sym_fns ecoff_sym_fns
=
3303 "ecoff", /* sym_name: name or name prefix of BFD target type */
3304 5, /* sym_namelen: number of significant sym_name chars */
3305 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
3306 mipscoff_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
3307 mipscoff_symfile_read
, /* sym_read: read a symbol file into symtab */
3308 mipscoff_symfile_finish
, /* sym_finish: finished with file, cleanup */
3309 mipscoff_symfile_offsets
, /* sym_offsets: dummy FIXME til implem sym reloc */
3310 NULL
/* next: pointer to next struct sym_fns */
3315 _initialize_mipsread ()
3317 add_symtab_fns (&ecoff_sym_fns
);
3319 /* Missing basic types */
3321 builtin_type_string
=
3322 init_type (TYPE_CODE_STRING
,
3323 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3325 (struct objfile
*) NULL
);
3326 builtin_type_complex
=
3327 init_type (TYPE_CODE_FLT
,
3328 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3330 (struct objfile
*) NULL
);
3331 builtin_type_double_complex
=
3332 init_type (TYPE_CODE_FLT
,
3333 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3334 0, "double complex",
3335 (struct objfile
*) NULL
);
3336 builtin_type_fixed_dec
=
3337 init_type (TYPE_CODE_INT
,
3338 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3340 (struct objfile
*) NULL
);
3341 builtin_type_float_dec
=
3342 init_type (TYPE_CODE_FLT
,
3343 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3344 0, "floating decimal",
3345 (struct objfile
*) NULL
);