1 /* Read os9/os9k symbol tables and convert to internal format, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993
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 /* The BFD for this file -- implicit parameter to next_symbol_text. */
109 static bfd
*symfile_bfd
;
111 /* Name of last function encountered. Used in Solaris to approximate
112 object file boundaries. */
113 static char *last_function_name
;
115 /* Complaints about the symbols we have encountered. */
116 extern struct complaint lbrac_complaint
;
118 extern struct complaint unknown_symtype_complaint
;
120 extern struct complaint unknown_symchar_complaint
;
122 extern struct complaint lbrac_rbrac_complaint
;
124 extern struct complaint repeated_header_complaint
;
126 extern struct complaint repeated_header_name_complaint
;
128 static struct complaint lbrac_unmatched_complaint
=
129 {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
131 static struct complaint lbrac_mismatch_complaint
=
132 {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
135 /* Local function prototypes */
137 os9k_read_ofile_symtab
PARAMS ((struct partial_symtab
*));
140 os9k_psymtab_to_symtab
PARAMS ((struct partial_symtab
*));
143 os9k_psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*));
146 read_os9k_psymtab
PARAMS ((struct section_offsets
*, struct objfile
*,
150 init_psymbol_list
PARAMS ((struct objfile
*));
153 os9k_next_symbol_text
PARAMS ((void));
156 fill_sym
PARAMS ((FILE *, bfd
*));
159 os9k_symfile_init
PARAMS ((struct objfile
*));
162 os9k_new_init
PARAMS ((struct objfile
*));
165 os9k_symfile_read
PARAMS ((struct objfile
*, struct section_offsets
*, int));
168 os9k_symfile_finish
PARAMS ((struct objfile
*));
171 os9k_process_one_symbol
PARAMS ((int, int, CORE_ADDR
, char *,
172 struct section_offsets
*, struct objfile
*));
174 static struct partial_symtab
*
175 os9k_start_psymtab
PARAMS ((struct objfile
*, struct section_offsets
*, char *,
176 CORE_ADDR
, int, int, struct partial_symbol
*,
177 struct partial_symbol
*));
179 static struct partial_symtab
*
180 os9k_end_psymtab
PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
181 struct partial_symtab
**, int));
184 record_minimal_symbol
PARAMS ((char *, CORE_ADDR
, int, struct objfile
*,
185 struct section_offsets
*));
187 #define HANDLE_RBRAC(val) \
188 if ((val) > pst->texthigh) pst->texthigh = (val);
190 #define SWAP_STBHDR(hdrp, abfd) \
192 (hdrp)->fmtno = bfd_get_16(abfd, (unsigned char *)&(hdrp)->fmtno); \
193 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
194 (hdrp)->offset = bfd_get_32(abfd, (unsigned char *)&(hdrp)->offset); \
195 (hdrp)->nsym = bfd_get_32(abfd, (unsigned char *)&(hdrp)->nsym); \
197 #define SWAP_STBSYM(symp, abfd) \
199 (symp)->value = bfd_get_32(abfd, (unsigned char *)&(symp)->value); \
200 (symp)->type = bfd_get_16(abfd, (unsigned char *)&(symp)->type); \
201 (symp)->stroff = bfd_get_32(abfd, (unsigned char *)&(symp)->stroff); \
211 record_minimal_symbol (name
, address
, type
, objfile
, section_offsets
)
215 struct objfile
*objfile
;
216 struct section_offsets
*section_offsets
;
218 enum minimal_symbol_type ms_type
;
224 address
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
242 ms_type
= mst_unknown
; break;
245 prim_record_minimal_symbol
246 (obsavestring (name
, strlen(name
), &objfile
->symbol_obstack
),
247 address
, ms_type
, objfile
);
250 /* read and process .stb file and store in minimal symbol table */
251 typedef char mhhdr
[80];
266 #define STBSYMSIZE 10
269 read_minimal_symbols(objfile
, section_offsets
)
270 struct objfile
*objfile
;
271 struct section_offsets
*section_offsets
;
276 struct stbsymbol sym
;
278 char buf
[64], buf1
[128];
281 if (fp
== NULL
) return;
282 abfd
= objfile
->obfd
;
283 fread(&hdr
.comhdr
[0], sizeof(mhhdr
), 1, fp
);
292 if (i
%2) ch
=getc(fp
);
295 fread(&hdr
.fmtno
, sizeof(hdr
.fmtno
), 1, fp
);
296 fread(&hdr
.crc
, sizeof(hdr
.crc
), 1, fp
);
297 fread(&hdr
.offset
, sizeof(hdr
.offset
), 1, fp
);
298 fread(&hdr
.nsym
, sizeof(hdr
.nsym
), 1, fp
);
299 SWAP_STBHDR(&hdr
, abfd
);
302 init_minimal_symbol_collection();
304 for (i
= hdr
.nsym
; i
> 0; i
--) {
305 fseek(fp
, (long)off
, 0);
306 fread(&sym
.value
, sizeof(sym
.value
), 1, fp
);
307 fread(&sym
.type
, sizeof(sym
.type
), 1, fp
);
308 fread(&sym
.stroff
, sizeof(sym
.stroff
), 1, fp
);
309 SWAP_STBSYM (&sym
, abfd
);
310 fseek(fp
, (long)sym
.stroff
, 0);
319 record_minimal_symbol(buf1
, sym
.value
, sym
.type
&7, objfile
, section_offsets
);
322 install_minimal_symbols (objfile
);
326 /* Scan and build partial symbols for a symbol file.
327 We have been initialized by a call to os9k_symfile_init, which
328 put all the relevant info into a "struct os9k_symfile_info",
329 hung off the objfile structure.
331 SECTION_OFFSETS contains offsets relative to which the symbols in the
332 various sections are (depending where the sections were actually loaded).
333 MAINLINE is true if we are reading the main symbol
334 table (as opposed to a shared lib or dynamically loaded file). */
337 os9k_symfile_read (objfile
, section_offsets
, mainline
)
338 struct objfile
*objfile
;
339 struct section_offsets
*section_offsets
;
340 int mainline
; /* FIXME comments above */
345 struct cleanup
*back_to
;
347 sym_bfd
= objfile
->obfd
;
348 /* If we are reinitializing, or if we have never loaded syms yet, init */
349 if (mainline
|| objfile
->global_psymbols
.size
== 0 ||
350 objfile
->static_psymbols
.size
== 0)
351 init_psymbol_list (objfile
);
354 back_to
= make_cleanup (really_free_pendings
, 0);
356 make_cleanup (discard_minimal_symbols
, 0);
357 read_minimal_symbols (objfile
, section_offsets
);
359 /* Now that the symbol table data of the executable file are all in core,
360 process them and define symbols accordingly. */
361 read_os9k_psymtab (section_offsets
, objfile
,
362 bfd_section_vma (sym_bfd
, DBX_TEXT_SECT (objfile
)),
363 bfd_section_size (sym_bfd
, DBX_TEXT_SECT (objfile
)));
365 if (!have_partial_symbols ()) {
367 printf_filtered ("(no debugging symbols found)...");
371 do_cleanups (back_to
);
374 /* Initialize anything that needs initializing when a completely new
375 symbol file is specified (not just adding some symbols from another
376 file, e.g. a shared library). */
379 os9k_new_init (ignore
)
380 struct objfile
*ignore
;
382 stabsread_new_init ();
383 buildsym_new_init ();
386 init_header_files ();
390 /* os9k_symfile_init ()
391 It is passed a struct objfile which contains, among other things,
392 the BFD for the file whose symbols are being read, and a slot for a pointer
393 to "private data" which we fill with goodies.
395 Since BFD doesn't know how to read debug symbols in a format-independent
396 way (and may never do so...), we have to do it ourselves. We will never
397 be called unless this is an a.out (or very similar) file.
398 FIXME, there should be a cleaner peephole into the BFD environment here. */
401 os9k_symfile_init (objfile
)
402 struct objfile
*objfile
;
405 bfd
*sym_bfd
= objfile
->obfd
;
406 char *name
= bfd_get_filename (sym_bfd
);
407 char dbgname
[512], stbname
[512];
412 strcpy(dbgname
, name
);
413 strcat(dbgname
, ".dbg");
414 strcpy(stbname
, name
);
415 strcat(stbname
, ".stb");
417 if ((symfile
= fopen(dbgname
, "r")) == NULL
) {
418 warning("Symbol file %s not found", dbgname
);
420 objfile
->auxf2
= symfile
;
422 if ((minfile
= fopen(stbname
, "r")) == NULL
) {
423 warning("Symbol file %s not found", stbname
);
425 objfile
->auxf1
= minfile
;
427 /* Allocate struct to keep track of the symfile */
428 objfile
->sym_stab_info
= (PTR
)
429 xmmalloc (objfile
-> md
, sizeof (struct dbx_symfile_info
));
430 DBX_SYMFILE_INFO (objfile
)->stab_section_info
= NULL
;
432 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
433 if (!DBX_TEXT_SECT (objfile
))
434 error ("Can't find .text section in file");
436 DBX_SYMBOL_SIZE (objfile
) = 0; /* variable size symbol */
437 DBX_SYMCOUNT (objfile
) = 0; /* used to be bfd_get_symcount(sym_bfd) */
438 DBX_SYMTAB_OFFSET (objfile
) = 0; /* used to be SYMBOL_TABLE_OFFSET */
441 /* Perform any local cleanups required when we are done with a particular
442 objfile. I.E, we are in the process of discarding all symbol information
443 for an objfile, freeing up all memory held for it, and unlinking the
444 objfile struct from the global list of known objfiles. */
447 os9k_symfile_finish (objfile
)
448 struct objfile
*objfile
;
450 if (objfile
->sym_stab_info
!= NULL
)
452 mfree (objfile
-> md
, objfile
->sym_stab_info
);
455 free_header_files ();
467 #define SYNC (int)0xefbefeca
469 #define SWAP_DBGHDR(hdrp, abfd) \
471 (hdrp)->sync = bfd_get_32(abfd, (unsigned char *)&(hdrp)->sync); \
472 (hdrp)->rev = bfd_get_16(abfd, (unsigned char *)&(hdrp)->rev); \
473 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
474 (hdrp)->os = bfd_get_16(abfd, (unsigned char *)&(hdrp)->os); \
475 (hdrp)->cpu = bfd_get_16(abfd, (unsigned char *)&(hdrp)->cpu); \
478 #define N_SYM_CMPLR 0
479 #define N_SYM_SLINE 1
481 #define N_SYM_LBRAC 3
482 #define N_SYM_RBRAC 4
485 struct internal_symstruct
{
491 static struct internal_symstruct symbol
;
492 static struct internal_symstruct
*symbuf
= &symbol
;
493 static char strbuf
[4096];
494 static struct st_dbghdr dbghdr
;
495 static short cmplrid
;
497 #define VER_PRE_ULTRAC ((short)4)
498 #define VER_ULTRAC ((short)5)
501 fill_sym (dbg_file
, abfd
)
511 int nbytes
= fread(&si
, sizeof(si
), 1, dbg_file
);
515 perror_with_name ("reading .dbg file.");
518 symbuf
->n_strx
= NULL
;
519 symbuf
->n_type
= bfd_get_16 (abfd
, (unsigned char *)&si
);
520 symbuf
->n_type
= 0xf & symbuf
->n_type
;
521 switch (symbuf
->n_type
)
524 fread(&si
, sizeof(si
), 1, dbg_file
);
525 symbuf
->n_desc
= bfd_get_16(abfd
, (unsigned char *)&si
);
526 cmplrid
= symbuf
->n_desc
& 0xff;
529 fread(&li
, sizeof(li
), 1, dbg_file
);
530 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
531 fread(&li
, sizeof(li
), 1, dbg_file
);
532 li
= bfd_get_32(abfd
, (unsigned char *)&li
);
533 symbuf
->n_strx
= (char *)(li
>> 12);
534 symbuf
->n_desc
= li
& 0xfff;
537 fread(&li
, sizeof(li
), 1, dbg_file
);
538 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
542 strbuf
[si
++] = (char) ii
;
543 } while (ii
!= 0 || si
% 2 != 0);
544 symbuf
->n_strx
= strbuf
;
545 p
= (char *) strchr (strbuf
, ':');
547 if ((p
[1] == 'F' || p
[1] == 'f') && cmplrid
== VER_PRE_ULTRAC
)
549 fread(&si
, sizeof(si
), 1, dbg_file
);
550 nmask
= bfd_get_16(abfd
, (unsigned char *)&si
);
551 for (ii
=0; ii
<nmask
; ii
++)
552 fread(&si
, sizeof(si
), 1, dbg_file
);
556 fread(&li
, sizeof(li
), 1, dbg_file
);
557 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
560 fread(&li
, sizeof(li
), 1, dbg_file
);
561 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
569 /* Initializes storage for all of the partial symbols that will be
570 created by read_dbx_symtab and subsidiaries. */
573 init_psymbol_list (objfile
)
574 struct objfile
*objfile
;
576 /* Free any previously allocated psymbol lists. */
577 if (objfile
-> global_psymbols
.list
)
578 mfree (objfile
-> md
, (PTR
)objfile
-> global_psymbols
.list
);
579 if (objfile
-> static_psymbols
.list
)
580 mfree (objfile
-> md
, (PTR
)objfile
-> static_psymbols
.list
);
582 /* Current best guess is that there are approximately a twentieth
583 of the total symbols (in a debugging file) are global or static
585 objfile
-> global_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
586 objfile
-> static_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
587 objfile
-> global_psymbols
.next
= objfile
-> global_psymbols
.list
= (struct partial_symbol
*)
588 xmmalloc (objfile
-> md
, objfile
-> global_psymbols
.size
* sizeof (struct partial_symbol
));
589 objfile
-> static_psymbols
.next
= objfile
-> static_psymbols
.list
= (struct partial_symbol
*)
590 xmmalloc (objfile
-> md
, objfile
-> static_psymbols
.size
* sizeof (struct partial_symbol
));
593 /* Given pointers to an a.out symbol table in core containing dbx
594 style data, setup partial_symtab's describing each source file for
595 which debugging information is available.
596 SYMFILE_NAME is the name of the file we are reading from
597 and SECTION_OFFSETS is the set of offsets for the various sections
598 of the file (a set of zeros if the mainline program). */
601 read_os9k_psymtab (section_offsets
, objfile
, text_addr
, text_size
)
602 struct section_offsets
*section_offsets
;
603 struct objfile
*objfile
;
607 register struct internal_symstruct
*bufp
= 0; /* =0 avoids gcc -Wall glitch*/
608 register char *namestring
;
610 int past_first_source_file
= 0;
611 CORE_ADDR last_o_file_start
= 0;
612 struct cleanup
*back_to
;
616 /* End of the text segment of the executable file. */
617 static CORE_ADDR end_of_text_addr
;
619 /* Current partial symtab */
620 static struct partial_symtab
*pst
= 0;
622 /* List of current psymtab's include files */
623 char **psymtab_include_list
;
624 int includes_allocated
;
627 /* Index within current psymtab dependency list */
628 struct partial_symtab
**dependency_list
;
629 int dependencies_used
, dependencies_allocated
;
631 includes_allocated
= 30;
633 psymtab_include_list
= (char **) alloca (includes_allocated
*
636 dependencies_allocated
= 30;
637 dependencies_used
= 0;
639 (struct partial_symtab
**) alloca (dependencies_allocated
*
640 sizeof (struct partial_symtab
*));
642 last_source_file
= NULL
;
644 #ifdef END_OF_TEXT_DEFAULT
645 end_of_text_addr
= END_OF_TEXT_DEFAULT
;
647 end_of_text_addr
= text_addr
+ section_offsets
->offsets
[SECT_OFF_TEXT
]
648 + text_size
; /* Relocate */
651 abfd
= objfile
->obfd
;
655 fread(&dbghdr
.sync
, sizeof(dbghdr
.sync
), 1, fp
);
656 fread(&dbghdr
.rev
, sizeof(dbghdr
.rev
), 1, fp
);
657 fread(&dbghdr
.crc
, sizeof(dbghdr
.crc
), 1, fp
);
658 fread(&dbghdr
.os
, sizeof(dbghdr
.os
), 1, fp
);
659 fread(&dbghdr
.cpu
, sizeof(dbghdr
.cpu
), 1, fp
);
660 SWAP_DBGHDR(&dbghdr
, abfd
);
668 /* Get the symbol for this run and pull out some info */
669 QUIT
; /* allow this to be interruptable */
670 cursymoffset
= ftell(objfile
->auxf2
);
671 ret
= fill_sym(objfile
->auxf2
, abfd
);
676 /* Special case to speed up readin. */
677 if (bufp
->n_type
== (short)N_SYM_SLINE
) continue;
679 #define CUR_SYMBOL_VALUE bufp->n_value
682 switch (bufp
->n_type
)
690 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
691 if (psymfile_depth
== 1 && pst
)
693 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
694 symnum
, CUR_SYMBOL_VALUE
,
695 dependency_list
, dependencies_used
);
696 pst
= (struct partial_symtab
*) 0;
698 dependencies_used
= 0;
703 case N_SYM_SYM
: /* Typedef or automatic variable. */
704 namestring
= bufp
->n_strx
;
705 p
= (char *) strchr (namestring
, ':');
707 continue; /* Not a debugging symbol. */
709 /* Main processing section for debugging symbols which
710 the initial read through the symbol tables needs to worry
711 about. If we reach this point, the symbol which we are
712 considering is definitely one we are interested in.
713 p must also contain the (valid) index into the namestring
714 which indicates the debugging type symbol. */
721 enum language tmp_language
;
725 valu
= CUR_SYMBOL_VALUE
;
727 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
728 past_first_source_file
= 1;
730 p
= strchr(namestring
, ':');
731 if (p
) n
= p
-namestring
;
732 else n
= strlen(namestring
);
734 strncpy(str
, namestring
, n
);
737 if (psymfile_depth
== 0) {
739 pst
= os9k_start_psymtab (objfile
, section_offsets
,
743 objfile
-> global_psymbols
.next
,
744 objfile
-> static_psymbols
.next
);
745 } else { /* this is a include file */
746 tmp_language
= deduce_language_from_filename (str
);
747 if (tmp_language
!= language_unknown
748 && (tmp_language
!= language_c
749 || psymtab_language
!= language_cplus
))
750 psymtab_language
= tmp_language
;
753 if (pst && STREQ (str, pst->filename))
757 for (i = 0; i < includes_used; i++)
758 if (STREQ (str, psymtab_include_list[i]))
768 psymtab_include_list
[includes_used
++] = str
;
769 if (includes_used
>= includes_allocated
)
771 char **orig
= psymtab_include_list
;
773 psymtab_include_list
= (char **)
774 alloca ((includes_allocated
*= 2) * sizeof (char *));
775 memcpy ((PTR
)psymtab_include_list
, (PTR
)orig
,
776 includes_used
* sizeof (char *));
785 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
786 VAR_NAMESPACE
, LOC_STATIC
,
787 objfile
->static_psymbols
,
789 psymtab_language
, objfile
);
792 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
793 VAR_NAMESPACE
, LOC_STATIC
,
794 objfile
->global_psymbols
,
796 psymtab_language
, objfile
);
800 if (p
!= namestring
) /* a name is there, not just :T... */
802 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
803 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
804 objfile
->static_psymbols
,
806 psymtab_language
, objfile
);
809 /* Also a typedef with the same name. */
810 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
811 VAR_NAMESPACE
, LOC_TYPEDEF
,
812 objfile
->static_psymbols
,
813 CUR_SYMBOL_VALUE
, psymtab_language
,
817 /* The semantics of C++ state that "struct foo { ... }"
818 also defines a typedef for "foo". Unfortuantely, cfront
819 never makes the typedef when translating from C++ to C.
820 We make the typedef here so that "ptype foo" works as
821 expected for cfront translated code. */
822 else if (psymtab_language
== language_cplus
)
824 /* Also a typedef with the same name. */
825 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
826 VAR_NAMESPACE
, LOC_TYPEDEF
,
827 objfile
->static_psymbols
,
828 CUR_SYMBOL_VALUE
, psymtab_language
,
834 if (p
!= namestring
) /* a name is there, not just :T... */
836 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
837 VAR_NAMESPACE
, LOC_TYPEDEF
,
838 objfile
->static_psymbols
,
840 psymtab_language
, objfile
);
843 /* If this is an enumerated type, we need to
844 add all the enum constants to the partial symbol
845 table. This does not cover enums without names, e.g.
846 "enum {a, b} c;" in C, but fortunately those are
847 rare. There is no way for GDB to find those from the
848 enum type without spending too much time on it. Thus
849 to solve this problem, the compiler needs to put out the
850 enum in a nameless type. GCC2 does this. */
852 /* We are looking for something of the form
853 <name> ":" ("t" | "T") [<number> "="] "e" <size>
854 {<constant> ":" <value> ","} ";". */
856 /* Skip over the colon and the 't' or 'T'. */
858 /* This type may be given a number. Also, numbers can come
859 in pairs like (0,26). Skip over it. */
860 while ((*p
>= '0' && *p
<= '9')
861 || *p
== '(' || *p
== ',' || *p
== ')'
867 /* We have found an enumerated type. skip size */
868 while (*p
>= '0' && *p
<= '9') p
++;
869 /* According to comments in read_enum_type
870 a comma could end it instead of a semicolon.
871 I don't know where that happens.
873 while (*p
&& *p
!= ';' && *p
!= ',')
877 /* Check for and handle cretinous dbx symbol name
880 p = next_symbol_text ();
883 /* Point to the character after the name
884 of the enum constant. */
885 for (q
= p
; *q
&& *q
!= ':'; q
++)
887 /* Note that the value doesn't matter for
888 enum constants in psymtabs, just in symtabs. */
889 ADD_PSYMBOL_TO_LIST (p
, q
- p
,
890 VAR_NAMESPACE
, LOC_CONST
,
891 objfile
->static_psymbols
, 0,
892 psymtab_language
, objfile
);
893 /* Point past the name. */
895 /* Skip over the value. */
896 while (*p
&& *p
!= ',')
898 /* Advance past the comma. */
905 /* Constant, e.g. from "const" in Pascal. */
906 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
907 VAR_NAMESPACE
, LOC_CONST
,
908 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
909 psymtab_language
, objfile
);
913 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
914 if (pst
&& pst
->textlow
== 0)
915 pst
->textlow
= CUR_SYMBOL_VALUE
;
917 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
918 VAR_NAMESPACE
, LOC_BLOCK
,
919 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
920 psymtab_language
, objfile
);
924 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
925 if (pst
&& pst
->textlow
== 0)
926 pst
->textlow
= CUR_SYMBOL_VALUE
;
928 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
929 VAR_NAMESPACE
, LOC_BLOCK
,
930 objfile
->global_psymbols
, CUR_SYMBOL_VALUE
,
931 psymtab_language
, objfile
);
940 /* It is a C++ nested symbol. We don't need to record it
941 (I don't think); if we try to look up foo::bar::baz,
942 then symbols for the symtab containing foo should get
944 /* Someone says sun cc puts out symbols like
945 /foo/baz/maclib::/usr/local/bin/maclib,
946 which would get here with a symbol type of ':'. */
950 /* Unexpected symbol descriptor. The second and subsequent stabs
951 of a continued stab can show up here. The question is
952 whether they ever can mimic a normal stab--it would be
953 nice if not, since we certainly don't want to spend the
954 time searching to the end of every string looking for
957 complain (&unknown_symchar_complaint
, p
[1]);
962 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
964 HANDLE_RBRAC(CUR_SYMBOL_VALUE
);
971 /* If we haven't found it yet, ignore it. It's probably some
972 new type we don't know about yet. */
973 complain (&unknown_symtype_complaint
,
974 local_hex_string ((unsigned long) bufp
->n_type
));
979 DBX_SYMCOUNT (objfile
) = symnum
;
981 /* If there's stuff to be cleaned up, clean it up. */
982 if (DBX_SYMCOUNT (objfile
) > 0
983 /*FIXME, does this have a bug at start address 0? */
985 && objfile
-> ei
.entry_point
< bufp
->n_value
986 && objfile
-> ei
.entry_point
>= last_o_file_start
)
988 objfile
-> ei
.entry_file_lowpc
= last_o_file_start
;
989 objfile
-> ei
.entry_file_highpc
= bufp
->n_value
;
994 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
995 symnum
, end_of_text_addr
,
996 dependency_list
, dependencies_used
);
999 do_cleanups (back_to);
1003 /* Allocate and partially fill a partial symtab. It will be
1004 completely filled at the end of the symbol list.
1006 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
1007 is the address relative to which its symbols are (incremental) or 0
1011 static struct partial_symtab
*
1012 os9k_start_psymtab (objfile
, section_offsets
,
1013 filename
, textlow
, ldsymoff
,ldsymcnt
, global_syms
, static_syms
)
1014 struct objfile
*objfile
;
1015 struct section_offsets
*section_offsets
;
1020 struct partial_symbol
*global_syms
;
1021 struct partial_symbol
*static_syms
;
1023 struct partial_symtab
*result
=
1024 start_psymtab_common(objfile
, section_offsets
,
1025 filename
, textlow
, global_syms
, static_syms
);
1027 result
->read_symtab_private
= (char *)
1028 obstack_alloc (&objfile
-> psymbol_obstack
, sizeof (struct symloc
));
1030 LDSYMOFF(result
) = ldsymoff
;
1031 LDSYMCNT(result
) = ldsymcnt
;
1032 result
->read_symtab
= os9k_psymtab_to_symtab
;
1034 /* Deduce the source language from the filename for this psymtab. */
1035 psymtab_language
= deduce_language_from_filename (filename
);
1039 /* Close off the current usage of PST.
1040 Returns PST or NULL if the partial symtab was empty and thrown away.
1041 FIXME: List variables and peculiarities of same. */
1043 static struct partial_symtab
*
1044 os9k_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_cnt
,
1045 capping_text
, dependency_list
, number_dependencies
)
1046 struct partial_symtab
*pst
;
1047 char **include_list
;
1049 int capping_symbol_cnt
;
1050 CORE_ADDR capping_text
;
1051 struct partial_symtab
**dependency_list
;
1052 int number_dependencies
;
1053 /* struct partial_symbol *capping_global, *capping_static;*/
1056 struct partial_symtab
*p1
;
1057 struct objfile
*objfile
= pst
-> objfile
;
1059 if (capping_symbol_cnt
!= -1)
1060 LDSYMCNT(pst
) = capping_symbol_cnt
- LDSYMCNT(pst
);
1062 /* Under Solaris, the N_SO symbols always have a value of 0,
1063 instead of the usual address of the .o file. Therefore,
1064 we have to do some tricks to fill in texthigh and textlow.
1065 The first trick is in partial-stab.h: if we see a static
1066 or global function, and the textlow for the current pst
1067 is still 0, then we use that function's address for
1068 the textlow of the pst.
1070 Now, to fill in texthigh, we remember the last function seen
1071 in the .o file (also in partial-stab.h). Also, there's a hack in
1072 bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
1073 to here via the misc_info field. Therefore, we can fill in
1074 a reliable texthigh by taking the address plus size of the
1075 last function in the file.
1077 Unfortunately, that does not cover the case where the last function
1078 in the file is static. See the paragraph below for more comments
1081 Finally, if we have a valid textlow for the current file, we run
1082 down the partial_symtab_list filling in previous texthighs that
1083 are still unknown. */
1085 if (pst
->texthigh
== 0 && last_function_name
) {
1088 struct minimal_symbol
*minsym
;
1090 p
= strchr (last_function_name
, ':');
1092 p
= last_function_name
;
1093 n
= p
- last_function_name
;
1095 strncpy (p
, last_function_name
, n
);
1098 minsym
= lookup_minimal_symbol (p
, objfile
);
1101 pst
->texthigh
= SYMBOL_VALUE_ADDRESS(minsym
)+(long)MSYMBOL_INFO(minsym
);
1103 /* This file ends with a static function, and it's
1104 difficult to imagine how hard it would be to track down
1105 the elf symbol. Luckily, most of the time no one will notice,
1106 since the next file will likely be compiled with -g, so
1107 the code below will copy the first fuction's start address
1108 back to our texthigh variable. (Also, if this file is the
1109 last one in a dynamically linked program, texthigh already
1110 has the right value.) If the next file isn't compiled
1111 with -g, then the last function in this file winds up owning
1112 all of the text space up to the next -g file, or the end (minus
1113 shared libraries). This only matters for single stepping,
1114 and even then it will still work, except that it will single
1115 step through all of the covered functions, instead of setting
1116 breakpoints around them as it usualy does. This makes it
1117 pretty slow, but at least it doesn't fail.
1119 We can fix this with a fairly big change to bfd, but we need
1120 to coordinate better with Cygnus if we want to do that. FIXME. */
1122 last_function_name
= NULL
;
1125 /* this test will be true if the last .o file is only data */
1126 if (pst
->textlow
== 0)
1127 pst
->textlow
= pst
->texthigh
;
1129 /* If we know our own starting text address, then walk through all other
1130 psymtabs for this objfile, and if any didn't know their ending text
1131 address, set it to our starting address. Take care to not set our
1132 own ending address to our starting address, nor to set addresses on
1133 `dependency' files that have both textlow and texthigh zero. */
1135 ALL_OBJFILE_PSYMTABS (objfile
, p1
) {
1136 if (p1
->texthigh
== 0 && p1
->textlow
!= 0 && p1
!= pst
) {
1137 p1
->texthigh
= pst
->textlow
;
1138 /* if this file has only data, then make textlow match texthigh */
1139 if (p1
->textlow
== 0)
1140 p1
->textlow
= p1
->texthigh
;
1145 /* End of kludge for patching Solaris textlow and texthigh. */
1147 pst
->n_global_syms
=
1148 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
1149 pst
->n_static_syms
=
1150 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
1152 pst
->number_of_dependencies
= number_dependencies
;
1153 if (number_dependencies
)
1155 pst
->dependencies
= (struct partial_symtab
**)
1156 obstack_alloc (&objfile
->psymbol_obstack
,
1157 number_dependencies
* sizeof (struct partial_symtab
*));
1158 memcpy (pst
->dependencies
, dependency_list
,
1159 number_dependencies
* sizeof (struct partial_symtab
*));
1162 pst
->dependencies
= 0;
1164 for (i
= 0; i
< num_includes
; i
++)
1166 struct partial_symtab
*subpst
=
1167 allocate_psymtab (include_list
[i
], objfile
);
1169 subpst
->section_offsets
= pst
->section_offsets
;
1170 subpst
->read_symtab_private
=
1171 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
1172 sizeof (struct symloc
));
1176 subpst
->texthigh
= 0;
1178 /* We could save slight bits of space by only making one of these,
1179 shared by the entire set of include files. FIXME-someday. */
1180 subpst
->dependencies
= (struct partial_symtab
**)
1181 obstack_alloc (&objfile
->psymbol_obstack
,
1182 sizeof (struct partial_symtab
*));
1183 subpst
->dependencies
[0] = pst
;
1184 subpst
->number_of_dependencies
= 1;
1186 subpst
->globals_offset
=
1187 subpst
->n_global_syms
=
1188 subpst
->statics_offset
=
1189 subpst
->n_static_syms
= 0;
1193 subpst
->read_symtab
= pst
->read_symtab
;
1196 sort_pst_symbols (pst
);
1198 /* If there is already a psymtab or symtab for a file of this name,
1200 (If there is a symtab, more drastic things also happen.)
1201 This happens in VxWorks. */
1202 free_named_symtabs (pst
->filename
);
1204 if (num_includes
== 0
1205 && number_dependencies
== 0
1206 && pst
->n_global_syms
== 0
1207 && pst
->n_static_syms
== 0) {
1208 /* Throw away this psymtab, it's empty. We can't deallocate it, since
1209 it is on the obstack, but we can forget to chain it on the list. */
1210 struct partial_symtab
*prev_pst
;
1212 /* First, snip it out of the psymtab chain */
1214 if (pst
->objfile
->psymtabs
== pst
)
1215 pst
->objfile
->psymtabs
= pst
->next
;
1217 for (prev_pst
= pst
->objfile
->psymtabs
; prev_pst
; prev_pst
= pst
->next
)
1218 if (prev_pst
->next
== pst
)
1219 prev_pst
->next
= pst
->next
;
1221 /* Next, put it on a free list for recycling */
1222 pst
->next
= pst
->objfile
->free_psymtabs
;
1223 pst
->objfile
->free_psymtabs
= pst
;
1225 /* Indicate that psymtab was thrown away. */
1226 pst
= (struct partial_symtab
*)NULL
;
1232 os9k_psymtab_to_symtab_1 (pst
)
1233 struct partial_symtab
*pst
;
1235 struct cleanup
*old_chain
;
1243 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1248 /* Read in all partial symtabs on which this one is dependent */
1249 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
1250 if (!pst
->dependencies
[i
]->readin
)
1252 /* Inform about additional files that need to be read in. */
1255 fputs_filtered (" ", gdb_stdout
);
1257 fputs_filtered ("and ", gdb_stdout
);
1259 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
1260 wrap_here (""); /* Flush output */
1261 gdb_flush (gdb_stdout
);
1263 os9k_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
1266 if (LDSYMCNT(pst
)) /* Otherwise it's a dummy */
1268 /* Init stuff necessary for reading in symbols */
1271 old_chain
= make_cleanup (really_free_pendings
, 0);
1273 /* Read in this file's symbols */
1274 os9k_read_ofile_symtab (pst
);
1275 sort_symtab_syms (pst
->symtab
);
1276 do_cleanups (old_chain
);
1282 /* Read in all of the symbols for a given psymtab for real.
1283 Be verbose about it if the user wants that. */
1286 os9k_psymtab_to_symtab (pst
)
1287 struct partial_symtab
*pst
;
1296 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1301 if (LDSYMCNT(pst
) || pst
->number_of_dependencies
)
1303 /* Print the message now, before reading the string table,
1304 to avoid disconcerting pauses. */
1307 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
1308 gdb_flush (gdb_stdout
);
1311 sym_bfd
= pst
->objfile
->obfd
;
1312 os9k_psymtab_to_symtab_1 (pst
);
1314 /* Match with global symbols. This only needs to be done once,
1315 after all of the symtabs and dependencies have been read in. */
1316 scan_file_globals (pst
->objfile
);
1318 /* Finish up the debug error message. */
1320 printf_filtered ("done.\n");
1324 /* Read in a defined section of a specific object file's symbols. */
1326 os9k_read_ofile_symtab (pst
)
1327 struct partial_symtab
*pst
;
1329 register struct internal_symstruct
*bufp
;
1331 unsigned max_symnum
;
1333 struct objfile
*objfile
;
1334 int sym_offset
; /* Offset to start of symbols to read */
1335 CORE_ADDR text_offset
; /* Start of text segment for symbols */
1336 int text_size
; /* Size of text segment for symbols */
1337 struct section_offsets
*section_offsets
;
1340 objfile
= pst
->objfile
;
1341 sym_offset
= LDSYMOFF(pst
);
1342 max_symnum
= LDSYMCNT(pst
);
1343 text_offset
= pst
->textlow
;
1344 text_size
= pst
->texthigh
- pst
->textlow
;
1345 section_offsets
= pst
->section_offsets
;
1347 current_objfile
= objfile
;
1348 subfile_stack
= NULL
;
1349 last_source_file
= NULL
;
1351 abfd
= objfile
->obfd
;
1352 dbg_file
= objfile
->auxf2
;
1355 /* It is necessary to actually read one symbol *before* the start
1356 of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1357 occurs before the N_SO symbol.
1358 Detecting this in read_dbx_symtab
1359 would slow down initial readin, so we look for it here instead. */
1360 if (!processing_acc_compilation
&& sym_offset
>= (int)symbol_size
)
1362 fseek (objefile
->auxf2
, sym_offset
, SEEK_CUR
);
1363 fill_sym(objfile
->auxf2
, abfd
);
1366 processing_gcc_compilation
= 0;
1367 if (bufp
->n_type
== N_TEXT
)
1369 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1370 processing_gcc_compilation
= 1;
1371 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1372 processing_gcc_compilation
= 2;
1375 /* Try to select a C++ demangling based on the compilation unit
1378 if (processing_gcc_compilation
)
1380 if (AUTO_DEMANGLING
)
1382 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1388 /* The N_SO starting this symtab is the first symbol, so we
1389 better not check the symbol before it. I'm not this can
1390 happen, but it doesn't hurt to check for it. */
1391 bfd_seek (symfile_bfd
, sym_offset
, SEEK_CUR
);
1392 processing_gcc_compilation
= 0;
1396 fseek(dbg_file
, (long)sym_offset
, 0);
1398 if (bufp->n_type != (unsigned char)N_SYM_SYM)
1399 error("First symbol in segment of executable not a source symbol");
1402 for (symnum
= 0; symnum
< max_symnum
; symnum
++)
1404 QUIT
; /* Allow this to be interruptable */
1405 fill_sym(dbg_file
, abfd
);
1407 type
= bufp
->n_type
;
1409 os9k_process_one_symbol ((int)type
, (int)bufp
->n_desc
,
1410 (CORE_ADDR
)bufp
->n_value
, bufp
->n_strx
, section_offsets
, objfile
);
1412 /* We skip checking for a new .o or -l file; that should never
1413 happen in this routine. */
1415 else if (type
== N_TEXT
)
1417 /* I don't think this code will ever be executed, because
1418 the GCC_COMPILED_FLAG_SYMBOL usually is right before
1419 the N_SO symbol which starts this source file.
1420 However, there is no reason not to accept
1421 the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1423 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1424 processing_gcc_compilation
= 1;
1425 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1426 processing_gcc_compilation
= 2;
1428 if (AUTO_DEMANGLING
)
1430 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1433 else if (type
& N_EXT
|| type
== (unsigned char)N_TEXT
1434 || type
== (unsigned char)N_NBTEXT
1436 /* Global symbol: see if we came across a dbx defintion for
1437 a corresponding symbol. If so, store the value. Remove
1438 syms from the chain when their values are stored, but
1439 search the whole chain, as there may be several syms from
1440 different files with the same name. */
1441 /* This is probably not true. Since the files will be read
1442 in one at a time, each reference to a global symbol will
1443 be satisfied in each file as it appears. So we skip this
1450 current_objfile
= NULL
;
1452 /* In a Solaris elf file, this variable, which comes from the
1453 value of the N_SO symbol, will still be 0. Luckily, text_offset,
1454 which comes from pst->textlow is correct. */
1455 if (last_source_start_addr
== 0)
1456 last_source_start_addr
= text_offset
;
1457 pst
->symtab
= end_symtab (text_offset
+ text_size
, 0, 0, objfile
,
1463 /* This handles a single symbol from the symbol-file, building symbols
1464 into a GDB symtab. It takes these arguments and an implicit argument.
1466 TYPE is the type field of the ".stab" symbol entry.
1467 DESC is the desc field of the ".stab" entry.
1468 VALU is the value field of the ".stab" entry.
1469 NAME is the symbol name, in our address space.
1470 SECTION_OFFSETS is a set of amounts by which the sections of this object
1471 file were relocated when it was loaded into memory.
1472 All symbols that refer
1473 to memory locations need to be offset by these amounts.
1474 OBJFILE is the object file from which we are reading symbols.
1475 It is used in end_symtab. */
1478 os9k_process_one_symbol (type
, desc
, valu
, name
, section_offsets
, objfile
)
1482 struct section_offsets
*section_offsets
;
1483 struct objfile
*objfile
;
1485 register struct context_stack
*new;
1486 /* The stab type used for the definition of the last function.
1487 N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
1488 static int function_stab_type
= 0;
1491 /* Something is wrong if we see real data before
1492 seeing a source file name. */
1493 if (last_source_file
== NULL
&& type
!= (unsigned char)N_SO
)
1495 /* Ignore any symbols which appear before an N_SO symbol. Currently
1496 no one puts symbols there, but we should deal gracefully with the
1497 case. A complain()t might be in order (if !IGNORE_SYMBOL (type)),
1498 but this should not be an error (). */
1506 /* On most machines, the block addresses are relative to the
1507 N_SO, the linker did not relocate them (sigh). */
1508 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1509 new = push_context (desc
, valu
);
1513 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1514 new = pop_context();
1516 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
1517 #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
1520 if (!OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1521 local_symbols
= new->locals
;
1523 if (context_stack_depth
> 1)
1525 /* This is not the outermost LBRAC...RBRAC pair in the function,
1526 its local symbols preceded it, and are the ones just recovered
1527 from the context stack. Define the block for them (but don't
1528 bother if the block contains no symbols. Should we complain
1529 on blocks without symbols? I can't think of any useful purpose
1531 if (local_symbols
!= NULL
)
1533 /* Muzzle a compiler bug that makes end < start. (which
1534 compilers? Is this ever harmful?). */
1535 if (new->start_addr
> valu
)
1537 complain (&lbrac_rbrac_complaint
);
1538 new->start_addr
= valu
;
1540 /* Make a block for the local symbols within. */
1541 finish_block (0, &local_symbols
, new->old_blocks
,
1542 new->start_addr
, valu
, objfile
);
1547 if (context_stack_depth
== 0)
1549 within_function
= 0;
1550 /* Make a block for the local symbols within. */
1551 finish_block (new->name
, &local_symbols
, new->old_blocks
,
1552 new->start_addr
, valu
, objfile
);
1556 /* attach local_symbols to the end of new->locals */
1557 if (!new->locals
) new->locals
= local_symbols
;
1562 while (p
->next
) p
= p
->next
;
1563 p
->next
= local_symbols
;
1568 if (OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1569 /* Now pop locals of block just finished. */
1570 local_symbols
= new->locals
;
1575 /* This type of "symbol" really just records
1576 one line-number -- core-address correspondence.
1577 Enter it in the line list for this symbol table. */
1578 /* Relocate for dynamic loading and for ELF acc fn-relative syms. */
1579 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1580 record_line (current_subfile
, (int)name
, valu
);
1583 /* The following symbol types need to have the appropriate offset added
1584 to their value; then we process symbol definitions in the name. */
1591 char *p
= strchr (name
, ':');
1601 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1602 n
= strrchr(name
, '/');
1612 if (symfile_depth
++ == 0) {
1613 if (last_source_file
) {
1614 end_symtab (valu
, 0, 0, objfile
, SECT_OFF_TEXT
);
1619 start_symtab (n
, dirn
, valu
);
1622 start_subfile (n
, dirn
!=NULL
? dirn
: current_subfile
->dirname
);
1628 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1629 function_stab_type
= type
;
1631 within_function
= 1;
1632 new = push_context (0, valu
);
1633 new->name
= define_symbol (valu
, name
, desc
, type
, objfile
);
1638 valu
+= ANOFFSET (section_offsets
, SECT_OFF_DATA
);
1639 define_symbol (valu
, name
, desc
, type
, objfile
);
1643 define_symbol (valu
, name
, desc
, type
, objfile
);
1650 if (--symfile_depth
!= 0)
1651 start_subfile(pop_subfile(), current_subfile
->dirname
);
1655 complain (&unknown_symtype_complaint
,
1656 local_hex_string((unsigned long) type
));
1663 previous_stab_code
= type
;
1666 /* Parse the user's idea of an offset for dynamic linking, into our idea
1667 of how to represent it for fast symbol reading. */
1669 static struct section_offsets
*
1670 os9k_symfile_offsets (objfile
, addr
)
1671 struct objfile
*objfile
;
1674 struct section_offsets
*section_offsets
;
1677 objfile
->num_sections
= SECT_OFF_MAX
;
1678 section_offsets
= (struct section_offsets
*)
1679 obstack_alloc (&objfile
-> psymbol_obstack
,
1680 sizeof (struct section_offsets
)
1681 + sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
1683 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
1684 ANOFFSET (section_offsets
, i
) = addr
;
1686 return section_offsets
;
1689 static struct sym_fns os9k_sym_fns
=
1691 bfd_target_os9k_flavour
,
1692 os9k_new_init
, /* sym_new_init: init anything gbl to entire symtab */
1693 os9k_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
1694 os9k_symfile_read
, /* sym_read: read a symbol file into symtab */
1695 os9k_symfile_finish
, /* sym_finish: finished with file, cleanup */
1696 os9k_symfile_offsets
, /* sym_offsets: parse user's offsets to internal form*/
1697 NULL
/* next: pointer to next struct sym_fns */
1701 _initialize_os9kread ()
1703 add_symtab_fns(&os9k_sym_fns
);