1 /* Read os9/os9k symbol tables and convert to internal format, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This module provides three functions: os9k_symfile_init,
22 which initializes to read a symbol file; os9k_new_init, which
23 discards existing cached information when all symbols are being
24 discarded; and os9k_symfile_read, which reads a symbol table
27 os9k_symfile_read only does the minimum work necessary for letting the
28 user "name" things symbolically; it does not read the entire symtab.
29 Instead, it reads the external and static symbols and puts them in partial
30 symbol tables. When more extensive information is requested of a
31 file, the corresponding partial symbol table is mutated into a full
32 fledged symbol table by going back and reading the symbols
33 for real. os9k_psymtab_to_symtab() is the function that does this */
39 #if defined(USG) || defined(__CYGNUSCLIB__)
40 #include <sys/types.h>
45 #include <sys/param.h>
52 #include "breakpoint.h"
55 #include "gdbcore.h" /* for bfd stuff */
56 #include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */
57 #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
61 #include "gdb-stabs.h"
63 #include "language.h" /* Needed inside partial-stab.h */
64 #include "complaints.h"
66 #include "stabsread.h"
68 #if !defined (SEEK_SET)
73 /* Each partial symbol table entry contains a pointer to private data for the
74 read_symtab() function to use when expanding a partial symbol table entry
75 to a full symbol table entry.
77 For dbxread this structure contains the offset within the file symbol table
78 of first local symbol for this file, and count of the section
79 of the symbol table devoted to this file's symbols (actually, the section
80 bracketed may contain more than just this file's symbols). It also contains
81 further information needed to locate the symbols if they are in an ELF file.
83 If ldsymcnt is 0, the only reason for this thing's existence is the
84 dependency list. Nothing else will happen when it is read in. */
86 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
87 #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum)
94 /* Remember what we deduced to be the source language of this psymtab. */
95 static enum language psymtab_language
= language_unknown
;
97 /* keep partial symbol table file nested depth */
98 static int psymfile_depth
= 0;
100 /* keep symbol table file nested depth */
101 static int symfile_depth
= 0;
103 /* Nonzero means give verbose info on gdb action. From main.c. */
104 extern int info_verbose
;
106 extern int previous_stab_code
;
108 /* Name of last function encountered. Used in Solaris to approximate
109 object file boundaries. */
110 static char *last_function_name
;
112 /* Complaints about the symbols we have encountered. */
113 extern struct complaint lbrac_complaint
;
115 extern struct complaint unknown_symtype_complaint
;
117 extern struct complaint unknown_symchar_complaint
;
119 extern struct complaint lbrac_rbrac_complaint
;
121 extern struct complaint repeated_header_complaint
;
123 extern struct complaint repeated_header_name_complaint
;
126 static struct complaint lbrac_unmatched_complaint
=
127 {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
129 static struct complaint lbrac_mismatch_complaint
=
130 {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
133 /* Local function prototypes */
135 os9k_read_ofile_symtab
PARAMS ((struct partial_symtab
*));
138 os9k_psymtab_to_symtab
PARAMS ((struct partial_symtab
*));
141 os9k_psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*));
144 read_os9k_psymtab
PARAMS ((struct section_offsets
*, struct objfile
*,
148 init_psymbol_list
PARAMS ((struct objfile
*));
151 fill_sym
PARAMS ((FILE *, bfd
*));
154 os9k_symfile_init
PARAMS ((struct objfile
*));
157 os9k_new_init
PARAMS ((struct objfile
*));
160 os9k_symfile_read
PARAMS ((struct objfile
*, struct section_offsets
*, int));
163 os9k_symfile_finish
PARAMS ((struct objfile
*));
166 os9k_process_one_symbol
PARAMS ((int, int, CORE_ADDR
, char *,
167 struct section_offsets
*, struct objfile
*));
169 static struct partial_symtab
*
170 os9k_start_psymtab
PARAMS ((struct objfile
*, struct section_offsets
*, char *,
171 CORE_ADDR
, int, int, struct partial_symbol
*,
172 struct partial_symbol
*));
174 static struct partial_symtab
*
175 os9k_end_psymtab
PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
176 struct partial_symtab
**, int));
179 record_minimal_symbol
PARAMS ((char *, CORE_ADDR
, int, struct objfile
*,
180 struct section_offsets
*));
182 #define HANDLE_RBRAC(val) \
183 if ((val) > pst->texthigh) pst->texthigh = (val);
185 #define SWAP_STBHDR(hdrp, abfd) \
187 (hdrp)->fmtno = bfd_get_16(abfd, (unsigned char *)&(hdrp)->fmtno); \
188 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
189 (hdrp)->offset = bfd_get_32(abfd, (unsigned char *)&(hdrp)->offset); \
190 (hdrp)->nsym = bfd_get_32(abfd, (unsigned char *)&(hdrp)->nsym); \
192 #define SWAP_STBSYM(symp, abfd) \
194 (symp)->value = bfd_get_32(abfd, (unsigned char *)&(symp)->value); \
195 (symp)->type = bfd_get_16(abfd, (unsigned char *)&(symp)->type); \
196 (symp)->stroff = bfd_get_32(abfd, (unsigned char *)&(symp)->stroff); \
206 record_minimal_symbol (name
, address
, type
, objfile
, section_offsets
)
210 struct objfile
*objfile
;
211 struct section_offsets
*section_offsets
;
213 enum minimal_symbol_type ms_type
;
219 address
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
237 ms_type
= mst_unknown
; break;
240 prim_record_minimal_symbol
241 (obsavestring (name
, strlen(name
), &objfile
->symbol_obstack
),
242 address
, ms_type
, objfile
);
245 /* read and process .stb file and store in minimal symbol table */
246 typedef char mhhdr
[80];
261 #define STBSYMSIZE 10
264 read_minimal_symbols(objfile
, section_offsets
)
265 struct objfile
*objfile
;
266 struct section_offsets
*section_offsets
;
271 struct stbsymbol sym
;
273 char buf
[64], buf1
[128];
276 if (fp
== NULL
) return;
277 abfd
= objfile
->obfd
;
278 fread(&hdr
.comhdr
[0], sizeof(mhhdr
), 1, fp
);
287 if (i
%2) ch
=getc(fp
);
290 fread(&hdr
.fmtno
, sizeof(hdr
.fmtno
), 1, fp
);
291 fread(&hdr
.crc
, sizeof(hdr
.crc
), 1, fp
);
292 fread(&hdr
.offset
, sizeof(hdr
.offset
), 1, fp
);
293 fread(&hdr
.nsym
, sizeof(hdr
.nsym
), 1, fp
);
294 SWAP_STBHDR(&hdr
, abfd
);
297 init_minimal_symbol_collection();
299 for (i
= hdr
.nsym
; i
> 0; i
--) {
300 fseek(fp
, (long)off
, 0);
301 fread(&sym
.value
, sizeof(sym
.value
), 1, fp
);
302 fread(&sym
.type
, sizeof(sym
.type
), 1, fp
);
303 fread(&sym
.stroff
, sizeof(sym
.stroff
), 1, fp
);
304 SWAP_STBSYM (&sym
, abfd
);
305 fseek(fp
, (long)sym
.stroff
, 0);
314 record_minimal_symbol(buf1
, sym
.value
, sym
.type
&7, objfile
, section_offsets
);
317 install_minimal_symbols (objfile
);
321 /* Scan and build partial symbols for a symbol file.
322 We have been initialized by a call to os9k_symfile_init, which
323 put all the relevant info into a "struct os9k_symfile_info",
324 hung off the objfile structure.
326 SECTION_OFFSETS contains offsets relative to which the symbols in the
327 various sections are (depending where the sections were actually loaded).
328 MAINLINE is true if we are reading the main symbol
329 table (as opposed to a shared lib or dynamically loaded file). */
332 os9k_symfile_read (objfile
, section_offsets
, mainline
)
333 struct objfile
*objfile
;
334 struct section_offsets
*section_offsets
;
335 int mainline
; /* FIXME comments above */
338 struct cleanup
*back_to
;
340 sym_bfd
= objfile
->obfd
;
341 /* If we are reinitializing, or if we have never loaded syms yet, init */
342 if (mainline
|| objfile
->global_psymbols
.size
== 0 ||
343 objfile
->static_psymbols
.size
== 0)
344 init_psymbol_list (objfile
);
347 back_to
= make_cleanup (really_free_pendings
, 0);
349 make_cleanup (discard_minimal_symbols
, 0);
350 read_minimal_symbols (objfile
, section_offsets
);
352 /* Now that the symbol table data of the executable file are all in core,
353 process them and define symbols accordingly. */
354 read_os9k_psymtab (section_offsets
, objfile
,
355 bfd_section_vma (sym_bfd
, DBX_TEXT_SECT (objfile
)),
356 bfd_section_size (sym_bfd
, DBX_TEXT_SECT (objfile
)));
358 do_cleanups (back_to
);
361 /* Initialize anything that needs initializing when a completely new
362 symbol file is specified (not just adding some symbols from another
363 file, e.g. a shared library). */
366 os9k_new_init (ignore
)
367 struct objfile
*ignore
;
369 stabsread_new_init ();
370 buildsym_new_init ();
373 init_header_files ();
377 /* os9k_symfile_init ()
378 It is passed a struct objfile which contains, among other things,
379 the BFD for the file whose symbols are being read, and a slot for a pointer
380 to "private data" which we fill with goodies.
382 Since BFD doesn't know how to read debug symbols in a format-independent
383 way (and may never do so...), we have to do it ourselves. We will never
384 be called unless this is an a.out (or very similar) file.
385 FIXME, there should be a cleaner peephole into the BFD environment here. */
388 os9k_symfile_init (objfile
)
389 struct objfile
*objfile
;
391 bfd
*sym_bfd
= objfile
->obfd
;
392 char *name
= bfd_get_filename (sym_bfd
);
393 char dbgname
[512], stbname
[512];
398 strcpy(dbgname
, name
);
399 strcat(dbgname
, ".dbg");
400 strcpy(stbname
, name
);
401 strcat(stbname
, ".stb");
403 if ((symfile
= fopen(dbgname
, "r")) == NULL
) {
404 warning("Symbol file %s not found", dbgname
);
406 objfile
->auxf2
= symfile
;
408 if ((minfile
= fopen(stbname
, "r")) == NULL
) {
409 warning("Symbol file %s not found", stbname
);
411 objfile
->auxf1
= minfile
;
413 /* Allocate struct to keep track of the symfile */
414 objfile
->sym_stab_info
= (PTR
)
415 xmmalloc (objfile
-> md
, sizeof (struct dbx_symfile_info
));
416 DBX_SYMFILE_INFO (objfile
)->stab_section_info
= NULL
;
418 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
419 if (!DBX_TEXT_SECT (objfile
))
420 error ("Can't find .text section in file");
422 DBX_SYMBOL_SIZE (objfile
) = 0; /* variable size symbol */
423 DBX_SYMCOUNT (objfile
) = 0; /* used to be bfd_get_symcount(sym_bfd) */
424 DBX_SYMTAB_OFFSET (objfile
) = 0; /* used to be SYMBOL_TABLE_OFFSET */
427 /* Perform any local cleanups required when we are done with a particular
428 objfile. I.E, we are in the process of discarding all symbol information
429 for an objfile, freeing up all memory held for it, and unlinking the
430 objfile struct from the global list of known objfiles. */
433 os9k_symfile_finish (objfile
)
434 struct objfile
*objfile
;
436 if (objfile
->sym_stab_info
!= NULL
)
438 mfree (objfile
-> md
, objfile
->sym_stab_info
);
441 free_header_files ();
453 #define SYNC (int)0xefbefeca
455 #define SWAP_DBGHDR(hdrp, abfd) \
457 (hdrp)->sync = bfd_get_32(abfd, (unsigned char *)&(hdrp)->sync); \
458 (hdrp)->rev = bfd_get_16(abfd, (unsigned char *)&(hdrp)->rev); \
459 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
460 (hdrp)->os = bfd_get_16(abfd, (unsigned char *)&(hdrp)->os); \
461 (hdrp)->cpu = bfd_get_16(abfd, (unsigned char *)&(hdrp)->cpu); \
464 #define N_SYM_CMPLR 0
465 #define N_SYM_SLINE 1
467 #define N_SYM_LBRAC 3
468 #define N_SYM_RBRAC 4
471 struct internal_symstruct
{
477 static struct internal_symstruct symbol
;
478 static struct internal_symstruct
*symbuf
= &symbol
;
479 static char strbuf
[4096];
480 static struct st_dbghdr dbghdr
;
481 static short cmplrid
;
483 #define VER_PRE_ULTRAC ((short)4)
484 #define VER_ULTRAC ((short)5)
487 fill_sym (dbg_file
, abfd
)
496 int nbytes
= fread(&si
, sizeof(si
), 1, dbg_file
);
500 perror_with_name ("reading .dbg file.");
503 symbuf
->n_strx
= NULL
;
504 symbuf
->n_type
= bfd_get_16 (abfd
, (unsigned char *)&si
);
505 symbuf
->n_type
= 0xf & symbuf
->n_type
;
506 switch (symbuf
->n_type
)
509 fread(&si
, sizeof(si
), 1, dbg_file
);
510 symbuf
->n_desc
= bfd_get_16(abfd
, (unsigned char *)&si
);
511 cmplrid
= symbuf
->n_desc
& 0xff;
514 fread(&li
, sizeof(li
), 1, dbg_file
);
515 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
516 fread(&li
, sizeof(li
), 1, dbg_file
);
517 li
= bfd_get_32(abfd
, (unsigned char *)&li
);
518 symbuf
->n_strx
= (char *)(li
>> 12);
519 symbuf
->n_desc
= li
& 0xfff;
522 fread(&li
, sizeof(li
), 1, dbg_file
);
523 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
527 strbuf
[si
++] = (char) ii
;
528 } while (ii
!= 0 || si
% 2 != 0);
529 symbuf
->n_strx
= strbuf
;
530 p
= (char *) strchr (strbuf
, ':');
532 if ((p
[1] == 'F' || p
[1] == 'f') && cmplrid
== VER_PRE_ULTRAC
)
534 fread(&si
, sizeof(si
), 1, dbg_file
);
535 nmask
= bfd_get_16(abfd
, (unsigned char *)&si
);
536 for (ii
=0; ii
<nmask
; ii
++)
537 fread(&si
, sizeof(si
), 1, dbg_file
);
541 fread(&li
, sizeof(li
), 1, dbg_file
);
542 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
545 fread(&li
, sizeof(li
), 1, dbg_file
);
546 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
554 /* Initializes storage for all of the partial symbols that will be
555 created by read_dbx_symtab and subsidiaries. */
558 init_psymbol_list (objfile
)
559 struct objfile
*objfile
;
561 /* Free any previously allocated psymbol lists. */
562 if (objfile
-> global_psymbols
.list
)
563 mfree (objfile
-> md
, (PTR
)objfile
-> global_psymbols
.list
);
564 if (objfile
-> static_psymbols
.list
)
565 mfree (objfile
-> md
, (PTR
)objfile
-> static_psymbols
.list
);
567 /* Current best guess is that there are approximately a twentieth
568 of the total symbols (in a debugging file) are global or static
570 objfile
-> global_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
571 objfile
-> static_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
572 objfile
-> global_psymbols
.next
= objfile
-> global_psymbols
.list
= (struct partial_symbol
*)
573 xmmalloc (objfile
-> md
, objfile
-> global_psymbols
.size
* sizeof (struct partial_symbol
));
574 objfile
-> static_psymbols
.next
= objfile
-> static_psymbols
.list
= (struct partial_symbol
*)
575 xmmalloc (objfile
-> md
, objfile
-> static_psymbols
.size
* sizeof (struct partial_symbol
));
578 /* Given pointers to an a.out symbol table in core containing dbx
579 style data, setup partial_symtab's describing each source file for
580 which debugging information is available.
581 SYMFILE_NAME is the name of the file we are reading from
582 and SECTION_OFFSETS is the set of offsets for the various sections
583 of the file (a set of zeros if the mainline program). */
586 read_os9k_psymtab (section_offsets
, objfile
, text_addr
, text_size
)
587 struct section_offsets
*section_offsets
;
588 struct objfile
*objfile
;
592 register struct internal_symstruct
*bufp
= 0; /* =0 avoids gcc -Wall glitch*/
593 register char *namestring
;
594 int past_first_source_file
= 0;
595 CORE_ADDR last_o_file_start
= 0;
597 struct cleanup
*back_to
;
602 /* End of the text segment of the executable file. */
603 static CORE_ADDR end_of_text_addr
;
605 /* Current partial symtab */
606 static struct partial_symtab
*pst
= 0;
608 /* List of current psymtab's include files */
609 char **psymtab_include_list
;
610 int includes_allocated
;
613 /* Index within current psymtab dependency list */
614 struct partial_symtab
**dependency_list
;
615 int dependencies_used
, dependencies_allocated
;
617 includes_allocated
= 30;
619 psymtab_include_list
= (char **) alloca (includes_allocated
*
622 dependencies_allocated
= 30;
623 dependencies_used
= 0;
625 (struct partial_symtab
**) alloca (dependencies_allocated
*
626 sizeof (struct partial_symtab
*));
628 last_source_file
= NULL
;
630 #ifdef END_OF_TEXT_DEFAULT
631 end_of_text_addr
= END_OF_TEXT_DEFAULT
;
633 end_of_text_addr
= text_addr
+ section_offsets
->offsets
[SECT_OFF_TEXT
]
634 + text_size
; /* Relocate */
637 abfd
= objfile
->obfd
;
641 fread(&dbghdr
.sync
, sizeof(dbghdr
.sync
), 1, fp
);
642 fread(&dbghdr
.rev
, sizeof(dbghdr
.rev
), 1, fp
);
643 fread(&dbghdr
.crc
, sizeof(dbghdr
.crc
), 1, fp
);
644 fread(&dbghdr
.os
, sizeof(dbghdr
.os
), 1, fp
);
645 fread(&dbghdr
.cpu
, sizeof(dbghdr
.cpu
), 1, fp
);
646 SWAP_DBGHDR(&dbghdr
, abfd
);
654 /* Get the symbol for this run and pull out some info */
655 QUIT
; /* allow this to be interruptable */
656 cursymoffset
= ftell(objfile
->auxf2
);
657 ret
= fill_sym(objfile
->auxf2
, abfd
);
662 /* Special case to speed up readin. */
663 if (bufp
->n_type
== (short)N_SYM_SLINE
) continue;
665 #define CUR_SYMBOL_VALUE bufp->n_value
668 switch (bufp
->n_type
)
676 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
677 if (psymfile_depth
== 1 && pst
)
679 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
680 symnum
, CUR_SYMBOL_VALUE
,
681 dependency_list
, dependencies_used
);
682 pst
= (struct partial_symtab
*) 0;
684 dependencies_used
= 0;
689 case N_SYM_SYM
: /* Typedef or automatic variable. */
690 namestring
= bufp
->n_strx
;
691 p
= (char *) strchr (namestring
, ':');
693 continue; /* Not a debugging symbol. */
695 /* Main processing section for debugging symbols which
696 the initial read through the symbol tables needs to worry
697 about. If we reach this point, the symbol which we are
698 considering is definitely one we are interested in.
699 p must also contain the (valid) index into the namestring
700 which indicates the debugging type symbol. */
707 enum language tmp_language
;
711 valu
= CUR_SYMBOL_VALUE
;
713 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
714 past_first_source_file
= 1;
716 p
= strchr(namestring
, ':');
717 if (p
) n
= p
-namestring
;
718 else n
= strlen(namestring
);
720 strncpy(str
, namestring
, n
);
723 if (psymfile_depth
== 0) {
725 pst
= os9k_start_psymtab (objfile
, section_offsets
,
729 objfile
-> global_psymbols
.next
,
730 objfile
-> static_psymbols
.next
);
731 } else { /* this is a include file */
732 tmp_language
= deduce_language_from_filename (str
);
733 if (tmp_language
!= language_unknown
734 && (tmp_language
!= language_c
735 || psymtab_language
!= language_cplus
))
736 psymtab_language
= tmp_language
;
739 if (pst && STREQ (str, pst->filename))
743 for (i = 0; i < includes_used; i++)
744 if (STREQ (str, psymtab_include_list[i]))
754 psymtab_include_list
[includes_used
++] = str
;
755 if (includes_used
>= includes_allocated
)
757 char **orig
= psymtab_include_list
;
759 psymtab_include_list
= (char **)
760 alloca ((includes_allocated
*= 2) * sizeof (char *));
761 memcpy ((PTR
)psymtab_include_list
, (PTR
)orig
,
762 includes_used
* sizeof (char *));
771 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
772 VAR_NAMESPACE
, LOC_STATIC
,
773 objfile
->static_psymbols
,
775 psymtab_language
, objfile
);
778 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
779 VAR_NAMESPACE
, LOC_STATIC
,
780 objfile
->global_psymbols
,
782 psymtab_language
, objfile
);
786 if (p
!= namestring
) /* a name is there, not just :T... */
788 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
789 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
790 objfile
->static_psymbols
,
792 psymtab_language
, objfile
);
795 /* Also a typedef with the same name. */
796 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
797 VAR_NAMESPACE
, LOC_TYPEDEF
,
798 objfile
->static_psymbols
,
799 CUR_SYMBOL_VALUE
, psymtab_language
,
803 /* The semantics of C++ state that "struct foo { ... }"
804 also defines a typedef for "foo". Unfortuantely, cfront
805 never makes the typedef when translating from C++ to C.
806 We make the typedef here so that "ptype foo" works as
807 expected for cfront translated code. */
808 else if (psymtab_language
== language_cplus
)
810 /* Also a typedef with the same name. */
811 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
812 VAR_NAMESPACE
, LOC_TYPEDEF
,
813 objfile
->static_psymbols
,
814 CUR_SYMBOL_VALUE
, psymtab_language
,
820 if (p
!= namestring
) /* a name is there, not just :T... */
822 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
823 VAR_NAMESPACE
, LOC_TYPEDEF
,
824 objfile
->static_psymbols
,
826 psymtab_language
, objfile
);
829 /* If this is an enumerated type, we need to
830 add all the enum constants to the partial symbol
831 table. This does not cover enums without names, e.g.
832 "enum {a, b} c;" in C, but fortunately those are
833 rare. There is no way for GDB to find those from the
834 enum type without spending too much time on it. Thus
835 to solve this problem, the compiler needs to put out the
836 enum in a nameless type. GCC2 does this. */
838 /* We are looking for something of the form
839 <name> ":" ("t" | "T") [<number> "="] "e" <size>
840 {<constant> ":" <value> ","} ";". */
842 /* Skip over the colon and the 't' or 'T'. */
844 /* This type may be given a number. Also, numbers can come
845 in pairs like (0,26). Skip over it. */
846 while ((*p
>= '0' && *p
<= '9')
847 || *p
== '(' || *p
== ',' || *p
== ')'
853 /* We have found an enumerated type. skip size */
854 while (*p
>= '0' && *p
<= '9') p
++;
855 /* According to comments in read_enum_type
856 a comma could end it instead of a semicolon.
857 I don't know where that happens.
859 while (*p
&& *p
!= ';' && *p
!= ',')
863 /* Check for and handle cretinous dbx symbol name
866 p = next_symbol_text ();
869 /* Point to the character after the name
870 of the enum constant. */
871 for (q
= p
; *q
&& *q
!= ':'; q
++)
873 /* Note that the value doesn't matter for
874 enum constants in psymtabs, just in symtabs. */
875 ADD_PSYMBOL_TO_LIST (p
, q
- p
,
876 VAR_NAMESPACE
, LOC_CONST
,
877 objfile
->static_psymbols
, 0,
878 psymtab_language
, objfile
);
879 /* Point past the name. */
881 /* Skip over the value. */
882 while (*p
&& *p
!= ',')
884 /* Advance past the comma. */
891 /* Constant, e.g. from "const" in Pascal. */
892 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
893 VAR_NAMESPACE
, LOC_CONST
,
894 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
895 psymtab_language
, objfile
);
899 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
900 if (pst
&& pst
->textlow
== 0)
901 pst
->textlow
= CUR_SYMBOL_VALUE
;
903 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
904 VAR_NAMESPACE
, LOC_BLOCK
,
905 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
906 psymtab_language
, objfile
);
910 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
911 if (pst
&& pst
->textlow
== 0)
912 pst
->textlow
= CUR_SYMBOL_VALUE
;
914 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
915 VAR_NAMESPACE
, LOC_BLOCK
,
916 objfile
->global_psymbols
, CUR_SYMBOL_VALUE
,
917 psymtab_language
, objfile
);
926 /* It is a C++ nested symbol. We don't need to record it
927 (I don't think); if we try to look up foo::bar::baz,
928 then symbols for the symtab containing foo should get
930 /* Someone says sun cc puts out symbols like
931 /foo/baz/maclib::/usr/local/bin/maclib,
932 which would get here with a symbol type of ':'. */
936 /* Unexpected symbol descriptor. The second and subsequent stabs
937 of a continued stab can show up here. The question is
938 whether they ever can mimic a normal stab--it would be
939 nice if not, since we certainly don't want to spend the
940 time searching to the end of every string looking for
943 complain (&unknown_symchar_complaint
, p
[1]);
948 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
950 HANDLE_RBRAC(CUR_SYMBOL_VALUE
);
957 /* If we haven't found it yet, ignore it. It's probably some
958 new type we don't know about yet. */
959 complain (&unknown_symtype_complaint
,
960 local_hex_string ((unsigned long) bufp
->n_type
));
965 DBX_SYMCOUNT (objfile
) = symnum
;
967 /* If there's stuff to be cleaned up, clean it up. */
968 if (DBX_SYMCOUNT (objfile
) > 0
969 /*FIXME, does this have a bug at start address 0? */
971 && objfile
-> ei
.entry_point
< bufp
->n_value
972 && objfile
-> ei
.entry_point
>= last_o_file_start
)
974 objfile
-> ei
.entry_file_lowpc
= last_o_file_start
;
975 objfile
-> ei
.entry_file_highpc
= bufp
->n_value
;
980 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
981 symnum
, end_of_text_addr
,
982 dependency_list
, dependencies_used
);
985 do_cleanups (back_to);
989 /* Allocate and partially fill a partial symtab. It will be
990 completely filled at the end of the symbol list.
992 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
993 is the address relative to which its symbols are (incremental) or 0
997 static struct partial_symtab
*
998 os9k_start_psymtab (objfile
, section_offsets
,
999 filename
, textlow
, ldsymoff
,ldsymcnt
, global_syms
, static_syms
)
1000 struct objfile
*objfile
;
1001 struct section_offsets
*section_offsets
;
1006 struct partial_symbol
*global_syms
;
1007 struct partial_symbol
*static_syms
;
1009 struct partial_symtab
*result
=
1010 start_psymtab_common(objfile
, section_offsets
,
1011 filename
, textlow
, global_syms
, static_syms
);
1013 result
->read_symtab_private
= (char *)
1014 obstack_alloc (&objfile
-> psymbol_obstack
, sizeof (struct symloc
));
1016 LDSYMOFF(result
) = ldsymoff
;
1017 LDSYMCNT(result
) = ldsymcnt
;
1018 result
->read_symtab
= os9k_psymtab_to_symtab
;
1020 /* Deduce the source language from the filename for this psymtab. */
1021 psymtab_language
= deduce_language_from_filename (filename
);
1025 /* Close off the current usage of PST.
1026 Returns PST or NULL if the partial symtab was empty and thrown away.
1027 FIXME: List variables and peculiarities of same. */
1029 static struct partial_symtab
*
1030 os9k_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_cnt
,
1031 capping_text
, dependency_list
, number_dependencies
)
1032 struct partial_symtab
*pst
;
1033 char **include_list
;
1035 int capping_symbol_cnt
;
1036 CORE_ADDR capping_text
;
1037 struct partial_symtab
**dependency_list
;
1038 int number_dependencies
;
1039 /* struct partial_symbol *capping_global, *capping_static;*/
1042 struct partial_symtab
*p1
;
1043 struct objfile
*objfile
= pst
-> objfile
;
1045 if (capping_symbol_cnt
!= -1)
1046 LDSYMCNT(pst
) = capping_symbol_cnt
- LDSYMCNT(pst
);
1048 /* Under Solaris, the N_SO symbols always have a value of 0,
1049 instead of the usual address of the .o file. Therefore,
1050 we have to do some tricks to fill in texthigh and textlow.
1051 The first trick is in partial-stab.h: if we see a static
1052 or global function, and the textlow for the current pst
1053 is still 0, then we use that function's address for
1054 the textlow of the pst.
1056 Now, to fill in texthigh, we remember the last function seen
1057 in the .o file (also in partial-stab.h). Also, there's a hack in
1058 bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
1059 to here via the misc_info field. Therefore, we can fill in
1060 a reliable texthigh by taking the address plus size of the
1061 last function in the file.
1063 Unfortunately, that does not cover the case where the last function
1064 in the file is static. See the paragraph below for more comments
1067 Finally, if we have a valid textlow for the current file, we run
1068 down the partial_symtab_list filling in previous texthighs that
1069 are still unknown. */
1071 if (pst
->texthigh
== 0 && last_function_name
) {
1074 struct minimal_symbol
*minsym
;
1076 p
= strchr (last_function_name
, ':');
1078 p
= last_function_name
;
1079 n
= p
- last_function_name
;
1081 strncpy (p
, last_function_name
, n
);
1084 minsym
= lookup_minimal_symbol (p
, objfile
);
1087 pst
->texthigh
= SYMBOL_VALUE_ADDRESS(minsym
)+(long)MSYMBOL_INFO(minsym
);
1089 /* This file ends with a static function, and it's
1090 difficult to imagine how hard it would be to track down
1091 the elf symbol. Luckily, most of the time no one will notice,
1092 since the next file will likely be compiled with -g, so
1093 the code below will copy the first fuction's start address
1094 back to our texthigh variable. (Also, if this file is the
1095 last one in a dynamically linked program, texthigh already
1096 has the right value.) If the next file isn't compiled
1097 with -g, then the last function in this file winds up owning
1098 all of the text space up to the next -g file, or the end (minus
1099 shared libraries). This only matters for single stepping,
1100 and even then it will still work, except that it will single
1101 step through all of the covered functions, instead of setting
1102 breakpoints around them as it usualy does. This makes it
1103 pretty slow, but at least it doesn't fail.
1105 We can fix this with a fairly big change to bfd, but we need
1106 to coordinate better with Cygnus if we want to do that. FIXME. */
1108 last_function_name
= NULL
;
1111 /* this test will be true if the last .o file is only data */
1112 if (pst
->textlow
== 0)
1113 pst
->textlow
= pst
->texthigh
;
1115 /* If we know our own starting text address, then walk through all other
1116 psymtabs for this objfile, and if any didn't know their ending text
1117 address, set it to our starting address. Take care to not set our
1118 own ending address to our starting address, nor to set addresses on
1119 `dependency' files that have both textlow and texthigh zero. */
1121 ALL_OBJFILE_PSYMTABS (objfile
, p1
) {
1122 if (p1
->texthigh
== 0 && p1
->textlow
!= 0 && p1
!= pst
) {
1123 p1
->texthigh
= pst
->textlow
;
1124 /* if this file has only data, then make textlow match texthigh */
1125 if (p1
->textlow
== 0)
1126 p1
->textlow
= p1
->texthigh
;
1131 /* End of kludge for patching Solaris textlow and texthigh. */
1133 pst
->n_global_syms
=
1134 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
1135 pst
->n_static_syms
=
1136 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
1138 pst
->number_of_dependencies
= number_dependencies
;
1139 if (number_dependencies
)
1141 pst
->dependencies
= (struct partial_symtab
**)
1142 obstack_alloc (&objfile
->psymbol_obstack
,
1143 number_dependencies
* sizeof (struct partial_symtab
*));
1144 memcpy (pst
->dependencies
, dependency_list
,
1145 number_dependencies
* sizeof (struct partial_symtab
*));
1148 pst
->dependencies
= 0;
1150 for (i
= 0; i
< num_includes
; i
++)
1152 struct partial_symtab
*subpst
=
1153 allocate_psymtab (include_list
[i
], objfile
);
1155 subpst
->section_offsets
= pst
->section_offsets
;
1156 subpst
->read_symtab_private
=
1157 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
1158 sizeof (struct symloc
));
1162 subpst
->texthigh
= 0;
1164 /* We could save slight bits of space by only making one of these,
1165 shared by the entire set of include files. FIXME-someday. */
1166 subpst
->dependencies
= (struct partial_symtab
**)
1167 obstack_alloc (&objfile
->psymbol_obstack
,
1168 sizeof (struct partial_symtab
*));
1169 subpst
->dependencies
[0] = pst
;
1170 subpst
->number_of_dependencies
= 1;
1172 subpst
->globals_offset
=
1173 subpst
->n_global_syms
=
1174 subpst
->statics_offset
=
1175 subpst
->n_static_syms
= 0;
1179 subpst
->read_symtab
= pst
->read_symtab
;
1182 sort_pst_symbols (pst
);
1184 /* If there is already a psymtab or symtab for a file of this name,
1186 (If there is a symtab, more drastic things also happen.)
1187 This happens in VxWorks. */
1188 free_named_symtabs (pst
->filename
);
1190 if (num_includes
== 0
1191 && number_dependencies
== 0
1192 && pst
->n_global_syms
== 0
1193 && pst
->n_static_syms
== 0) {
1194 /* Throw away this psymtab, it's empty. We can't deallocate it, since
1195 it is on the obstack, but we can forget to chain it on the list. */
1196 struct partial_symtab
*prev_pst
;
1198 /* First, snip it out of the psymtab chain */
1200 if (pst
->objfile
->psymtabs
== pst
)
1201 pst
->objfile
->psymtabs
= pst
->next
;
1203 for (prev_pst
= pst
->objfile
->psymtabs
; prev_pst
; prev_pst
= pst
->next
)
1204 if (prev_pst
->next
== pst
)
1205 prev_pst
->next
= pst
->next
;
1207 /* Next, put it on a free list for recycling */
1208 pst
->next
= pst
->objfile
->free_psymtabs
;
1209 pst
->objfile
->free_psymtabs
= pst
;
1211 /* Indicate that psymtab was thrown away. */
1212 pst
= (struct partial_symtab
*)NULL
;
1218 os9k_psymtab_to_symtab_1 (pst
)
1219 struct partial_symtab
*pst
;
1221 struct cleanup
*old_chain
;
1229 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1234 /* Read in all partial symtabs on which this one is dependent */
1235 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
1236 if (!pst
->dependencies
[i
]->readin
)
1238 /* Inform about additional files that need to be read in. */
1241 fputs_filtered (" ", gdb_stdout
);
1243 fputs_filtered ("and ", gdb_stdout
);
1245 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
1246 wrap_here (""); /* Flush output */
1247 gdb_flush (gdb_stdout
);
1249 os9k_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
1252 if (LDSYMCNT(pst
)) /* Otherwise it's a dummy */
1254 /* Init stuff necessary for reading in symbols */
1257 old_chain
= make_cleanup (really_free_pendings
, 0);
1259 /* Read in this file's symbols */
1260 os9k_read_ofile_symtab (pst
);
1261 sort_symtab_syms (pst
->symtab
);
1262 do_cleanups (old_chain
);
1268 /* Read in all of the symbols for a given psymtab for real.
1269 Be verbose about it if the user wants that. */
1272 os9k_psymtab_to_symtab (pst
)
1273 struct partial_symtab
*pst
;
1282 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1287 if (LDSYMCNT(pst
) || pst
->number_of_dependencies
)
1289 /* Print the message now, before reading the string table,
1290 to avoid disconcerting pauses. */
1293 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
1294 gdb_flush (gdb_stdout
);
1297 sym_bfd
= pst
->objfile
->obfd
;
1298 os9k_psymtab_to_symtab_1 (pst
);
1300 /* Match with global symbols. This only needs to be done once,
1301 after all of the symtabs and dependencies have been read in. */
1302 scan_file_globals (pst
->objfile
);
1304 /* Finish up the debug error message. */
1306 printf_filtered ("done.\n");
1310 /* Read in a defined section of a specific object file's symbols. */
1312 os9k_read_ofile_symtab (pst
)
1313 struct partial_symtab
*pst
;
1315 register struct internal_symstruct
*bufp
;
1317 unsigned max_symnum
;
1319 struct objfile
*objfile
;
1320 int sym_offset
; /* Offset to start of symbols to read */
1321 CORE_ADDR text_offset
; /* Start of text segment for symbols */
1322 int text_size
; /* Size of text segment for symbols */
1323 struct section_offsets
*section_offsets
;
1326 objfile
= pst
->objfile
;
1327 sym_offset
= LDSYMOFF(pst
);
1328 max_symnum
= LDSYMCNT(pst
);
1329 text_offset
= pst
->textlow
;
1330 text_size
= pst
->texthigh
- pst
->textlow
;
1331 section_offsets
= pst
->section_offsets
;
1333 current_objfile
= objfile
;
1334 subfile_stack
= NULL
;
1335 last_source_file
= NULL
;
1337 abfd
= objfile
->obfd
;
1338 dbg_file
= objfile
->auxf2
;
1341 /* It is necessary to actually read one symbol *before* the start
1342 of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1343 occurs before the N_SO symbol.
1344 Detecting this in read_dbx_symtab
1345 would slow down initial readin, so we look for it here instead. */
1346 if (!processing_acc_compilation
&& sym_offset
>= (int)symbol_size
)
1348 fseek (objefile
->auxf2
, sym_offset
, SEEK_CUR
);
1349 fill_sym(objfile
->auxf2
, abfd
);
1352 processing_gcc_compilation
= 0;
1353 if (bufp
->n_type
== N_TEXT
)
1355 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1356 processing_gcc_compilation
= 1;
1357 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1358 processing_gcc_compilation
= 2;
1361 /* Try to select a C++ demangling based on the compilation unit
1364 if (processing_gcc_compilation
)
1366 if (AUTO_DEMANGLING
)
1368 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1374 /* The N_SO starting this symtab is the first symbol, so we
1375 better not check the symbol before it. I'm not this can
1376 happen, but it doesn't hurt to check for it. */
1377 bfd_seek (symfile_bfd
, sym_offset
, SEEK_CUR
);
1378 processing_gcc_compilation
= 0;
1382 fseek(dbg_file
, (long)sym_offset
, 0);
1384 if (bufp->n_type != (unsigned char)N_SYM_SYM)
1385 error("First symbol in segment of executable not a source symbol");
1388 for (symnum
= 0; symnum
< max_symnum
; symnum
++)
1390 QUIT
; /* Allow this to be interruptable */
1391 fill_sym(dbg_file
, abfd
);
1393 type
= bufp
->n_type
;
1395 os9k_process_one_symbol ((int)type
, (int)bufp
->n_desc
,
1396 (CORE_ADDR
)bufp
->n_value
, bufp
->n_strx
, section_offsets
, objfile
);
1398 /* We skip checking for a new .o or -l file; that should never
1399 happen in this routine. */
1401 else if (type
== N_TEXT
)
1403 /* I don't think this code will ever be executed, because
1404 the GCC_COMPILED_FLAG_SYMBOL usually is right before
1405 the N_SO symbol which starts this source file.
1406 However, there is no reason not to accept
1407 the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1409 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1410 processing_gcc_compilation
= 1;
1411 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1412 processing_gcc_compilation
= 2;
1414 if (AUTO_DEMANGLING
)
1416 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1419 else if (type
& N_EXT
|| type
== (unsigned char)N_TEXT
1420 || type
== (unsigned char)N_NBTEXT
1422 /* Global symbol: see if we came across a dbx defintion for
1423 a corresponding symbol. If so, store the value. Remove
1424 syms from the chain when their values are stored, but
1425 search the whole chain, as there may be several syms from
1426 different files with the same name. */
1427 /* This is probably not true. Since the files will be read
1428 in one at a time, each reference to a global symbol will
1429 be satisfied in each file as it appears. So we skip this
1436 current_objfile
= NULL
;
1438 /* In a Solaris elf file, this variable, which comes from the
1439 value of the N_SO symbol, will still be 0. Luckily, text_offset,
1440 which comes from pst->textlow is correct. */
1441 if (last_source_start_addr
== 0)
1442 last_source_start_addr
= text_offset
;
1443 pst
->symtab
= end_symtab (text_offset
+ text_size
, 0, 0, objfile
,
1449 /* This handles a single symbol from the symbol-file, building symbols
1450 into a GDB symtab. It takes these arguments and an implicit argument.
1452 TYPE is the type field of the ".stab" symbol entry.
1453 DESC is the desc field of the ".stab" entry.
1454 VALU is the value field of the ".stab" entry.
1455 NAME is the symbol name, in our address space.
1456 SECTION_OFFSETS is a set of amounts by which the sections of this object
1457 file were relocated when it was loaded into memory.
1458 All symbols that refer
1459 to memory locations need to be offset by these amounts.
1460 OBJFILE is the object file from which we are reading symbols.
1461 It is used in end_symtab. */
1464 os9k_process_one_symbol (type
, desc
, valu
, name
, section_offsets
, objfile
)
1468 struct section_offsets
*section_offsets
;
1469 struct objfile
*objfile
;
1471 register struct context_stack
*new;
1472 /* The stab type used for the definition of the last function.
1473 N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
1474 static int function_stab_type
= 0;
1477 /* Something is wrong if we see real data before
1478 seeing a source file name. */
1479 if (last_source_file
== NULL
&& type
!= (unsigned char)N_SO
)
1481 /* Ignore any symbols which appear before an N_SO symbol. Currently
1482 no one puts symbols there, but we should deal gracefully with the
1483 case. A complain()t might be in order (if !IGNORE_SYMBOL (type)),
1484 but this should not be an error (). */
1492 /* On most machines, the block addresses are relative to the
1493 N_SO, the linker did not relocate them (sigh). */
1494 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1495 new = push_context (desc
, valu
);
1499 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1500 new = pop_context();
1502 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
1503 #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
1506 if (!OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1507 local_symbols
= new->locals
;
1509 if (context_stack_depth
> 1)
1511 /* This is not the outermost LBRAC...RBRAC pair in the function,
1512 its local symbols preceded it, and are the ones just recovered
1513 from the context stack. Define the block for them (but don't
1514 bother if the block contains no symbols. Should we complain
1515 on blocks without symbols? I can't think of any useful purpose
1517 if (local_symbols
!= NULL
)
1519 /* Muzzle a compiler bug that makes end < start. (which
1520 compilers? Is this ever harmful?). */
1521 if (new->start_addr
> valu
)
1523 complain (&lbrac_rbrac_complaint
);
1524 new->start_addr
= valu
;
1526 /* Make a block for the local symbols within. */
1527 finish_block (0, &local_symbols
, new->old_blocks
,
1528 new->start_addr
, valu
, objfile
);
1533 if (context_stack_depth
== 0)
1535 within_function
= 0;
1536 /* Make a block for the local symbols within. */
1537 finish_block (new->name
, &local_symbols
, new->old_blocks
,
1538 new->start_addr
, valu
, objfile
);
1542 /* attach local_symbols to the end of new->locals */
1543 if (!new->locals
) new->locals
= local_symbols
;
1548 while (p
->next
) p
= p
->next
;
1549 p
->next
= local_symbols
;
1554 if (OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1555 /* Now pop locals of block just finished. */
1556 local_symbols
= new->locals
;
1561 /* This type of "symbol" really just records
1562 one line-number -- core-address correspondence.
1563 Enter it in the line list for this symbol table. */
1564 /* Relocate for dynamic loading and for ELF acc fn-relative syms. */
1565 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1566 record_line (current_subfile
, (int)name
, valu
);
1569 /* The following symbol types need to have the appropriate offset added
1570 to their value; then we process symbol definitions in the name. */
1577 char *p
= strchr (name
, ':');
1587 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1588 n
= strrchr(name
, '/');
1598 if (symfile_depth
++ == 0) {
1599 if (last_source_file
) {
1600 end_symtab (valu
, 0, 0, objfile
, SECT_OFF_TEXT
);
1605 start_symtab (n
, dirn
, valu
);
1608 start_subfile (n
, dirn
!=NULL
? dirn
: current_subfile
->dirname
);
1614 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1615 function_stab_type
= type
;
1617 within_function
= 1;
1618 new = push_context (0, valu
);
1619 new->name
= define_symbol (valu
, name
, desc
, type
, objfile
);
1624 valu
+= ANOFFSET (section_offsets
, SECT_OFF_DATA
);
1625 define_symbol (valu
, name
, desc
, type
, objfile
);
1629 define_symbol (valu
, name
, desc
, type
, objfile
);
1636 if (--symfile_depth
!= 0)
1637 start_subfile(pop_subfile(), current_subfile
->dirname
);
1641 complain (&unknown_symtype_complaint
,
1642 local_hex_string((unsigned long) type
));
1649 previous_stab_code
= type
;
1652 /* Parse the user's idea of an offset for dynamic linking, into our idea
1653 of how to represent it for fast symbol reading. */
1655 static struct section_offsets
*
1656 os9k_symfile_offsets (objfile
, addr
)
1657 struct objfile
*objfile
;
1660 struct section_offsets
*section_offsets
;
1663 objfile
->num_sections
= SECT_OFF_MAX
;
1664 section_offsets
= (struct section_offsets
*)
1665 obstack_alloc (&objfile
-> psymbol_obstack
,
1666 sizeof (struct section_offsets
)
1667 + sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
1669 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
1670 ANOFFSET (section_offsets
, i
) = addr
;
1672 return section_offsets
;
1675 static struct sym_fns os9k_sym_fns
=
1677 bfd_target_os9k_flavour
,
1678 os9k_new_init
, /* sym_new_init: init anything gbl to entire symtab */
1679 os9k_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
1680 os9k_symfile_read
, /* sym_read: read a symbol file into symtab */
1681 os9k_symfile_finish
, /* sym_finish: finished with file, cleanup */
1682 os9k_symfile_offsets
, /* sym_offsets: parse user's offsets to internal form*/
1683 NULL
/* next: pointer to next struct sym_fns */
1687 _initialize_os9kread ()
1689 add_symtab_fns(&os9k_sym_fns
);