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 "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
60 #include "gdb-stabs.h"
62 #include "language.h" /* Needed inside partial-stab.h */
63 #include "complaints.h"
65 #include "stabsread.h"
67 #if !defined (SEEK_SET)
72 /* Each partial symbol table entry contains a pointer to private data for the
73 read_symtab() function to use when expanding a partial symbol table entry
74 to a full symbol table entry.
76 For dbxread this structure contains the offset within the file symbol table
77 of first local symbol for this file, and count of the section
78 of the symbol table devoted to this file's symbols (actually, the section
79 bracketed may contain more than just this file's symbols). It also contains
80 further information needed to locate the symbols if they are in an ELF file.
82 If ldsymcnt is 0, the only reason for this thing's existence is the
83 dependency list. Nothing else will happen when it is read in. */
85 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
86 #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum)
93 /* Remember what we deduced to be the source language of this psymtab. */
94 static enum language psymtab_language
= language_unknown
;
96 /* keep partial symbol table file nested depth */
97 static int psymfile_depth
= 0;
99 /* keep symbol table file nested depth */
100 static int symfile_depth
= 0;
102 /* Nonzero means give verbose info on gdb action. From main.c. */
103 extern int info_verbose
;
105 extern int previous_stab_code
;
107 /* Name of last function encountered. Used in Solaris to approximate
108 object file boundaries. */
109 static char *last_function_name
;
111 /* Complaints about the symbols we have encountered. */
112 extern struct complaint lbrac_complaint
;
114 extern struct complaint unknown_symtype_complaint
;
116 extern struct complaint unknown_symchar_complaint
;
118 extern struct complaint lbrac_rbrac_complaint
;
120 extern struct complaint repeated_header_complaint
;
122 extern struct complaint repeated_header_name_complaint
;
125 static struct complaint lbrac_unmatched_complaint
=
126 {"unmatched Increment Block Entry before symtab pos %d", 0, 0};
128 static struct complaint lbrac_mismatch_complaint
=
129 {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0};
132 /* Local function prototypes */
134 os9k_read_ofile_symtab
PARAMS ((struct partial_symtab
*));
137 os9k_psymtab_to_symtab
PARAMS ((struct partial_symtab
*));
140 os9k_psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*));
143 read_os9k_psymtab
PARAMS ((struct section_offsets
*, struct objfile
*,
147 fill_sym
PARAMS ((FILE *, bfd
*));
150 os9k_symfile_init
PARAMS ((struct objfile
*));
153 os9k_new_init
PARAMS ((struct objfile
*));
156 os9k_symfile_read
PARAMS ((struct objfile
*, struct section_offsets
*, int));
159 os9k_symfile_finish
PARAMS ((struct objfile
*));
162 os9k_process_one_symbol
PARAMS ((int, int, CORE_ADDR
, char *,
163 struct section_offsets
*, struct objfile
*));
165 static struct partial_symtab
*
166 os9k_start_psymtab
PARAMS ((struct objfile
*, struct section_offsets
*, char *,
167 CORE_ADDR
, int, int, struct partial_symbol
*,
168 struct partial_symbol
*));
170 static struct partial_symtab
*
171 os9k_end_psymtab
PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
172 struct partial_symtab
**, int));
175 record_minimal_symbol
PARAMS ((char *, CORE_ADDR
, int, struct objfile
*,
176 struct section_offsets
*));
178 #define HANDLE_RBRAC(val) \
179 if ((val) > pst->texthigh) pst->texthigh = (val);
181 #define SWAP_STBHDR(hdrp, abfd) \
183 (hdrp)->fmtno = bfd_get_16(abfd, (unsigned char *)&(hdrp)->fmtno); \
184 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
185 (hdrp)->offset = bfd_get_32(abfd, (unsigned char *)&(hdrp)->offset); \
186 (hdrp)->nsym = bfd_get_32(abfd, (unsigned char *)&(hdrp)->nsym); \
188 #define SWAP_STBSYM(symp, abfd) \
190 (symp)->value = bfd_get_32(abfd, (unsigned char *)&(symp)->value); \
191 (symp)->type = bfd_get_16(abfd, (unsigned char *)&(symp)->type); \
192 (symp)->stroff = bfd_get_32(abfd, (unsigned char *)&(symp)->stroff); \
202 record_minimal_symbol (name
, address
, type
, objfile
, section_offsets
)
206 struct objfile
*objfile
;
207 struct section_offsets
*section_offsets
;
209 enum minimal_symbol_type ms_type
;
215 address
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
233 ms_type
= mst_unknown
; break;
236 prim_record_minimal_symbol
237 (obsavestring (name
, strlen(name
), &objfile
->symbol_obstack
),
238 address
, ms_type
, objfile
);
241 /* read and process .stb file and store in minimal symbol table */
242 typedef char mhhdr
[80];
257 #define STBSYMSIZE 10
260 read_minimal_symbols(objfile
, section_offsets
)
261 struct objfile
*objfile
;
262 struct section_offsets
*section_offsets
;
267 struct stbsymbol sym
;
269 char buf
[64], buf1
[128];
272 if (fp
== NULL
) return;
273 abfd
= objfile
->obfd
;
274 fread(&hdr
.comhdr
[0], sizeof(mhhdr
), 1, fp
);
283 if (i
%2) ch
=getc(fp
);
286 fread(&hdr
.fmtno
, sizeof(hdr
.fmtno
), 1, fp
);
287 fread(&hdr
.crc
, sizeof(hdr
.crc
), 1, fp
);
288 fread(&hdr
.offset
, sizeof(hdr
.offset
), 1, fp
);
289 fread(&hdr
.nsym
, sizeof(hdr
.nsym
), 1, fp
);
290 SWAP_STBHDR(&hdr
, abfd
);
293 init_minimal_symbol_collection();
295 for (i
= hdr
.nsym
; i
> 0; i
--) {
296 fseek(fp
, (long)off
, 0);
297 fread(&sym
.value
, sizeof(sym
.value
), 1, fp
);
298 fread(&sym
.type
, sizeof(sym
.type
), 1, fp
);
299 fread(&sym
.stroff
, sizeof(sym
.stroff
), 1, fp
);
300 SWAP_STBSYM (&sym
, abfd
);
301 fseek(fp
, (long)sym
.stroff
, 0);
310 record_minimal_symbol(buf1
, sym
.value
, sym
.type
&7, objfile
, section_offsets
);
313 install_minimal_symbols (objfile
);
317 /* Scan and build partial symbols for a symbol file.
318 We have been initialized by a call to os9k_symfile_init, which
319 put all the relevant info into a "struct os9k_symfile_info",
320 hung off the objfile structure.
322 SECTION_OFFSETS contains offsets relative to which the symbols in the
323 various sections are (depending where the sections were actually loaded).
324 MAINLINE is true if we are reading the main symbol
325 table (as opposed to a shared lib or dynamically loaded file). */
328 os9k_symfile_read (objfile
, section_offsets
, mainline
)
329 struct objfile
*objfile
;
330 struct section_offsets
*section_offsets
;
331 int mainline
; /* FIXME comments above */
334 struct cleanup
*back_to
;
336 sym_bfd
= objfile
->obfd
;
337 /* If we are reinitializing, or if we have never loaded syms yet, init */
338 if (mainline
|| objfile
->global_psymbols
.size
== 0 ||
339 objfile
->static_psymbols
.size
== 0)
340 init_psymbol_list (objfile
, DBX_SYMCOUNT (objfile
));
343 back_to
= make_cleanup (really_free_pendings
, 0);
345 make_cleanup (discard_minimal_symbols
, 0);
346 read_minimal_symbols (objfile
, section_offsets
);
348 /* Now that the symbol table data of the executable file are all in core,
349 process them and define symbols accordingly. */
350 read_os9k_psymtab (section_offsets
, objfile
,
351 bfd_section_vma (sym_bfd
, DBX_TEXT_SECT (objfile
)),
352 bfd_section_size (sym_bfd
, DBX_TEXT_SECT (objfile
)));
354 do_cleanups (back_to
);
357 /* Initialize anything that needs initializing when a completely new
358 symbol file is specified (not just adding some symbols from another
359 file, e.g. a shared library). */
362 os9k_new_init (ignore
)
363 struct objfile
*ignore
;
365 stabsread_new_init ();
366 buildsym_new_init ();
369 init_header_files ();
373 /* os9k_symfile_init ()
374 It is passed a struct objfile which contains, among other things,
375 the BFD for the file whose symbols are being read, and a slot for a pointer
376 to "private data" which we fill with goodies.
378 Since BFD doesn't know how to read debug symbols in a format-independent
379 way (and may never do so...), we have to do it ourselves. We will never
380 be called unless this is an a.out (or very similar) file.
381 FIXME, there should be a cleaner peephole into the BFD environment here. */
384 os9k_symfile_init (objfile
)
385 struct objfile
*objfile
;
387 bfd
*sym_bfd
= objfile
->obfd
;
388 char *name
= bfd_get_filename (sym_bfd
);
389 char dbgname
[512], stbname
[512];
394 strcpy(dbgname
, name
);
395 strcat(dbgname
, ".dbg");
396 strcpy(stbname
, name
);
397 strcat(stbname
, ".stb");
399 if ((symfile
= fopen(dbgname
, "r")) == NULL
) {
400 warning("Symbol file %s not found", dbgname
);
402 objfile
->auxf2
= symfile
;
404 if ((minfile
= fopen(stbname
, "r")) == NULL
) {
405 warning("Symbol file %s not found", stbname
);
407 objfile
->auxf1
= minfile
;
409 /* Allocate struct to keep track of the symfile */
410 objfile
->sym_stab_info
= (PTR
)
411 xmmalloc (objfile
-> md
, sizeof (struct dbx_symfile_info
));
412 DBX_SYMFILE_INFO (objfile
)->stab_section_info
= NULL
;
414 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
415 if (!DBX_TEXT_SECT (objfile
))
416 error ("Can't find .text section in file");
418 DBX_SYMBOL_SIZE (objfile
) = 0; /* variable size symbol */
419 DBX_SYMCOUNT (objfile
) = 0; /* used to be bfd_get_symcount(sym_bfd) */
420 DBX_SYMTAB_OFFSET (objfile
) = 0; /* used to be SYMBOL_TABLE_OFFSET */
423 /* Perform any local cleanups required when we are done with a particular
424 objfile. I.E, we are in the process of discarding all symbol information
425 for an objfile, freeing up all memory held for it, and unlinking the
426 objfile struct from the global list of known objfiles. */
429 os9k_symfile_finish (objfile
)
430 struct objfile
*objfile
;
432 if (objfile
->sym_stab_info
!= NULL
)
434 mfree (objfile
-> md
, objfile
->sym_stab_info
);
437 free_header_files ();
449 #define SYNC (int)0xefbefeca
451 #define SWAP_DBGHDR(hdrp, abfd) \
453 (hdrp)->sync = bfd_get_32(abfd, (unsigned char *)&(hdrp)->sync); \
454 (hdrp)->rev = bfd_get_16(abfd, (unsigned char *)&(hdrp)->rev); \
455 (hdrp)->crc = bfd_get_32(abfd, (unsigned char *)&(hdrp)->crc); \
456 (hdrp)->os = bfd_get_16(abfd, (unsigned char *)&(hdrp)->os); \
457 (hdrp)->cpu = bfd_get_16(abfd, (unsigned char *)&(hdrp)->cpu); \
460 #define N_SYM_CMPLR 0
461 #define N_SYM_SLINE 1
463 #define N_SYM_LBRAC 3
464 #define N_SYM_RBRAC 4
467 struct internal_symstruct
{
473 static struct internal_symstruct symbol
;
474 static struct internal_symstruct
*symbuf
= &symbol
;
475 static char strbuf
[4096];
476 static struct st_dbghdr dbghdr
;
477 static short cmplrid
;
479 #define VER_PRE_ULTRAC ((short)4)
480 #define VER_ULTRAC ((short)5)
483 fill_sym (dbg_file
, abfd
)
492 int nbytes
= fread(&si
, sizeof(si
), 1, dbg_file
);
496 perror_with_name ("reading .dbg file.");
499 symbuf
->n_strx
= NULL
;
500 symbuf
->n_type
= bfd_get_16 (abfd
, (unsigned char *)&si
);
501 symbuf
->n_type
= 0xf & symbuf
->n_type
;
502 switch (symbuf
->n_type
)
505 fread(&si
, sizeof(si
), 1, dbg_file
);
506 symbuf
->n_desc
= bfd_get_16(abfd
, (unsigned char *)&si
);
507 cmplrid
= symbuf
->n_desc
& 0xff;
510 fread(&li
, sizeof(li
), 1, dbg_file
);
511 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
512 fread(&li
, sizeof(li
), 1, dbg_file
);
513 li
= bfd_get_32(abfd
, (unsigned char *)&li
);
514 symbuf
->n_strx
= (char *)(li
>> 12);
515 symbuf
->n_desc
= li
& 0xfff;
518 fread(&li
, sizeof(li
), 1, dbg_file
);
519 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
523 strbuf
[si
++] = (char) ii
;
524 } while (ii
!= 0 || si
% 2 != 0);
525 symbuf
->n_strx
= strbuf
;
526 p
= (char *) strchr (strbuf
, ':');
528 if ((p
[1] == 'F' || p
[1] == 'f') && cmplrid
== VER_PRE_ULTRAC
)
530 fread(&si
, sizeof(si
), 1, dbg_file
);
531 nmask
= bfd_get_16(abfd
, (unsigned char *)&si
);
532 for (ii
=0; ii
<nmask
; ii
++)
533 fread(&si
, sizeof(si
), 1, dbg_file
);
537 fread(&li
, sizeof(li
), 1, dbg_file
);
538 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
541 fread(&li
, sizeof(li
), 1, dbg_file
);
542 symbuf
->n_value
= bfd_get_32(abfd
, (unsigned char *)&li
);
550 /* Given pointers to an a.out symbol table in core containing dbx
551 style data, setup partial_symtab's describing each source file for
552 which debugging information is available.
553 SYMFILE_NAME is the name of the file we are reading from
554 and SECTION_OFFSETS is the set of offsets for the various sections
555 of the file (a set of zeros if the mainline program). */
558 read_os9k_psymtab (section_offsets
, objfile
, text_addr
, text_size
)
559 struct section_offsets
*section_offsets
;
560 struct objfile
*objfile
;
564 register struct internal_symstruct
*bufp
= 0; /* =0 avoids gcc -Wall glitch*/
565 register char *namestring
;
566 int past_first_source_file
= 0;
567 CORE_ADDR last_o_file_start
= 0;
569 struct cleanup
*back_to
;
574 /* End of the text segment of the executable file. */
575 static CORE_ADDR end_of_text_addr
;
577 /* Current partial symtab */
578 static struct partial_symtab
*pst
= 0;
580 /* List of current psymtab's include files */
581 char **psymtab_include_list
;
582 int includes_allocated
;
585 /* Index within current psymtab dependency list */
586 struct partial_symtab
**dependency_list
;
587 int dependencies_used
, dependencies_allocated
;
589 includes_allocated
= 30;
591 psymtab_include_list
= (char **) alloca (includes_allocated
*
594 dependencies_allocated
= 30;
595 dependencies_used
= 0;
597 (struct partial_symtab
**) alloca (dependencies_allocated
*
598 sizeof (struct partial_symtab
*));
600 last_source_file
= NULL
;
602 #ifdef END_OF_TEXT_DEFAULT
603 end_of_text_addr
= END_OF_TEXT_DEFAULT
;
605 end_of_text_addr
= text_addr
+ section_offsets
->offsets
[SECT_OFF_TEXT
]
606 + text_size
; /* Relocate */
609 abfd
= objfile
->obfd
;
613 fread(&dbghdr
.sync
, sizeof(dbghdr
.sync
), 1, fp
);
614 fread(&dbghdr
.rev
, sizeof(dbghdr
.rev
), 1, fp
);
615 fread(&dbghdr
.crc
, sizeof(dbghdr
.crc
), 1, fp
);
616 fread(&dbghdr
.os
, sizeof(dbghdr
.os
), 1, fp
);
617 fread(&dbghdr
.cpu
, sizeof(dbghdr
.cpu
), 1, fp
);
618 SWAP_DBGHDR(&dbghdr
, abfd
);
626 /* Get the symbol for this run and pull out some info */
627 QUIT
; /* allow this to be interruptable */
628 cursymoffset
= ftell(objfile
->auxf2
);
629 ret
= fill_sym(objfile
->auxf2
, abfd
);
634 /* Special case to speed up readin. */
635 if (bufp
->n_type
== (short)N_SYM_SLINE
) continue;
637 #define CUR_SYMBOL_VALUE bufp->n_value
640 switch (bufp
->n_type
)
648 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
649 if (psymfile_depth
== 1 && pst
)
651 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
652 symnum
, CUR_SYMBOL_VALUE
,
653 dependency_list
, dependencies_used
);
654 pst
= (struct partial_symtab
*) 0;
656 dependencies_used
= 0;
661 case N_SYM_SYM
: /* Typedef or automatic variable. */
662 namestring
= bufp
->n_strx
;
663 p
= (char *) strchr (namestring
, ':');
665 continue; /* Not a debugging symbol. */
667 /* Main processing section for debugging symbols which
668 the initial read through the symbol tables needs to worry
669 about. If we reach this point, the symbol which we are
670 considering is definitely one we are interested in.
671 p must also contain the (valid) index into the namestring
672 which indicates the debugging type symbol. */
679 enum language tmp_language
;
683 valu
= CUR_SYMBOL_VALUE
;
685 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
686 past_first_source_file
= 1;
688 p
= strchr(namestring
, ':');
689 if (p
) n
= p
-namestring
;
690 else n
= strlen(namestring
);
692 strncpy(str
, namestring
, n
);
695 if (psymfile_depth
== 0) {
697 pst
= os9k_start_psymtab (objfile
, section_offsets
,
701 objfile
-> global_psymbols
.next
,
702 objfile
-> static_psymbols
.next
);
703 } else { /* this is a include file */
704 tmp_language
= deduce_language_from_filename (str
);
705 if (tmp_language
!= language_unknown
706 && (tmp_language
!= language_c
707 || psymtab_language
!= language_cplus
))
708 psymtab_language
= tmp_language
;
711 if (pst && STREQ (str, pst->filename))
715 for (i = 0; i < includes_used; i++)
716 if (STREQ (str, psymtab_include_list[i]))
726 psymtab_include_list
[includes_used
++] = str
;
727 if (includes_used
>= includes_allocated
)
729 char **orig
= psymtab_include_list
;
731 psymtab_include_list
= (char **)
732 alloca ((includes_allocated
*= 2) * sizeof (char *));
733 memcpy ((PTR
)psymtab_include_list
, (PTR
)orig
,
734 includes_used
* sizeof (char *));
743 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
744 VAR_NAMESPACE
, LOC_STATIC
,
745 objfile
->static_psymbols
,
747 psymtab_language
, objfile
);
750 ADD_PSYMBOL_ADDR_TO_LIST (namestring
, p
- namestring
,
751 VAR_NAMESPACE
, LOC_STATIC
,
752 objfile
->global_psymbols
,
754 psymtab_language
, objfile
);
758 if (p
!= namestring
) /* a name is there, not just :T... */
760 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
761 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
762 objfile
->static_psymbols
,
764 psymtab_language
, objfile
);
767 /* Also a typedef with the same name. */
768 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
769 VAR_NAMESPACE
, LOC_TYPEDEF
,
770 objfile
->static_psymbols
,
771 CUR_SYMBOL_VALUE
, psymtab_language
,
775 /* The semantics of C++ state that "struct foo { ... }"
776 also defines a typedef for "foo". Unfortuantely, cfront
777 never makes the typedef when translating from C++ to C.
778 We make the typedef here so that "ptype foo" works as
779 expected for cfront translated code. */
780 else if (psymtab_language
== language_cplus
)
782 /* Also a typedef with the same name. */
783 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
784 VAR_NAMESPACE
, LOC_TYPEDEF
,
785 objfile
->static_psymbols
,
786 CUR_SYMBOL_VALUE
, psymtab_language
,
792 if (p
!= namestring
) /* a name is there, not just :T... */
794 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
795 VAR_NAMESPACE
, LOC_TYPEDEF
,
796 objfile
->static_psymbols
,
798 psymtab_language
, objfile
);
801 /* If this is an enumerated type, we need to
802 add all the enum constants to the partial symbol
803 table. This does not cover enums without names, e.g.
804 "enum {a, b} c;" in C, but fortunately those are
805 rare. There is no way for GDB to find those from the
806 enum type without spending too much time on it. Thus
807 to solve this problem, the compiler needs to put out the
808 enum in a nameless type. GCC2 does this. */
810 /* We are looking for something of the form
811 <name> ":" ("t" | "T") [<number> "="] "e" <size>
812 {<constant> ":" <value> ","} ";". */
814 /* Skip over the colon and the 't' or 'T'. */
816 /* This type may be given a number. Also, numbers can come
817 in pairs like (0,26). Skip over it. */
818 while ((*p
>= '0' && *p
<= '9')
819 || *p
== '(' || *p
== ',' || *p
== ')'
825 /* We have found an enumerated type. skip size */
826 while (*p
>= '0' && *p
<= '9') p
++;
827 /* According to comments in read_enum_type
828 a comma could end it instead of a semicolon.
829 I don't know where that happens.
831 while (*p
&& *p
!= ';' && *p
!= ',')
835 /* Check for and handle cretinous dbx symbol name
838 p = next_symbol_text ();
841 /* Point to the character after the name
842 of the enum constant. */
843 for (q
= p
; *q
&& *q
!= ':'; q
++)
845 /* Note that the value doesn't matter for
846 enum constants in psymtabs, just in symtabs. */
847 ADD_PSYMBOL_TO_LIST (p
, q
- p
,
848 VAR_NAMESPACE
, LOC_CONST
,
849 objfile
->static_psymbols
, 0,
850 psymtab_language
, objfile
);
851 /* Point past the name. */
853 /* Skip over the value. */
854 while (*p
&& *p
!= ',')
856 /* Advance past the comma. */
863 /* Constant, e.g. from "const" in Pascal. */
864 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
865 VAR_NAMESPACE
, LOC_CONST
,
866 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
867 psymtab_language
, objfile
);
871 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
872 if (pst
&& pst
->textlow
== 0)
873 pst
->textlow
= CUR_SYMBOL_VALUE
;
875 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
876 VAR_NAMESPACE
, LOC_BLOCK
,
877 objfile
->static_psymbols
, CUR_SYMBOL_VALUE
,
878 psymtab_language
, objfile
);
882 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
883 if (pst
&& pst
->textlow
== 0)
884 pst
->textlow
= CUR_SYMBOL_VALUE
;
886 ADD_PSYMBOL_TO_LIST (namestring
, p
- namestring
,
887 VAR_NAMESPACE
, LOC_BLOCK
,
888 objfile
->global_psymbols
, CUR_SYMBOL_VALUE
,
889 psymtab_language
, objfile
);
898 /* It is a C++ nested symbol. We don't need to record it
899 (I don't think); if we try to look up foo::bar::baz,
900 then symbols for the symtab containing foo should get
902 /* Someone says sun cc puts out symbols like
903 /foo/baz/maclib::/usr/local/bin/maclib,
904 which would get here with a symbol type of ':'. */
908 /* Unexpected symbol descriptor. The second and subsequent stabs
909 of a continued stab can show up here. The question is
910 whether they ever can mimic a normal stab--it would be
911 nice if not, since we certainly don't want to spend the
912 time searching to the end of every string looking for
915 complain (&unknown_symchar_complaint
, p
[1]);
920 CUR_SYMBOL_VALUE
+= ANOFFSET(section_offsets
, SECT_OFF_TEXT
);
922 HANDLE_RBRAC(CUR_SYMBOL_VALUE
);
929 /* If we haven't found it yet, ignore it. It's probably some
930 new type we don't know about yet. */
931 complain (&unknown_symtype_complaint
,
932 local_hex_string ((unsigned long) bufp
->n_type
));
937 DBX_SYMCOUNT (objfile
) = symnum
;
939 /* If there's stuff to be cleaned up, clean it up. */
940 if (DBX_SYMCOUNT (objfile
) > 0
941 /*FIXME, does this have a bug at start address 0? */
943 && objfile
-> ei
.entry_point
< bufp
->n_value
944 && objfile
-> ei
.entry_point
>= last_o_file_start
)
946 objfile
-> ei
.entry_file_lowpc
= last_o_file_start
;
947 objfile
-> ei
.entry_file_highpc
= bufp
->n_value
;
952 os9k_end_psymtab (pst
, psymtab_include_list
, includes_used
,
953 symnum
, end_of_text_addr
,
954 dependency_list
, dependencies_used
);
957 do_cleanups (back_to);
961 /* Allocate and partially fill a partial symtab. It will be
962 completely filled at the end of the symbol list.
964 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
965 is the address relative to which its symbols are (incremental) or 0
969 static struct partial_symtab
*
970 os9k_start_psymtab (objfile
, section_offsets
,
971 filename
, textlow
, ldsymoff
,ldsymcnt
, global_syms
, static_syms
)
972 struct objfile
*objfile
;
973 struct section_offsets
*section_offsets
;
978 struct partial_symbol
*global_syms
;
979 struct partial_symbol
*static_syms
;
981 struct partial_symtab
*result
=
982 start_psymtab_common(objfile
, section_offsets
,
983 filename
, textlow
, global_syms
, static_syms
);
985 result
->read_symtab_private
= (char *)
986 obstack_alloc (&objfile
-> psymbol_obstack
, sizeof (struct symloc
));
988 LDSYMOFF(result
) = ldsymoff
;
989 LDSYMCNT(result
) = ldsymcnt
;
990 result
->read_symtab
= os9k_psymtab_to_symtab
;
992 /* Deduce the source language from the filename for this psymtab. */
993 psymtab_language
= deduce_language_from_filename (filename
);
997 /* Close off the current usage of PST.
998 Returns PST or NULL if the partial symtab was empty and thrown away.
999 FIXME: List variables and peculiarities of same. */
1001 static struct partial_symtab
*
1002 os9k_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_cnt
,
1003 capping_text
, dependency_list
, number_dependencies
)
1004 struct partial_symtab
*pst
;
1005 char **include_list
;
1007 int capping_symbol_cnt
;
1008 CORE_ADDR capping_text
;
1009 struct partial_symtab
**dependency_list
;
1010 int number_dependencies
;
1011 /* struct partial_symbol *capping_global, *capping_static;*/
1014 struct partial_symtab
*p1
;
1015 struct objfile
*objfile
= pst
-> objfile
;
1017 if (capping_symbol_cnt
!= -1)
1018 LDSYMCNT(pst
) = capping_symbol_cnt
- LDSYMCNT(pst
);
1020 /* Under Solaris, the N_SO symbols always have a value of 0,
1021 instead of the usual address of the .o file. Therefore,
1022 we have to do some tricks to fill in texthigh and textlow.
1023 The first trick is in partial-stab.h: if we see a static
1024 or global function, and the textlow for the current pst
1025 is still 0, then we use that function's address for
1026 the textlow of the pst.
1028 Now, to fill in texthigh, we remember the last function seen
1029 in the .o file (also in partial-stab.h). Also, there's a hack in
1030 bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
1031 to here via the misc_info field. Therefore, we can fill in
1032 a reliable texthigh by taking the address plus size of the
1033 last function in the file.
1035 Unfortunately, that does not cover the case where the last function
1036 in the file is static. See the paragraph below for more comments
1039 Finally, if we have a valid textlow for the current file, we run
1040 down the partial_symtab_list filling in previous texthighs that
1041 are still unknown. */
1043 if (pst
->texthigh
== 0 && last_function_name
) {
1046 struct minimal_symbol
*minsym
;
1048 p
= strchr (last_function_name
, ':');
1050 p
= last_function_name
;
1051 n
= p
- last_function_name
;
1053 strncpy (p
, last_function_name
, n
);
1056 minsym
= lookup_minimal_symbol (p
, NULL
, objfile
);
1059 pst
->texthigh
= SYMBOL_VALUE_ADDRESS(minsym
)+(long)MSYMBOL_INFO(minsym
);
1061 /* This file ends with a static function, and it's
1062 difficult to imagine how hard it would be to track down
1063 the elf symbol. Luckily, most of the time no one will notice,
1064 since the next file will likely be compiled with -g, so
1065 the code below will copy the first fuction's start address
1066 back to our texthigh variable. (Also, if this file is the
1067 last one in a dynamically linked program, texthigh already
1068 has the right value.) If the next file isn't compiled
1069 with -g, then the last function in this file winds up owning
1070 all of the text space up to the next -g file, or the end (minus
1071 shared libraries). This only matters for single stepping,
1072 and even then it will still work, except that it will single
1073 step through all of the covered functions, instead of setting
1074 breakpoints around them as it usualy does. This makes it
1075 pretty slow, but at least it doesn't fail.
1077 We can fix this with a fairly big change to bfd, but we need
1078 to coordinate better with Cygnus if we want to do that. FIXME. */
1080 last_function_name
= NULL
;
1083 /* this test will be true if the last .o file is only data */
1084 if (pst
->textlow
== 0)
1085 pst
->textlow
= pst
->texthigh
;
1087 /* If we know our own starting text address, then walk through all other
1088 psymtabs for this objfile, and if any didn't know their ending text
1089 address, set it to our starting address. Take care to not set our
1090 own ending address to our starting address, nor to set addresses on
1091 `dependency' files that have both textlow and texthigh zero. */
1093 ALL_OBJFILE_PSYMTABS (objfile
, p1
) {
1094 if (p1
->texthigh
== 0 && p1
->textlow
!= 0 && p1
!= pst
) {
1095 p1
->texthigh
= pst
->textlow
;
1096 /* if this file has only data, then make textlow match texthigh */
1097 if (p1
->textlow
== 0)
1098 p1
->textlow
= p1
->texthigh
;
1103 /* End of kludge for patching Solaris textlow and texthigh. */
1105 pst
->n_global_syms
=
1106 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
1107 pst
->n_static_syms
=
1108 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
1110 pst
->number_of_dependencies
= number_dependencies
;
1111 if (number_dependencies
)
1113 pst
->dependencies
= (struct partial_symtab
**)
1114 obstack_alloc (&objfile
->psymbol_obstack
,
1115 number_dependencies
* sizeof (struct partial_symtab
*));
1116 memcpy (pst
->dependencies
, dependency_list
,
1117 number_dependencies
* sizeof (struct partial_symtab
*));
1120 pst
->dependencies
= 0;
1122 for (i
= 0; i
< num_includes
; i
++)
1124 struct partial_symtab
*subpst
=
1125 allocate_psymtab (include_list
[i
], objfile
);
1127 subpst
->section_offsets
= pst
->section_offsets
;
1128 subpst
->read_symtab_private
=
1129 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
1130 sizeof (struct symloc
));
1134 subpst
->texthigh
= 0;
1136 /* We could save slight bits of space by only making one of these,
1137 shared by the entire set of include files. FIXME-someday. */
1138 subpst
->dependencies
= (struct partial_symtab
**)
1139 obstack_alloc (&objfile
->psymbol_obstack
,
1140 sizeof (struct partial_symtab
*));
1141 subpst
->dependencies
[0] = pst
;
1142 subpst
->number_of_dependencies
= 1;
1144 subpst
->globals_offset
=
1145 subpst
->n_global_syms
=
1146 subpst
->statics_offset
=
1147 subpst
->n_static_syms
= 0;
1151 subpst
->read_symtab
= pst
->read_symtab
;
1154 sort_pst_symbols (pst
);
1156 /* If there is already a psymtab or symtab for a file of this name,
1158 (If there is a symtab, more drastic things also happen.)
1159 This happens in VxWorks. */
1160 free_named_symtabs (pst
->filename
);
1162 if (num_includes
== 0
1163 && number_dependencies
== 0
1164 && pst
->n_global_syms
== 0
1165 && pst
->n_static_syms
== 0) {
1166 /* Throw away this psymtab, it's empty. We can't deallocate it, since
1167 it is on the obstack, but we can forget to chain it on the list. */
1168 struct partial_symtab
*prev_pst
;
1170 /* First, snip it out of the psymtab chain */
1172 if (pst
->objfile
->psymtabs
== pst
)
1173 pst
->objfile
->psymtabs
= pst
->next
;
1175 for (prev_pst
= pst
->objfile
->psymtabs
; prev_pst
; prev_pst
= pst
->next
)
1176 if (prev_pst
->next
== pst
)
1177 prev_pst
->next
= pst
->next
;
1179 /* Next, put it on a free list for recycling */
1180 pst
->next
= pst
->objfile
->free_psymtabs
;
1181 pst
->objfile
->free_psymtabs
= pst
;
1183 /* Indicate that psymtab was thrown away. */
1184 pst
= (struct partial_symtab
*)NULL
;
1190 os9k_psymtab_to_symtab_1 (pst
)
1191 struct partial_symtab
*pst
;
1193 struct cleanup
*old_chain
;
1201 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1206 /* Read in all partial symtabs on which this one is dependent */
1207 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
1208 if (!pst
->dependencies
[i
]->readin
)
1210 /* Inform about additional files that need to be read in. */
1213 fputs_filtered (" ", gdb_stdout
);
1215 fputs_filtered ("and ", gdb_stdout
);
1217 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
1218 wrap_here (""); /* Flush output */
1219 gdb_flush (gdb_stdout
);
1221 os9k_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
1224 if (LDSYMCNT(pst
)) /* Otherwise it's a dummy */
1226 /* Init stuff necessary for reading in symbols */
1229 old_chain
= make_cleanup (really_free_pendings
, 0);
1231 /* Read in this file's symbols */
1232 os9k_read_ofile_symtab (pst
);
1233 sort_symtab_syms (pst
->symtab
);
1234 do_cleanups (old_chain
);
1240 /* Read in all of the symbols for a given psymtab for real.
1241 Be verbose about it if the user wants that. */
1244 os9k_psymtab_to_symtab (pst
)
1245 struct partial_symtab
*pst
;
1254 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1259 if (LDSYMCNT(pst
) || pst
->number_of_dependencies
)
1261 /* Print the message now, before reading the string table,
1262 to avoid disconcerting pauses. */
1265 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
1266 gdb_flush (gdb_stdout
);
1269 sym_bfd
= pst
->objfile
->obfd
;
1270 os9k_psymtab_to_symtab_1 (pst
);
1272 /* Match with global symbols. This only needs to be done once,
1273 after all of the symtabs and dependencies have been read in. */
1274 scan_file_globals (pst
->objfile
);
1276 /* Finish up the debug error message. */
1278 printf_filtered ("done.\n");
1282 /* Read in a defined section of a specific object file's symbols. */
1284 os9k_read_ofile_symtab (pst
)
1285 struct partial_symtab
*pst
;
1287 register struct internal_symstruct
*bufp
;
1289 unsigned max_symnum
;
1291 struct objfile
*objfile
;
1292 int sym_offset
; /* Offset to start of symbols to read */
1293 CORE_ADDR text_offset
; /* Start of text segment for symbols */
1294 int text_size
; /* Size of text segment for symbols */
1295 struct section_offsets
*section_offsets
;
1298 objfile
= pst
->objfile
;
1299 sym_offset
= LDSYMOFF(pst
);
1300 max_symnum
= LDSYMCNT(pst
);
1301 text_offset
= pst
->textlow
;
1302 text_size
= pst
->texthigh
- pst
->textlow
;
1303 section_offsets
= pst
->section_offsets
;
1305 current_objfile
= objfile
;
1306 subfile_stack
= NULL
;
1307 last_source_file
= NULL
;
1309 abfd
= objfile
->obfd
;
1310 dbg_file
= objfile
->auxf2
;
1313 /* It is necessary to actually read one symbol *before* the start
1314 of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1315 occurs before the N_SO symbol.
1316 Detecting this in read_dbx_symtab
1317 would slow down initial readin, so we look for it here instead. */
1318 if (!processing_acc_compilation
&& sym_offset
>= (int)symbol_size
)
1320 fseek (objefile
->auxf2
, sym_offset
, SEEK_CUR
);
1321 fill_sym(objfile
->auxf2
, abfd
);
1324 processing_gcc_compilation
= 0;
1325 if (bufp
->n_type
== N_TEXT
)
1327 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1328 processing_gcc_compilation
= 1;
1329 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1330 processing_gcc_compilation
= 2;
1333 /* Try to select a C++ demangling based on the compilation unit
1336 if (processing_gcc_compilation
)
1338 if (AUTO_DEMANGLING
)
1340 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1346 /* The N_SO starting this symtab is the first symbol, so we
1347 better not check the symbol before it. I'm not this can
1348 happen, but it doesn't hurt to check for it. */
1349 bfd_seek (symfile_bfd
, sym_offset
, SEEK_CUR
);
1350 processing_gcc_compilation
= 0;
1354 fseek(dbg_file
, (long)sym_offset
, 0);
1356 if (bufp->n_type != (unsigned char)N_SYM_SYM)
1357 error("First symbol in segment of executable not a source symbol");
1360 for (symnum
= 0; symnum
< max_symnum
; symnum
++)
1362 QUIT
; /* Allow this to be interruptable */
1363 fill_sym(dbg_file
, abfd
);
1365 type
= bufp
->n_type
;
1367 os9k_process_one_symbol ((int)type
, (int)bufp
->n_desc
,
1368 (CORE_ADDR
)bufp
->n_value
, bufp
->n_strx
, section_offsets
, objfile
);
1370 /* We skip checking for a new .o or -l file; that should never
1371 happen in this routine. */
1373 else if (type
== N_TEXT
)
1375 /* I don't think this code will ever be executed, because
1376 the GCC_COMPILED_FLAG_SYMBOL usually is right before
1377 the N_SO symbol which starts this source file.
1378 However, there is no reason not to accept
1379 the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1381 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1382 processing_gcc_compilation
= 1;
1383 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1384 processing_gcc_compilation
= 2;
1386 if (AUTO_DEMANGLING
)
1388 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1391 else if (type
& N_EXT
|| type
== (unsigned char)N_TEXT
1392 || type
== (unsigned char)N_NBTEXT
1394 /* Global symbol: see if we came across a dbx defintion for
1395 a corresponding symbol. If so, store the value. Remove
1396 syms from the chain when their values are stored, but
1397 search the whole chain, as there may be several syms from
1398 different files with the same name. */
1399 /* This is probably not true. Since the files will be read
1400 in one at a time, each reference to a global symbol will
1401 be satisfied in each file as it appears. So we skip this
1408 current_objfile
= NULL
;
1410 /* In a Solaris elf file, this variable, which comes from the
1411 value of the N_SO symbol, will still be 0. Luckily, text_offset,
1412 which comes from pst->textlow is correct. */
1413 if (last_source_start_addr
== 0)
1414 last_source_start_addr
= text_offset
;
1415 pst
->symtab
= end_symtab (text_offset
+ text_size
, 0, 0, objfile
,
1421 /* This handles a single symbol from the symbol-file, building symbols
1422 into a GDB symtab. It takes these arguments and an implicit argument.
1424 TYPE is the type field of the ".stab" symbol entry.
1425 DESC is the desc field of the ".stab" entry.
1426 VALU is the value field of the ".stab" entry.
1427 NAME is the symbol name, in our address space.
1428 SECTION_OFFSETS is a set of amounts by which the sections of this object
1429 file were relocated when it was loaded into memory.
1430 All symbols that refer
1431 to memory locations need to be offset by these amounts.
1432 OBJFILE is the object file from which we are reading symbols.
1433 It is used in end_symtab. */
1436 os9k_process_one_symbol (type
, desc
, valu
, name
, section_offsets
, objfile
)
1440 struct section_offsets
*section_offsets
;
1441 struct objfile
*objfile
;
1443 register struct context_stack
*new;
1444 /* The stab type used for the definition of the last function.
1445 N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
1446 static int function_stab_type
= 0;
1449 /* Something is wrong if we see real data before
1450 seeing a source file name. */
1451 if (last_source_file
== NULL
&& type
!= (unsigned char)N_SO
)
1453 /* Ignore any symbols which appear before an N_SO symbol. Currently
1454 no one puts symbols there, but we should deal gracefully with the
1455 case. A complain()t might be in order (if !IGNORE_SYMBOL (type)),
1456 but this should not be an error (). */
1464 /* On most machines, the block addresses are relative to the
1465 N_SO, the linker did not relocate them (sigh). */
1466 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1467 new = push_context (desc
, valu
);
1471 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1472 new = pop_context();
1474 #if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
1475 #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1
1478 if (!OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1479 local_symbols
= new->locals
;
1481 if (context_stack_depth
> 1)
1483 /* This is not the outermost LBRAC...RBRAC pair in the function,
1484 its local symbols preceded it, and are the ones just recovered
1485 from the context stack. Define the block for them (but don't
1486 bother if the block contains no symbols. Should we complain
1487 on blocks without symbols? I can't think of any useful purpose
1489 if (local_symbols
!= NULL
)
1491 /* Muzzle a compiler bug that makes end < start. (which
1492 compilers? Is this ever harmful?). */
1493 if (new->start_addr
> valu
)
1495 complain (&lbrac_rbrac_complaint
);
1496 new->start_addr
= valu
;
1498 /* Make a block for the local symbols within. */
1499 finish_block (0, &local_symbols
, new->old_blocks
,
1500 new->start_addr
, valu
, objfile
);
1505 if (context_stack_depth
== 0)
1507 within_function
= 0;
1508 /* Make a block for the local symbols within. */
1509 finish_block (new->name
, &local_symbols
, new->old_blocks
,
1510 new->start_addr
, valu
, objfile
);
1514 /* attach local_symbols to the end of new->locals */
1515 if (!new->locals
) new->locals
= local_symbols
;
1520 while (p
->next
) p
= p
->next
;
1521 p
->next
= local_symbols
;
1526 if (OS9K_VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1527 /* Now pop locals of block just finished. */
1528 local_symbols
= new->locals
;
1533 /* This type of "symbol" really just records
1534 one line-number -- core-address correspondence.
1535 Enter it in the line list for this symbol table. */
1536 /* Relocate for dynamic loading and for ELF acc fn-relative syms. */
1537 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1538 record_line (current_subfile
, (int)name
, valu
);
1541 /* The following symbol types need to have the appropriate offset added
1542 to their value; then we process symbol definitions in the name. */
1549 char *p
= strchr (name
, ':');
1559 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1560 n
= strrchr(name
, '/');
1570 if (symfile_depth
++ == 0) {
1571 if (last_source_file
) {
1572 end_symtab (valu
, 0, 0, objfile
, SECT_OFF_TEXT
);
1577 start_symtab (n
, dirn
, valu
);
1580 start_subfile (n
, dirn
!=NULL
? dirn
: current_subfile
->dirname
);
1586 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1587 function_stab_type
= type
;
1589 within_function
= 1;
1590 new = push_context (0, valu
);
1591 new->name
= define_symbol (valu
, name
, desc
, type
, objfile
);
1596 valu
+= ANOFFSET (section_offsets
, SECT_OFF_DATA
);
1597 define_symbol (valu
, name
, desc
, type
, objfile
);
1601 define_symbol (valu
, name
, desc
, type
, objfile
);
1608 if (--symfile_depth
!= 0)
1609 start_subfile(pop_subfile(), current_subfile
->dirname
);
1613 complain (&unknown_symtype_complaint
,
1614 local_hex_string((unsigned long) type
));
1621 previous_stab_code
= type
;
1624 /* Parse the user's idea of an offset for dynamic linking, into our idea
1625 of how to represent it for fast symbol reading. */
1627 static struct section_offsets
*
1628 os9k_symfile_offsets (objfile
, addr
)
1629 struct objfile
*objfile
;
1632 struct section_offsets
*section_offsets
;
1635 objfile
->num_sections
= SECT_OFF_MAX
;
1636 section_offsets
= (struct section_offsets
*)
1637 obstack_alloc (&objfile
-> psymbol_obstack
,
1638 sizeof (struct section_offsets
)
1639 + sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
1641 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
1642 ANOFFSET (section_offsets
, i
) = addr
;
1644 return section_offsets
;
1647 static struct sym_fns os9k_sym_fns
=
1649 bfd_target_os9k_flavour
,
1650 os9k_new_init
, /* sym_new_init: init anything gbl to entire symtab */
1651 os9k_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
1652 os9k_symfile_read
, /* sym_read: read a symbol file into symtab */
1653 os9k_symfile_finish
, /* sym_finish: finished with file, cleanup */
1654 os9k_symfile_offsets
, /* sym_offsets: parse user's offsets to internal form*/
1655 NULL
/* next: pointer to next struct sym_fns */
1659 _initialize_os9kread ()
1661 add_symtab_fns(&os9k_sym_fns
);