1 /* Read dbx symbol tables and convert to internal format, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* This module provides three functions: dbx_symfile_init,
21 which initializes to read a symbol file; dbx_new_init, which
22 discards existing cached information when all symbols are being
23 discarded; and dbx_symfile_read, which reads a symbol table
26 dbx_symfile_read only does the minimum work necessary for letting the
27 user "name" things symbolically; it does not read the entire symtab.
28 Instead, it reads the external and static symbols and puts them in partial
29 symbol tables. When more extensive information is requested of a
30 file, the corresponding partial symbol table is mutated into a full
31 fledged symbol table by going back and reading the symbols
32 for real. dbx_psymtab_to_symtab() is the function that does this */
38 #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 */
62 #include "aout/aout64.h"
63 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
65 /* Information is passed among various dbxread routines for accessing
66 symbol files. A pointer to this structure is kept in the sym_private
67 field of the objfile struct. */
69 struct dbx_symfile_info {
70 asection *text_sect; /* Text section accessor */
71 int symcount; /* How many symbols are there in the file */
72 char *stringtab; /* The actual string table */
73 int stringtab_size; /* Its size */
74 off_t symtab_offset; /* Offset in file to symbol table */
77 #define DBX_SYMFILE_INFO(o) ((struct dbx_symfile_info *)((o)->sym_private))
78 #define DBX_TEXT_SECT(o) (DBX_SYMFILE_INFO(o)->text_sect)
79 #define DBX_SYMCOUNT(o) (DBX_SYMFILE_INFO(o)->symcount)
80 #define DBX_STRINGTAB(o) (DBX_SYMFILE_INFO(o)->stringtab)
81 #define DBX_STRINGTAB_SIZE(o) (DBX_SYMFILE_INFO(o)->stringtab_size)
82 #define DBX_SYMTAB_OFFSET(o) (DBX_SYMFILE_INFO(o)->symtab_offset)
84 /* Each partial symbol table entry contains a pointer to private data for the
85 read_symtab() function to use when expanding a partial symbol table entry
86 to a full symbol table entry.
88 For dbxread this structure contains the offset within the file symbol table
89 of first local symbol for this file, and length (in bytes) of the section
90 of the symbol table devoted to this file's symbols (actually, the section
91 bracketed may contain more than just this file's symbols). If ldsymlen is
92 0, the only reason for this thing's existence is the dependency list.
93 Nothing else will happen when it is read in. */
95 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
96 #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen)
103 /* Macro to determine which symbols to ignore when reading the first symbol
104 of a file. Some machines override this definition. */
105 #ifndef IGNORE_SYMBOL
106 /* This code is used on Ultrix systems. Ignore it */
107 #define IGNORE_SYMBOL(type) (type == (int)N_NSYMS)
110 /* Macro for name of symbol to indicate a file compiled with gcc. */
111 #ifndef GCC_COMPILED_FLAG_SYMBOL
112 #define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
115 /* Macro for name of symbol to indicate a file compiled with gcc2. */
116 #ifndef GCC2_COMPILED_FLAG_SYMBOL
117 #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
120 /* Define this as 1 if a pcc declaration of a char or short argument
121 gives the correct address. Otherwise assume pcc gives the
122 address of the corresponding int, which is not the same on a
123 big-endian machine. */
125 #ifndef BELIEVE_PCC_PROMOTION
126 #define BELIEVE_PCC_PROMOTION 0
129 /* Nonzero means give verbose info on gdb action. From main.c. */
130 extern int info_verbose;
132 /* The BFD for this file -- implicit parameter to next_symbol_text. */
134 static bfd *symfile_bfd;
136 /* The objfile for this file -- only good in process_one_symbol(). */
138 static struct objfile *our_objfile;
140 /* The size of each symbol in the symbol file (in external form).
141 This is set by dbx_symfile_read when building psymtabs, and by
142 dbx_psymtab_to_symtab when building symtabs. */
144 static unsigned symbol_size;
146 /* Complaints about the symbols we have encountered. */
148 struct complaint lbrac_complaint =
149 {"bad block start address patched", 0, 0};
151 struct complaint string_table_offset_complaint =
152 {"bad string table offset in symbol %d", 0, 0};
154 struct complaint unknown_symtype_complaint =
155 {"unknown symbol type %s", 0, 0};
157 struct complaint lbrac_rbrac_complaint =
158 {"block start larger than block end", 0, 0};
160 struct complaint lbrac_unmatched_complaint =
161 {"unmatched N_LBRAC before symtab pos %d", 0, 0};
163 struct complaint lbrac_mismatch_complaint =
164 {"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0};
166 /* During initial symbol readin, we need to have a structure to keep
167 track of which psymtabs have which bincls in them. This structure
168 is used during readin to setup the list of dependencies within each
169 partial symbol table. */
171 struct header_file_location
173 char *name; /* Name of header file */
174 int instance; /* See above */
175 struct partial_symtab *pst; /* Partial symtab that has the
176 BINCL/EINCL defs for this file */
179 /* The actual list and controling variables */
180 static struct header_file_location *bincl_list, *next_bincl;
181 static int bincls_allocated;
183 /* Local function prototypes */
186 free_header_files PARAMS ((void));
189 init_header_files PARAMS ((void));
191 static struct pending *
192 copy_pending PARAMS ((struct pending *, int, struct pending *));
194 static struct symtab *
195 read_ofile_symtab PARAMS ((struct objfile *, int, int, CORE_ADDR, int, int));
198 dbx_psymtab_to_symtab PARAMS ((struct partial_symtab *));
201 psymtab_to_symtab_1 PARAMS ((struct partial_symtab *, int));
204 read_dbx_symtab PARAMS ((CORE_ADDR, struct objfile *, CORE_ADDR, int));
207 free_bincl_list PARAMS ((struct objfile *));
209 static struct partial_symtab *
210 find_corresponding_bincl_psymtab PARAMS ((char *, int));
213 add_bincl_to_list PARAMS ((struct partial_symtab *, char *, int));
216 init_bincl_list PARAMS ((int, struct objfile *));
219 init_psymbol_list PARAMS ((struct objfile *));
222 dbx_next_symbol_text PARAMS ((void));
225 fill_symbuf PARAMS ((bfd *));
228 dbx_symfile_init PARAMS ((struct objfile *));
231 dbx_new_init PARAMS ((struct objfile *));
234 dbx_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
237 dbx_symfile_finish PARAMS ((struct objfile *));
240 record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
243 add_new_header_file PARAMS ((char *, int));
246 add_old_header_file PARAMS ((char *, int));
249 add_this_object_header_file PARAMS ((int));
251 /* Free up old header file tables */
258 if (header_files != NULL)
260 for (i = 0; i < n_header_files; i++)
262 free (header_files[i].name);
264 free ((PTR)header_files);
268 if (this_object_header_files)
270 free ((PTR)this_object_header_files);
271 this_object_header_files = NULL;
273 n_allocated_header_files = 0;
274 n_allocated_this_object_header_files = 0;
277 /* Allocate new header file tables */
283 n_allocated_header_files = 10;
284 header_files = (struct header_file *)
285 xmalloc (10 * sizeof (struct header_file));
287 n_allocated_this_object_header_files = 10;
288 this_object_header_files = (int *) xmalloc (10 * sizeof (int));
291 /* Add header file number I for this object file
292 at the next successive FILENUM. */
295 add_this_object_header_file (i)
298 if (n_this_object_header_files == n_allocated_this_object_header_files)
300 n_allocated_this_object_header_files *= 2;
301 this_object_header_files
302 = (int *) xrealloc ((char *) this_object_header_files,
303 n_allocated_this_object_header_files * sizeof (int));
306 this_object_header_files[n_this_object_header_files++] = i;
309 /* Add to this file an "old" header file, one already seen in
310 a previous object file. NAME is the header file's name.
311 INSTANCE is its instance code, to select among multiple
312 symbol tables for the same header file. */
315 add_old_header_file (name, instance)
319 register struct header_file *p = header_files;
322 for (i = 0; i < n_header_files; i++)
323 if (!strcmp (p[i].name, name) && instance == p[i].instance)
325 add_this_object_header_file (i);
328 error ("Invalid symbol data: \"repeated\" header file that hasn't been seen before, at symtab pos %d.",
332 /* Add to this file a "new" header file: definitions for its types follow.
333 NAME is the header file's name.
334 Most often this happens only once for each distinct header file,
335 but not necessarily. If it happens more than once, INSTANCE has
336 a different value each time, and references to the header file
337 use INSTANCE values to select among them.
339 dbx output contains "begin" and "end" markers for each new header file,
340 but at this level we just need to know which files there have been;
341 so we record the file when its "begin" is seen and ignore the "end". */
344 add_new_header_file (name, instance)
349 header_file_prev_index = -1;
351 /* Make sure there is room for one more header file. */
353 if (n_header_files == n_allocated_header_files)
355 n_allocated_header_files *= 2;
356 header_files = (struct header_file *)
357 xrealloc ((char *) header_files,
358 (n_allocated_header_files * sizeof (struct header_file)));
361 /* Create an entry for this header file. */
363 i = n_header_files++;
364 header_files[i].name = savestring (name, strlen(name));
365 header_files[i].instance = instance;
366 header_files[i].length = 10;
367 header_files[i].vector
368 = (struct type **) xmalloc (10 * sizeof (struct type *));
369 bzero (header_files[i].vector, 10 * sizeof (struct type *));
371 add_this_object_header_file (i);
375 static struct type **
376 explicit_lookup_type (real_filenum, index)
377 int real_filenum, index;
379 register struct header_file *f = &header_files[real_filenum];
381 if (index >= f->length)
384 f->vector = (struct type **)
385 xrealloc (f->vector, f->length * sizeof (struct type *));
386 bzero (&f->vector[f->length / 2],
387 f->length * sizeof (struct type *) / 2);
389 return &f->vector[index];
394 record_minimal_symbol (name, address, type, objfile)
398 struct objfile *objfile;
400 enum minimal_symbol_type ms_type;
402 switch (type &~ N_EXT) {
403 case N_TEXT: ms_type = mst_text; break;
404 case N_DATA: ms_type = mst_data; break;
405 case N_BSS: ms_type = mst_bss; break;
406 case N_ABS: ms_type = mst_abs; break;
408 case N_SETV: ms_type = mst_data; break;
410 default: ms_type = mst_unknown; break;
413 prim_record_minimal_symbol (obsavestring (name, strlen (name), &objfile -> symbol_obstack),
417 /* Scan and build partial symbols for a symbol file.
418 We have been initialized by a call to dbx_symfile_init, which
419 put all the relevant info into a "struct dbx_symfile_info",
420 hung off the objfile structure.
422 ADDR is the address relative to which the symbols in it are (e.g.
423 the base address of the text segment).
424 MAINLINE is true if we are reading the main symbol
425 table (as opposed to a shared lib or dynamically loaded file). */
428 dbx_symfile_read (objfile, addr, mainline)
429 struct objfile *objfile;
431 int mainline; /* FIXME comments above */
436 sym_bfd = objfile->obfd;
437 val = bfd_seek (objfile->obfd, DBX_SYMTAB_OFFSET (objfile), L_SET);
439 perror_with_name (objfile->name);
441 /* If we are reinitializing, or if we have never loaded syms yet, init */
442 if (mainline || objfile->global_psymbols.size == 0 || objfile->static_psymbols.size == 0)
443 init_psymbol_list (objfile);
445 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
446 symbol_size = obj_symbol_entry_size (sym_bfd);
449 make_cleanup (really_free_pendings, 0);
451 init_minimal_symbol_collection ();
452 make_cleanup (discard_minimal_symbols, 0);
454 /* Now that the symbol table data of the executable file are all in core,
455 process them and define symbols accordingly. */
457 addr -= bfd_section_vma (sym_bfd, DBX_TEXT_SECT (objfile)); /*offset*/
458 read_dbx_symtab (addr, objfile,
459 bfd_section_vma (sym_bfd, DBX_TEXT_SECT (objfile)),
460 bfd_section_size (sym_bfd, DBX_TEXT_SECT (objfile)));
462 /* Install any minimal symbols that have been collected as the current
463 minimal symbols for this objfile. */
465 install_minimal_symbols (objfile);
467 if (!have_partial_symbols ()) {
469 printf_filtered ("(no debugging symbols found)...");
474 /* Initialize anything that needs initializing when a completely new
475 symbol file is specified (not just adding some symbols from another
476 file, e.g. a shared library). */
479 dbx_new_init (ignore)
480 struct objfile *ignore;
482 buildsym_new_init ();
483 init_header_files ();
487 /* dbx_symfile_init ()
488 is the dbx-specific initialization routine for reading symbols.
489 It is passed a struct objfile which contains, among other things,
490 the BFD for the file whose symbols are being read, and a slot for a pointer
491 to "private data" which we fill with goodies.
493 We read the string table into malloc'd space and stash a pointer to it.
495 Since BFD doesn't know how to read debug symbols in a format-independent
496 way (and may never do so...), we have to do it ourselves. We will never
497 be called unless this is an a.out (or very similar) file.
498 FIXME, there should be a cleaner peephole into the BFD environment here. */
501 dbx_symfile_init (objfile)
502 struct objfile *objfile;
505 bfd *sym_bfd = objfile->obfd;
506 char *name = bfd_get_filename (sym_bfd);
507 unsigned char size_temp[4];
509 /* Allocate struct to keep track of the symfile */
510 objfile->sym_private = (PTR)
511 xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
513 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
514 #define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd))
515 #define SYMBOL_TABLE_OFFSET (sym_bfd->origin + obj_sym_filepos (sym_bfd))
516 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
518 DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
519 if (!DBX_TEXT_SECT (objfile))
521 DBX_SYMCOUNT (objfile) = bfd_get_symcount (sym_bfd);
523 /* Read the string table and stash it away in the psymbol_obstack. It is
524 only needed as long as we need to expand psymbols into full symbols,
525 so when we blow away the psymbol the string table goes away as well.
526 Note that gdb used to use the results of attempting to malloc the
527 string table, based on the size it read, as a form of sanity check
528 for botched byte swapping, on the theory that a byte swapped string
529 table size would be so totally bogus that the malloc would fail. Now
530 that we put in on the psymbol_obstack, we can't do this since gdb gets
531 a fatal error (out of virtual memory) if the size is bogus. We can
532 however at least check to see if the size is zero or some negative
535 val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
537 perror_with_name (name);
539 val = bfd_read ((PTR)size_temp, sizeof (long), 1, sym_bfd);
541 perror_with_name (name);
543 DBX_STRINGTAB_SIZE (objfile) = bfd_h_get_32 (sym_bfd, size_temp);
544 if (DBX_STRINGTAB_SIZE (objfile) <= 0)
545 error ("ridiculous string table size (%d bytes).",
546 DBX_STRINGTAB_SIZE (objfile));
548 DBX_STRINGTAB (objfile) =
549 (char *) obstack_alloc (&objfile -> psymbol_obstack,
550 DBX_STRINGTAB_SIZE (objfile));
552 /* Now read in the string table in one big gulp. */
554 val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, L_SET);
556 perror_with_name (name);
557 val = bfd_read (DBX_STRINGTAB (objfile), DBX_STRINGTAB_SIZE (objfile), 1,
559 if (val != DBX_STRINGTAB_SIZE (objfile))
560 perror_with_name (name);
562 /* Record the position of the symbol table for later use. */
564 DBX_SYMTAB_OFFSET (objfile) = SYMBOL_TABLE_OFFSET;
567 /* Perform any local cleanups required when we are done with a particular
568 objfile. I.E, we are in the process of discarding all symbol information
569 for an objfile, freeing up all memory held for it, and unlinking the
570 objfile struct from the global list of known objfiles. */
573 dbx_symfile_finish (objfile)
574 struct objfile *objfile;
576 if (objfile->sym_private != NULL)
578 mfree (objfile -> md, objfile->sym_private);
580 free_header_files ();
584 /* Buffer for reading the symbol table entries. */
585 static struct internal_nlist symbuf[4096];
586 static int symbuf_idx;
587 static int symbuf_end;
589 /* The address in memory of the string table of the object file we are
590 reading (which might not be the "main" object file, but might be a
591 shared library or some other dynamically loaded thing). This is set
592 by read_dbx_symtab when building psymtabs, and by read_ofile_symtab
593 when building symtabs, and is used only by next_symbol_text. */
594 static char *stringtab_global;
596 /* Refill the symbol table input buffer
597 and set the variables that control fetching entries from it.
598 Reports an error if no data available.
599 This function can read past the end of the symbol table
600 (into the string table) but this does no harm. */
603 fill_symbuf (sym_bfd)
606 int nbytes = bfd_read ((PTR)symbuf, sizeof (symbuf), 1, sym_bfd);
608 perror_with_name (bfd_get_filename (sym_bfd));
609 else if (nbytes == 0)
610 error ("Premature end of file reading symbol table");
611 symbuf_end = nbytes / symbol_size;
615 #define SWAP_SYMBOL(symp, abfd) \
617 (symp)->n_strx = bfd_h_get_32(abfd, \
618 (unsigned char *)&(symp)->n_strx); \
619 (symp)->n_desc = bfd_h_get_16 (abfd, \
620 (unsigned char *)&(symp)->n_desc); \
621 (symp)->n_value = bfd_h_get_32 (abfd, \
622 (unsigned char *)&(symp)->n_value); \
625 /* Invariant: The symbol pointed to by symbuf_idx is the first one
626 that hasn't been swapped. Swap the symbol at the same time
627 that symbuf_idx is incremented. */
629 /* dbx allows the text of a symbol name to be continued into the
630 next symbol name! When such a continuation is encountered
631 (a \ at the end of the text of a name)
632 call this function to get the continuation. */
635 dbx_next_symbol_text ()
637 if (symbuf_idx == symbuf_end)
638 fill_symbuf (symfile_bfd);
640 SWAP_SYMBOL(&symbuf[symbuf_idx], symfile_bfd);
641 return symbuf[symbuf_idx++].n_strx + stringtab_global;
644 /* Initializes storage for all of the partial symbols that will be
645 created by read_dbx_symtab and subsidiaries. */
648 init_psymbol_list (objfile)
649 struct objfile *objfile;
651 /* Free any previously allocated psymbol lists. */
652 if (objfile -> global_psymbols.list)
653 mfree (objfile -> md, (PTR)objfile -> global_psymbols.list);
654 if (objfile -> static_psymbols.list)
655 mfree (objfile -> md, (PTR)objfile -> static_psymbols.list);
657 /* Current best guess is that there are approximately a twentieth
658 of the total symbols (in a debugging file) are global or static
660 objfile -> global_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
661 objfile -> static_psymbols.size = DBX_SYMCOUNT (objfile) / 10;
662 objfile -> global_psymbols.next = objfile -> global_psymbols.list = (struct partial_symbol *)
663 xmmalloc (objfile -> md, objfile -> global_psymbols.size * sizeof (struct partial_symbol));
664 objfile -> static_psymbols.next = objfile -> static_psymbols.list = (struct partial_symbol *)
665 xmmalloc (objfile -> md, objfile -> static_psymbols.size * sizeof (struct partial_symbol));
668 /* Initialize the list of bincls to contain none and have some
672 init_bincl_list (number, objfile)
674 struct objfile *objfile;
676 bincls_allocated = number;
677 next_bincl = bincl_list = (struct header_file_location *)
678 xmmalloc (objfile -> md, bincls_allocated * sizeof(struct header_file_location));
681 /* Add a bincl to the list. */
684 add_bincl_to_list (pst, name, instance)
685 struct partial_symtab *pst;
689 if (next_bincl >= bincl_list + bincls_allocated)
691 int offset = next_bincl - bincl_list;
692 bincls_allocated *= 2;
693 bincl_list = (struct header_file_location *)
694 xmrealloc (pst->objfile->md, (char *)bincl_list,
695 bincls_allocated * sizeof (struct header_file_location));
696 next_bincl = bincl_list + offset;
698 next_bincl->pst = pst;
699 next_bincl->instance = instance;
700 next_bincl++->name = name;
703 /* Given a name, value pair, find the corresponding
704 bincl in the list. Return the partial symtab associated
705 with that header_file_location. */
707 static struct partial_symtab *
708 find_corresponding_bincl_psymtab (name, instance)
712 struct header_file_location *bincl;
714 for (bincl = bincl_list; bincl < next_bincl; bincl++)
715 if (bincl->instance == instance
716 && !strcmp (name, bincl->name))
719 return (struct partial_symtab *) 0;
722 /* Free the storage allocated for the bincl list. */
725 free_bincl_list (objfile)
726 struct objfile *objfile;
728 mfree (objfile -> md, (PTR)bincl_list);
729 bincls_allocated = 0;
732 /* Given pointers to an a.out symbol table in core containing dbx
733 style data, setup partial_symtab's describing each source file for
734 which debugging information is available.
735 SYMFILE_NAME is the name of the file we are reading from
736 and ADDR is its relocated address (if incremental) or 0 (if not). */
739 read_dbx_symtab (addr, objfile, text_addr, text_size)
741 struct objfile *objfile;
745 register struct internal_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */
746 register char *namestring;
748 int past_first_source_file = 0;
749 CORE_ADDR last_o_file_start = 0;
750 struct cleanup *old_chain;
753 /* End of the text segment of the executable file. */
754 CORE_ADDR end_of_text_addr;
756 /* Current partial symtab */
757 struct partial_symtab *pst;
759 /* List of current psymtab's include files */
760 char **psymtab_include_list;
761 int includes_allocated;
764 /* Index within current psymtab dependency list */
765 struct partial_symtab **dependency_list;
766 int dependencies_used, dependencies_allocated;
768 stringtab_global = DBX_STRINGTAB (objfile);
770 pst = (struct partial_symtab *) 0;
772 includes_allocated = 30;
774 psymtab_include_list = (char **) alloca (includes_allocated *
777 dependencies_allocated = 30;
778 dependencies_used = 0;
780 (struct partial_symtab **) alloca (dependencies_allocated *
781 sizeof (struct partial_symtab *));
783 old_chain = make_cleanup (free_objfile, objfile);
785 /* Init bincl list */
786 init_bincl_list (20, objfile);
787 make_cleanup (free_bincl_list, objfile);
789 last_source_file = 0;
791 #ifdef END_OF_TEXT_DEFAULT
792 end_of_text_addr = END_OF_TEXT_DEFAULT;
794 end_of_text_addr = text_addr + addr + text_size; /* Relocate */
797 symfile_bfd = objfile->obfd; /* For next_text_symbol */
798 abfd = objfile->obfd;
799 symbuf_end = symbuf_idx = 0;
800 next_symbol_text_func = dbx_next_symbol_text;
802 for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
804 /* Get the symbol for this run and pull out some info */
805 QUIT; /* allow this to be interruptable */
806 if (symbuf_idx == symbuf_end)
808 bufp = &symbuf[symbuf_idx++];
811 * Special case to speed up readin.
813 if (bufp->n_type == (unsigned char)N_SLINE) continue;
815 SWAP_SYMBOL (bufp, abfd);
817 /* Ok. There is a lot of code duplicated in the rest of this
818 switch statement (for efficiency reasons). Since I don't
819 like duplicating code, I will do my penance here, and
820 describe the code which is duplicated:
822 *) The assignment to namestring.
823 *) The call to strchr.
824 *) The addition of a partial symbol the the two partial
825 symbol lists. This last is a large section of code, so
826 I've imbedded it in the following macro.
829 /* Set namestring based on bufp. If the string table index is invalid,
830 give a fake name, and print a single error message per symbol file read,
831 rather than abort the symbol reading or flood the user with messages. */
832 #define SET_NAMESTRING()\
833 if (((unsigned)bufp->n_strx) >= DBX_STRINGTAB_SIZE (objfile)) { \
834 complain (&string_table_offset_complaint, (char *) symnum); \
835 namestring = "foo"; \
837 namestring = bufp->n_strx + DBX_STRINGTAB (objfile)
839 #define CUR_SYMBOL_TYPE bufp->n_type
840 #define CUR_SYMBOL_VALUE bufp->n_value
842 #define START_PSYMTAB(ofile,addr,fname,low,symoff,global_syms,static_syms)\
843 start_psymtab(ofile, addr, fname, low, symoff, global_syms, static_syms)
844 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)\
845 end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)
847 #include "partial-stab.h"
850 /* If there's stuff to be cleaned up, clean it up. */
851 if (DBX_SYMCOUNT (objfile) > 0 /* We have some syms */
852 && objfile -> ei.entry_point < bufp->n_value
853 && objfile -> ei.entry_point >= last_o_file_start)
855 objfile -> ei.entry_file_lowpc = last_o_file_start;
856 objfile -> ei.entry_file_highpc = bufp->n_value;
861 end_psymtab (pst, psymtab_include_list, includes_used,
862 symnum * symbol_size, end_of_text_addr,
863 dependency_list, dependencies_used);
866 free_bincl_list (objfile);
867 discard_cleanups (old_chain);
870 /* Allocate and partially fill a partial symtab. It will be
871 completely filled at the end of the symbol list.
873 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
874 is the address relative to which its symbols are (incremental) or 0
878 struct partial_symtab *
879 start_psymtab (objfile, addr,
880 filename, textlow, ldsymoff, global_syms, static_syms)
881 struct objfile *objfile;
886 struct partial_symbol *global_syms;
887 struct partial_symbol *static_syms;
889 struct partial_symtab *result =
890 start_psymtab_common(objfile, addr,
891 filename, textlow, global_syms, static_syms);
893 result->read_symtab_private = (char *)
894 obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc));
895 LDSYMOFF(result) = ldsymoff;
896 result->read_symtab = dbx_psymtab_to_symtab;
901 /* Close off the current usage of a partial_symbol table entry. This
902 involves setting the correct number of includes (with a realloc),
903 setting the high text mark, setting the symbol length in the
904 executable, and setting the length of the global and static lists
907 The global symbols and static symbols are then seperately sorted.
909 Then the partial symtab is put on the global list.
910 *** List variables and peculiarities of same. ***
914 end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
915 capping_text, dependency_list, number_dependencies)
916 struct partial_symtab *pst;
919 int capping_symbol_offset;
920 CORE_ADDR capping_text;
921 struct partial_symtab **dependency_list;
922 int number_dependencies;
923 /* struct partial_symbol *capping_global, *capping_static;*/
926 struct objfile *objfile = pst -> objfile;
928 if (capping_symbol_offset != -1)
929 LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst);
930 pst->texthigh = capping_text;
933 objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
935 objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset);
937 pst->number_of_dependencies = number_dependencies;
938 if (number_dependencies)
940 pst->dependencies = (struct partial_symtab **)
941 obstack_alloc (&objfile->psymbol_obstack,
942 number_dependencies * sizeof (struct partial_symtab *));
943 memcpy (pst->dependencies, dependency_list,
944 number_dependencies * sizeof (struct partial_symtab *));
947 pst->dependencies = 0;
949 for (i = 0; i < num_includes; i++)
951 struct partial_symtab *subpst =
952 allocate_psymtab (include_list[i], objfile);
954 subpst->addr = pst->addr;
955 subpst->read_symtab_private =
956 (char *) obstack_alloc (&objfile->psymbol_obstack,
957 sizeof (struct symloc));
961 subpst->texthigh = 0;
963 /* We could save slight bits of space by only making one of these,
964 shared by the entire set of include files. FIXME-someday. */
965 subpst->dependencies = (struct partial_symtab **)
966 obstack_alloc (&objfile->psymbol_obstack,
967 sizeof (struct partial_symtab *));
968 subpst->dependencies[0] = pst;
969 subpst->number_of_dependencies = 1;
971 subpst->globals_offset =
972 subpst->n_global_syms =
973 subpst->statics_offset =
974 subpst->n_static_syms = 0;
978 subpst->read_symtab = dbx_psymtab_to_symtab;
981 sort_pst_symbols (pst);
983 /* If there is already a psymtab or symtab for a file of this name, remove it.
984 (If there is a symtab, more drastic things also happen.)
985 This happens in VxWorks. */
986 free_named_symtabs (pst->filename);
988 if (num_includes == 0
989 && number_dependencies == 0
990 && pst->n_global_syms == 0
991 && pst->n_static_syms == 0) {
992 /* Throw away this psymtab, it's empty. We can't deallocate it, since
993 it is on the obstack, but we can forget to chain it on the list. */
994 struct partial_symtab *prev_pst;
996 /* First, snip it out of the psymtab chain */
998 if (pst->objfile->psymtabs == pst)
999 pst->objfile->psymtabs = pst->next;
1001 for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next)
1002 if (prev_pst->next == pst)
1003 prev_pst->next = pst->next;
1005 /* Next, put it on a free list for recycling */
1007 pst->next = pst->objfile->free_psymtabs;
1008 pst->objfile->free_psymtabs = pst;
1013 psymtab_to_symtab_1 (pst, sym_offset)
1014 struct partial_symtab *pst;
1017 struct cleanup *old_chain;
1025 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1030 /* Read in all partial symtabs on which this one is dependent */
1031 for (i = 0; i < pst->number_of_dependencies; i++)
1032 if (!pst->dependencies[i]->readin)
1034 /* Inform about additional files that need to be read in. */
1037 fputs_filtered (" ", stdout);
1039 fputs_filtered ("and ", stdout);
1041 printf_filtered ("%s...", pst->dependencies[i]->filename);
1042 wrap_here (""); /* Flush output */
1045 psymtab_to_symtab_1 (pst->dependencies[i], sym_offset);
1048 if (LDSYMLEN(pst)) /* Otherwise it's a dummy */
1050 /* Init stuff necessary for reading in symbols */
1052 old_chain = make_cleanup (really_free_pendings, 0);
1054 /* Read in this files symbols */
1055 bfd_seek (pst->objfile->obfd, sym_offset, L_SET);
1057 read_ofile_symtab (pst->objfile, LDSYMOFF(pst), LDSYMLEN(pst),
1058 pst->textlow, pst->texthigh - pst->textlow,
1060 sort_symtab_syms (pst->symtab);
1062 do_cleanups (old_chain);
1068 /* Read in all of the symbols for a given psymtab for real.
1069 Be verbose about it if the user wants that. */
1072 dbx_psymtab_to_symtab (pst)
1073 struct partial_symtab *pst;
1082 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1087 if (LDSYMLEN(pst) || pst->number_of_dependencies)
1089 /* Print the message now, before reading the string table,
1090 to avoid disconcerting pauses. */
1093 printf_filtered ("Reading in symbols for %s...", pst->filename);
1097 sym_bfd = pst->objfile->obfd;
1099 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
1100 symbol_size = obj_symbol_entry_size (sym_bfd);
1102 next_symbol_text_func = dbx_next_symbol_text;
1104 /* FIXME, this uses internal BFD variables. See above in
1105 dbx_symbol_file_open where the macro is defined! */
1106 psymtab_to_symtab_1 (pst, SYMBOL_TABLE_OFFSET);
1108 /* Match with global symbols. This only needs to be done once,
1109 after all of the symtabs and dependencies have been read in. */
1110 scan_file_globals (pst->objfile);
1112 /* Finish up the debug error message. */
1114 printf_filtered ("done.\n");
1119 * Read in a defined section of a specific object file's symbols.
1121 * DESC is the file descriptor for the file, positioned at the
1122 * beginning of the symtab
1123 * SYM_OFFSET is the offset within the file of
1124 * the beginning of the symbols we want to read
1125 * SYM_SIZE is the size of the symbol info to read in.
1126 * TEXT_OFFSET is the beginning of the text segment we are reading symbols for
1127 * TEXT_SIZE is the size of the text segment read in.
1128 * OFFSET is a relocation offset which gets added to each symbol
1131 static struct symtab *
1132 read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
1134 struct objfile *objfile;
1137 CORE_ADDR text_offset;
1141 register char *namestring;
1142 register struct internal_nlist *bufp;
1144 unsigned max_symnum;
1147 current_objfile = objfile;
1150 stringtab_global = DBX_STRINGTAB (objfile);
1151 last_source_file = 0;
1153 abfd = objfile->obfd;
1154 symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol */
1155 our_objfile = objfile; /* For end_symtab calls in process_one_symbol */
1156 symbuf_end = symbuf_idx = 0;
1158 /* It is necessary to actually read one symbol *before* the start
1159 of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1160 occurs before the N_SO symbol.
1162 Detecting this in read_dbx_symtab
1163 would slow down initial readin, so we look for it here instead. */
1164 if (sym_offset >= (int)symbol_size)
1166 bfd_seek (symfile_bfd, sym_offset - symbol_size, L_INCR);
1168 bufp = &symbuf[symbuf_idx++];
1169 SWAP_SYMBOL (bufp, abfd);
1173 processing_gcc_compilation =
1174 (bufp->n_type == N_TEXT
1175 && (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
1176 || strcmp(namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0));
1180 /* The N_SO starting this symtab is the first symbol, so we
1181 better not check the symbol before it. I'm not this can
1182 happen, but it doesn't hurt to check for it. */
1183 bfd_seek (symfile_bfd, sym_offset, L_INCR);
1184 processing_gcc_compilation = 0;
1187 if (symbuf_idx == symbuf_end)
1189 bufp = &symbuf[symbuf_idx];
1190 if (bufp->n_type != (unsigned char)N_SO)
1191 error("First symbol in segment of executable not a source symbol");
1193 max_symnum = sym_size / symbol_size;
1196 symnum < max_symnum;
1199 QUIT; /* Allow this to be interruptable */
1200 if (symbuf_idx == symbuf_end)
1202 bufp = &symbuf[symbuf_idx++];
1203 SWAP_SYMBOL (bufp, abfd);
1205 type = bufp->n_type;
1206 if (type == (unsigned char)N_CATCH)
1208 /* N_CATCH is not fixed up by the linker, and unfortunately,
1209 there's no other place to put it in the .stab map. */
1210 bufp->n_value += text_offset - offset;
1215 if (type & N_STAB) {
1216 process_one_symbol (type, bufp->n_desc, bufp->n_value,
1217 namestring, offset);
1218 /* our_objfile is an implicit parameter. */
1220 /* We skip checking for a new .o or -l file; that should never
1221 happen in this routine. */
1222 else if (type == N_TEXT
1223 && (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0
1224 || strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0))
1225 /* I don't think this code will ever be executed, because
1226 the GCC_COMPILED_FLAG_SYMBOL usually is right before
1227 the N_SO symbol which starts this source file.
1228 However, there is no reason not to accept
1229 the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1230 processing_gcc_compilation = 1;
1231 else if (type & N_EXT || type == (unsigned char)N_TEXT
1232 || type == (unsigned char)N_NBTEXT
1234 /* Global symbol: see if we came across a dbx defintion for
1235 a corresponding symbol. If so, store the value. Remove
1236 syms from the chain when their values are stored, but
1237 search the whole chain, as there may be several syms from
1238 different files with the same name. */
1239 /* This is probably not true. Since the files will be read
1240 in one at a time, each reference to a global symbol will
1241 be satisfied in each file as it appears. So we skip this
1247 current_objfile = NULL;
1248 return (end_symtab (text_offset + text_size, 0, 0, objfile));
1251 /* This handles a single symbol from the symbol-file, building symbols
1252 into a GDB symtab. It takes these arguments and an implicit argument.
1254 TYPE is the type field of the ".stab" symbol entry.
1255 DESC is the desc field of the ".stab" entry.
1256 VALU is the value field of the ".stab" entry.
1257 NAME is the symbol name, in our address space.
1258 OFFSET is the amount by which this object file was relocated
1259 when it was loaded into memory. All symbols that refer
1260 to memory locations need to be offset by this amount.
1262 The implicit argument is:
1263 OUR_OBJFILE is the object file from which we are reading symbols.
1264 It is used in end_symtab. */
1267 process_one_symbol (type, desc, valu, name, offset)
1273 #ifndef SUN_FIXED_LBRAC_BUG
1274 /* This records the last pc address we've seen. We depend on there being
1275 an SLINE or FUN or SO before the first LBRAC, since the variable does
1276 not get reset in between reads of different symbol files. */
1277 static CORE_ADDR last_pc_address;
1279 register struct context_stack *new;
1282 /* Something is wrong if we see real data before
1283 seeing a source file name. */
1285 if (last_source_file == 0 && type != (unsigned char)N_SO)
1287 /* Currently this ignores N_ENTRY on Gould machines, N_NSYM on machines
1288 where that code is defined. */
1289 if (IGNORE_SYMBOL (type))
1292 /* FIXME, this should not be an error, since it precludes extending
1293 the symbol table information in this way... */
1294 error ("Invalid symbol data: does not start by identifying a source file.");
1302 /* It seems that the Sun ANSI C compiler (acc) replaces N_FUN with N_GSYM and
1303 N_STSYM with a type code of f or F. Can't enable this until we get some
1304 stuff straightened out with psymtabs. */
1310 valu += offset; /* Relocate for dynamic loading */
1312 /* Either of these types of symbols indicates the start of
1313 a new function. We must process its "name" normally for dbx,
1314 but also record the start of a new lexical context, and possibly
1315 also the end of the lexical context for the previous function. */
1316 /* This is not always true. This type of symbol may indicate a
1317 text segment variable. */
1319 colon_pos = strchr (name, ':');
1321 || (*colon_pos != 'f' && *colon_pos != 'F'))
1323 define_symbol (valu, name, desc, type, our_objfile);
1327 #ifndef SUN_FIXED_LBRAC_BUG
1328 last_pc_address = valu; /* Save for SunOS bug circumcision */
1331 within_function = 1;
1332 if (context_stack_depth > 0)
1334 new = pop_context ();
1335 /* Make a block for the local symbols within. */
1336 finish_block (new->name, &local_symbols, new->old_blocks,
1337 new->start_addr, valu, our_objfile);
1339 /* Stack must be empty now. */
1340 if (context_stack_depth != 0)
1341 complain (&lbrac_unmatched_complaint, (char *) symnum);
1343 new = push_context (0, valu);
1344 new->name = define_symbol (valu, name, desc, type, our_objfile);
1348 /* Record the address at which this catch takes place. */
1349 define_symbol (valu+offset, name, desc, type, our_objfile);
1353 /* This "symbol" just indicates the start of an inner lexical
1354 context within a function. */
1356 #if defined (BLOCK_ADDRESS_ABSOLUTE)
1357 valu += offset; /* Relocate for dynamic loading */
1359 /* On most machines, the block addresses are relative to the
1360 N_SO, the linker did not relocate them (sigh). */
1361 valu += last_source_start_addr;
1364 #ifndef SUN_FIXED_LBRAC_BUG
1365 if (valu < last_pc_address) {
1366 /* Patch current LBRAC pc value to match last handy pc value */
1367 complain (&lbrac_complaint, 0);
1368 valu = last_pc_address;
1371 new = push_context (desc, valu);
1375 /* This "symbol" just indicates the end of an inner lexical
1376 context that was started with N_LBRAC. */
1378 #if defined (BLOCK_ADDRESS_ABSOLUTE)
1379 valu += offset; /* Relocate for dynamic loading */
1381 /* On most machines, the block addresses are relative to the
1382 N_SO, the linker did not relocate them (sigh). */
1383 valu += last_source_start_addr;
1386 new = pop_context();
1387 if (desc != new->depth)
1388 complain (&lbrac_mismatch_complaint, (char *) symnum);
1390 /* Some compilers put the variable decls inside of an
1391 LBRAC/RBRAC block. This macro should be nonzero if this
1392 is true. DESC is N_DESC from the N_RBRAC symbol.
1393 GCC_P is true if we've detected the GCC_COMPILED_SYMBOL
1394 or the GCC2_COMPILED_SYMBOL. */
1395 #if !defined (VARIABLES_INSIDE_BLOCK)
1396 #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) 0
1399 /* Can only use new->locals as local symbols here if we're in
1400 gcc or on a machine that puts them before the lbrack. */
1401 if (!VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
1402 local_symbols = new->locals;
1404 /* If this is not the outermost LBRAC...RBRAC pair in the
1405 function, its local symbols preceded it, and are the ones
1406 just recovered from the context stack. Defined the block for them.
1408 If this is the outermost LBRAC...RBRAC pair, there is no
1409 need to do anything; leave the symbols that preceded it
1410 to be attached to the function's own block. However, if
1411 it is so, we need to indicate that we just moved outside
1414 && (context_stack_depth
1415 > !VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)))
1417 /* FIXME Muzzle a compiler bug that makes end < start. */
1418 if (new->start_addr > valu)
1420 complain(&lbrac_rbrac_complaint, 0);
1421 new->start_addr = valu;
1423 /* Make a block for the local symbols within. */
1424 finish_block (0, &local_symbols, new->old_blocks,
1425 new->start_addr, valu, our_objfile);
1429 within_function = 0;
1431 if (VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
1432 /* Now pop locals of block just finished. */
1433 local_symbols = new->locals;
1438 /* This kind of symbol indicates the start of an object file. */
1439 valu += offset; /* Relocate for dynamic loading */
1443 /* This type of symbol indicates the start of data
1444 for one source file.
1445 Finish the symbol table of the previous source file
1446 (if any) and start accumulating a new symbol table. */
1447 valu += offset; /* Relocate for dynamic loading */
1449 #ifndef SUN_FIXED_LBRAC_BUG
1450 last_pc_address = valu; /* Save for SunOS bug circumcision */
1453 #ifdef PCC_SOL_BROKEN
1454 /* pcc bug, occasionally puts out SO for SOL. */
1455 if (context_stack_depth > 0)
1457 start_subfile (name, NULL);
1461 if (last_source_file)
1463 /* Check if previous symbol was also an N_SO (with some
1464 sanity checks). If so, that one was actually the directory
1465 name, and the current one is the real file name.
1467 if (previous_stab_code == N_SO
1468 && current_subfile && current_subfile->dirname == NULL
1469 && current_subfile->name != NULL
1470 && current_subfile->name[strlen(current_subfile->name)-1] == '/')
1472 current_subfile->dirname = current_subfile->name;
1473 current_subfile->name =
1474 obsavestring (name, strlen (name),
1475 &our_objfile -> symbol_obstack);
1478 (void) end_symtab (valu, 0, 0, our_objfile);
1480 start_symtab (name, NULL, valu);
1485 /* This type of symbol indicates the start of data for
1486 a sub-source-file, one whose contents were copied or
1487 included in the compilation of the main source file
1488 (whose name was given in the N_SO symbol.) */
1489 valu += offset; /* Relocate for dynamic loading */
1490 start_subfile (name, NULL);
1495 add_new_header_file (name, valu);
1496 start_subfile (name, NULL);
1500 start_subfile (pop_subfile (), NULL);
1504 add_old_header_file (name, valu);
1508 /* This type of "symbol" really just records
1509 one line-number -- core-address correspondence.
1510 Enter it in the line list for this symbol table. */
1511 valu += offset; /* Relocate for dynamic loading */
1512 #ifndef SUN_FIXED_LBRAC_BUG
1513 last_pc_address = valu; /* Save for SunOS bug circumcision */
1515 record_line (current_subfile, desc, valu);
1520 error ("Invalid symbol data: common within common at symtab pos %d",
1522 common_block = local_symbols;
1523 common_block_i = local_symbols ? local_symbols->nsyms : 0;
1527 /* Symbols declared since the BCOMM are to have the common block
1528 start address added in when we know it. common_block points to
1529 the first symbol after the BCOMM in the local_symbols list;
1530 copy the list and hang it off the symbol for the common block name
1534 struct symbol *sym =
1535 (struct symbol *) xmmalloc (our_objfile -> md, sizeof (struct symbol));
1536 bzero (sym, sizeof *sym);
1537 SYMBOL_NAME (sym) = savestring (name, strlen (name));
1538 SYMBOL_CLASS (sym) = LOC_BLOCK;
1539 SYMBOL_NAMESPACE (sym) = (enum namespace)((long)
1540 copy_pending (local_symbols, common_block_i, common_block));
1541 i = hashname (SYMBOL_NAME (sym));
1542 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1543 global_sym_chain[i] = sym;
1548 /* The following symbol types need to have the offset added to their
1549 value; then we process symbol definitions in the name. */
1550 case N_STSYM: /* Global symbol */
1551 case N_LCSYM: /* Local symbol */
1552 case N_DSLINE: /* Source line number, data seg */
1553 case N_BSLINE: /* Source line number, bss seg */
1554 /* N_BROWS: overlaps with N_BSLINE */
1555 case N_ENTRY: /* Alternate entry point */
1556 valu += offset; /* Relocate for dynamic loading */
1559 /* The following symbol types don't need the address field relocated,
1560 since it is either unused, or is absolute. */
1561 case N_GSYM: /* Global variable */
1562 case N_NSYMS: /* Number of symbols (ultrix) */
1563 case N_NOMAP: /* No map? (ultrix) */
1564 case N_RSYM: /* Register variable */
1565 case N_DEFD: /* Modula-2 GNU module dependency */
1566 case N_SSYM: /* Struct or union element */
1567 case N_LSYM: /* Local symbol in stack */
1568 case N_PSYM: /* Parameter variable */
1569 case N_LENG: /* Length of preceding symbol type */
1571 define_symbol (valu, name, desc, type, our_objfile);
1574 /* The following symbol types we don't know how to process. Handle
1575 them in a "default" way, but complain to people who care. */
1577 case N_EHDECL: /* Exception handler name */
1578 case N_MAIN: /* Name of main routine (not used in C) */
1579 case N_PC: /* Global symbol in Pascal */
1580 case N_M2C: /* Modula-2 compilation unit */
1581 /* N_MOD2: overlaps with N_EHDECL */
1582 case N_SCOPE: /* Modula-2 scope information */
1583 case N_ECOML: /* End common (local name) */
1584 case N_NBTEXT: /* Gould Non-Base-Register symbols??? */
1589 complain (&unknown_symtype_complaint, local_hex_string(type));
1591 define_symbol (valu, name, desc, type, our_objfile);
1594 previous_stab_code = type;
1597 /* Copy a pending list, used to record the contents of a common
1598 block for later fixup. */
1599 static struct pending *
1600 copy_pending (beg, begi, end)
1601 struct pending *beg;
1603 struct pending *end;
1605 struct pending *new = 0;
1606 struct pending *next;
1608 for (next = beg; next != 0 && (next != end || begi < end->nsyms);
1609 next = next->next, begi = 0)
1612 for (j = begi; j < next->nsyms; j++)
1613 add_symbol_to_list (next->symbol[j], &new);
1618 /* Register our willingness to decode symbols for SunOS and a.out and
1619 b.out files handled by BFD... */
1620 static struct sym_fns sunos_sym_fns =
1622 "sunOs", /* sym_name: name or name prefix of BFD target type */
1623 6, /* sym_namelen: number of significant sym_name chars */
1624 dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
1625 dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
1626 dbx_symfile_read, /* sym_read: read a symbol file into symtab */
1627 dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
1628 NULL /* next: pointer to next struct sym_fns */
1631 static struct sym_fns aout_sym_fns =
1633 "a.out", /* sym_name: name or name prefix of BFD target type */
1634 5, /* sym_namelen: number of significant sym_name chars */
1635 dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
1636 dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
1637 dbx_symfile_read, /* sym_read: read a symbol file into symtab */
1638 dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
1639 NULL /* next: pointer to next struct sym_fns */
1642 static struct sym_fns bout_sym_fns =
1644 "b.out", /* sym_name: name or name prefix of BFD target type */
1645 5, /* sym_namelen: number of significant sym_name chars */
1646 dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
1647 dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
1648 dbx_symfile_read, /* sym_read: read a symbol file into symtab */
1649 dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
1650 NULL /* next: pointer to next struct sym_fns */
1654 _initialize_dbxread ()
1656 add_symtab_fns(&sunos_sym_fns);
1657 add_symtab_fns(&aout_sym_fns);
1658 add_symtab_fns(&bout_sym_fns);