1 /* Read dbx symbol tables and convert to internal format, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This module provides three functions: dbx_symfile_init,
22 which initializes to read a symbol file; dbx_new_init, which
23 discards existing cached information when all symbols are being
24 discarded; and dbx_symfile_read, which reads a symbol table
27 dbx_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. dbx_psymtab_to_symtab() is the function that does this */
38 #if defined(USG) || defined(__CYGNUSCLIB__)
39 #include <sys/types.h>
44 #include <sys/param.h>
51 #include "breakpoint.h"
54 #include "gdbcore.h" /* for bfd stuff */
55 #include "libbfd.h" /* FIXME Secret internal BFD stuff (bfd_read) */
56 #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
60 #include "stabsread.h"
61 #include "gdb-stabs.h"
63 #include "language.h" /* Needed inside partial-stab.h */
64 #include "complaints.h"
66 #include "aout/aout64.h"
67 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
69 #if !defined (SEEK_SET)
74 /* Each partial symbol table entry contains a pointer to private data for the
75 read_symtab() function to use when expanding a partial symbol table entry
76 to a full symbol table entry.
78 For dbxread this structure contains the offset within the file symbol table
79 of first local symbol for this file, and length (in bytes) of the section
80 of the symbol table devoted to this file's symbols (actually, the section
81 bracketed may contain more than just this file's symbols). It also contains
82 further information needed to locate the symbols if they are in an ELF file.
84 If ldsymlen is 0, the only reason for this thing's existence is the
85 dependency list. Nothing else will happen when it is read in. */
87 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
88 #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen)
89 #define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private))
90 #define SYMBOL_SIZE(p) (SYMLOC(p)->symbol_size)
91 #define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset)
92 #define STRING_OFFSET(p) (SYMLOC(p)->string_offset)
93 #define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset)
101 int file_string_offset
;
104 /* Macro to determine which symbols to ignore when reading the first symbol
105 of a file. Some machines override this definition. */
106 #ifndef IGNORE_SYMBOL
107 /* This code is used on Ultrix systems. Ignore it */
108 #define IGNORE_SYMBOL(type) (type == (int)N_NSYMS)
111 /* Remember what we deduced to be the source language of this psymtab. */
113 static enum language psymtab_language
= language_unknown
;
115 /* Nonzero means give verbose info on gdb action. From main.c. */
116 extern int info_verbose
;
118 /* The BFD for this file -- implicit parameter to next_symbol_text. */
120 static bfd
*symfile_bfd
;
122 /* The size of each symbol in the symbol file (in external form).
123 This is set by dbx_symfile_read when building psymtabs, and by
124 dbx_psymtab_to_symtab when building symtabs. */
126 static unsigned symbol_size
;
128 /* This is the offset of the symbol table in the executable file */
129 static unsigned symbol_table_offset
;
131 /* This is the offset of the string table in the executable file */
132 static unsigned string_table_offset
;
134 /* For elf+stab executables, the n_strx field is not a simple index
135 into the string table. Instead, each .o file has a base offset
136 in the string table, and the associated symbols contain offsets
137 from this base. The following two variables contain the base
138 offset for the current and next .o files. */
139 static unsigned int file_string_table_offset
;
140 static unsigned int next_file_string_table_offset
;
142 /* This is the lowest text address we have yet encountered. */
143 static CORE_ADDR lowest_text_address
;
145 /* Complaints about the symbols we have encountered. */
147 struct complaint lbrac_complaint
=
148 {"bad block start address patched", 0, 0};
150 struct complaint string_table_offset_complaint
=
151 {"bad string table offset in symbol %d", 0, 0};
153 struct complaint unknown_symtype_complaint
=
154 {"unknown symbol type %s", 0, 0};
156 struct complaint unknown_symchar_complaint
=
157 {"unknown symbol descriptor `%c'", 0, 0};
159 struct complaint lbrac_rbrac_complaint
=
160 {"block start larger than block end", 0, 0};
162 struct complaint lbrac_unmatched_complaint
=
163 {"unmatched N_LBRAC before symtab pos %d", 0, 0};
165 struct complaint lbrac_mismatch_complaint
=
166 {"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0};
168 struct complaint repeated_header_complaint
=
169 {"\"repeated\" header file not previously seen, at symtab pos %d", 0, 0};
171 struct complaint repeated_header_name_complaint
=
172 {"\"repeated\" header file not previously seen, named %s", 0, 0};
174 /* During initial symbol readin, we need to have a structure to keep
175 track of which psymtabs have which bincls in them. This structure
176 is used during readin to setup the list of dependencies within each
177 partial symbol table. */
179 struct header_file_location
181 char *name
; /* Name of header file */
182 int instance
; /* See above */
183 struct partial_symtab
*pst
; /* Partial symtab that has the
184 BINCL/EINCL defs for this file */
187 /* The actual list and controling variables */
188 static struct header_file_location
*bincl_list
, *next_bincl
;
189 static int bincls_allocated
;
191 /* Local function prototypes */
194 free_header_files
PARAMS ((void));
197 init_header_files
PARAMS ((void));
200 read_ofile_symtab
PARAMS ((struct partial_symtab
*));
203 dbx_psymtab_to_symtab
PARAMS ((struct partial_symtab
*));
206 dbx_psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*));
209 read_dbx_symtab
PARAMS ((struct section_offsets
*, struct objfile
*,
213 free_bincl_list
PARAMS ((struct objfile
*));
215 static struct partial_symtab
*
216 find_corresponding_bincl_psymtab
PARAMS ((char *, int));
219 add_bincl_to_list
PARAMS ((struct partial_symtab
*, char *, int));
222 init_bincl_list
PARAMS ((int, struct objfile
*));
225 init_psymbol_list
PARAMS ((struct objfile
*));
228 dbx_next_symbol_text
PARAMS ((void));
231 fill_symbuf
PARAMS ((bfd
*));
234 dbx_symfile_init
PARAMS ((struct objfile
*));
237 dbx_new_init
PARAMS ((struct objfile
*));
240 dbx_symfile_read
PARAMS ((struct objfile
*, struct section_offsets
*, int));
243 dbx_symfile_finish
PARAMS ((struct objfile
*));
246 record_minimal_symbol
PARAMS ((char *, CORE_ADDR
, int, struct objfile
*));
249 add_new_header_file
PARAMS ((char *, int));
252 add_old_header_file
PARAMS ((char *, int));
255 add_this_object_header_file
PARAMS ((int));
257 /* Free up old header file tables */
264 if (header_files
!= NULL
)
266 for (i
= 0; i
< n_header_files
; i
++)
268 free (header_files
[i
].name
);
270 free ((PTR
)header_files
);
274 if (this_object_header_files
)
276 free ((PTR
)this_object_header_files
);
277 this_object_header_files
= NULL
;
279 n_allocated_header_files
= 0;
280 n_allocated_this_object_header_files
= 0;
283 /* Allocate new header file tables */
289 n_allocated_header_files
= 10;
290 header_files
= (struct header_file
*)
291 xmalloc (10 * sizeof (struct header_file
));
293 n_allocated_this_object_header_files
= 10;
294 this_object_header_files
= (int *) xmalloc (10 * sizeof (int));
297 /* Add header file number I for this object file
298 at the next successive FILENUM. */
301 add_this_object_header_file (i
)
304 if (n_this_object_header_files
== n_allocated_this_object_header_files
)
306 n_allocated_this_object_header_files
*= 2;
307 this_object_header_files
308 = (int *) xrealloc ((char *) this_object_header_files
,
309 n_allocated_this_object_header_files
* sizeof (int));
312 this_object_header_files
[n_this_object_header_files
++] = i
;
315 /* Add to this file an "old" header file, one already seen in
316 a previous object file. NAME is the header file's name.
317 INSTANCE is its instance code, to select among multiple
318 symbol tables for the same header file. */
321 add_old_header_file (name
, instance
)
325 register struct header_file
*p
= header_files
;
328 for (i
= 0; i
< n_header_files
; i
++)
329 if (STREQ (p
[i
].name
, name
) && instance
== p
[i
].instance
)
331 add_this_object_header_file (i
);
334 complain (&repeated_header_complaint
, symnum
);
335 complain (&repeated_header_name_complaint
, name
);
338 /* Add to this file a "new" header file: definitions for its types follow.
339 NAME is the header file's name.
340 Most often this happens only once for each distinct header file,
341 but not necessarily. If it happens more than once, INSTANCE has
342 a different value each time, and references to the header file
343 use INSTANCE values to select among them.
345 dbx output contains "begin" and "end" markers for each new header file,
346 but at this level we just need to know which files there have been;
347 so we record the file when its "begin" is seen and ignore the "end". */
350 add_new_header_file (name
, instance
)
356 /* Make sure there is room for one more header file. */
358 if (n_header_files
== n_allocated_header_files
)
360 n_allocated_header_files
*= 2;
361 header_files
= (struct header_file
*)
362 xrealloc ((char *) header_files
,
363 (n_allocated_header_files
* sizeof (struct header_file
)));
366 /* Create an entry for this header file. */
368 i
= n_header_files
++;
369 header_files
[i
].name
= savestring (name
, strlen(name
));
370 header_files
[i
].instance
= instance
;
371 header_files
[i
].length
= 10;
372 header_files
[i
].vector
373 = (struct type
**) xmalloc (10 * sizeof (struct type
*));
374 memset (header_files
[i
].vector
, 0, 10 * sizeof (struct type
*));
376 add_this_object_header_file (i
);
380 static struct type
**
381 explicit_lookup_type (real_filenum
, index
)
382 int real_filenum
, index
;
384 register struct header_file
*f
= &header_files
[real_filenum
];
386 if (index
>= f
->length
)
389 f
->vector
= (struct type
**)
390 xrealloc (f
->vector
, f
->length
* sizeof (struct type
*));
391 memset (&f
->vector
[f
->length
/ 2],
392 '\0', f
->length
* sizeof (struct type
*) / 2);
394 return &f
->vector
[index
];
399 record_minimal_symbol (name
, address
, type
, objfile
)
403 struct objfile
*objfile
;
405 enum minimal_symbol_type ms_type
;
409 case N_TEXT
| N_EXT
: ms_type
= mst_text
; break;
410 case N_DATA
| N_EXT
: ms_type
= mst_data
; break;
411 case N_BSS
| N_EXT
: ms_type
= mst_bss
; break;
412 case N_ABS
| N_EXT
: ms_type
= mst_abs
; break;
414 case N_SETV
| N_EXT
: ms_type
= mst_data
; break;
416 /* I don't think this type actually exists; since a N_SETV is the result
417 of going over many .o files, it doesn't make sense to have one
419 ms_type
= mst_file_data
;
426 ms_type
= mst_file_text
;
430 ms_type
= mst_file_data
;
432 /* Check for __DYNAMIC, which is used by Sun shared libraries.
433 Record it as global even if it's local, not global, so
434 lookup_minimal_symbol can find it. We don't check symbol_leading_char
435 because for SunOS4 it always is '_'. */
436 if (name
[8] == 'C' && STREQ ("__DYNAMIC", name
))
439 /* Same with virtual function tables, both global and static. */
441 char *tempstring
= name
;
442 if (tempstring
[0] == bfd_get_symbol_leading_char (objfile
->obfd
))
444 if (VTBL_PREFIX_P ((tempstring
)))
450 ms_type
= mst_file_bss
;
453 default: ms_type
= mst_unknown
; break;
456 if (ms_type
== mst_file_text
|| ms_type
== mst_text
457 && address
< lowest_text_address
)
458 lowest_text_address
= address
;
460 prim_record_minimal_symbol
461 (obsavestring (name
, strlen (name
), &objfile
-> symbol_obstack
),
467 /* Scan and build partial symbols for a symbol file.
468 We have been initialized by a call to dbx_symfile_init, which
469 put all the relevant info into a "struct dbx_symfile_info",
470 hung off the objfile structure.
472 SECTION_OFFSETS contains offsets relative to which the symbols in the
473 various sections are (depending where the sections were actually loaded).
474 MAINLINE is true if we are reading the main symbol
475 table (as opposed to a shared lib or dynamically loaded file). */
478 dbx_symfile_read (objfile
, section_offsets
, mainline
)
479 struct objfile
*objfile
;
480 struct section_offsets
*section_offsets
;
481 int mainline
; /* FIXME comments above */
485 struct cleanup
*back_to
;
487 sym_bfd
= objfile
->obfd
;
488 val
= bfd_seek (objfile
->obfd
, DBX_SYMTAB_OFFSET (objfile
), SEEK_SET
);
490 perror_with_name (objfile
->name
);
492 /* If we are reinitializing, or if we have never loaded syms yet, init */
493 if (mainline
|| objfile
->global_psymbols
.size
== 0 || objfile
->static_psymbols
.size
== 0)
494 init_psymbol_list (objfile
);
496 symbol_size
= DBX_SYMBOL_SIZE (objfile
);
497 symbol_table_offset
= DBX_SYMTAB_OFFSET (objfile
);
500 back_to
= make_cleanup (really_free_pendings
, 0);
502 init_minimal_symbol_collection ();
503 make_cleanup (discard_minimal_symbols
, 0);
505 /* Now that the symbol table data of the executable file are all in core,
506 process them and define symbols accordingly. */
508 read_dbx_symtab (section_offsets
, objfile
,
509 bfd_section_vma (sym_bfd
, DBX_TEXT_SECT (objfile
)),
510 bfd_section_size (sym_bfd
, DBX_TEXT_SECT (objfile
)));
512 /* Install any minimal symbols that have been collected as the current
513 minimal symbols for this objfile. */
515 install_minimal_symbols (objfile
);
517 if (!have_partial_symbols ()) {
519 printf_filtered ("(no debugging symbols found)...");
523 do_cleanups (back_to
);
526 /* Initialize anything that needs initializing when a completely new
527 symbol file is specified (not just adding some symbols from another
528 file, e.g. a shared library). */
531 dbx_new_init (ignore
)
532 struct objfile
*ignore
;
534 stabsread_new_init ();
535 buildsym_new_init ();
536 init_header_files ();
540 /* dbx_symfile_init ()
541 is the dbx-specific initialization routine for reading symbols.
542 It is passed a struct objfile which contains, among other things,
543 the BFD for the file whose symbols are being read, and a slot for a pointer
544 to "private data" which we fill with goodies.
546 We read the string table into malloc'd space and stash a pointer to it.
548 Since BFD doesn't know how to read debug symbols in a format-independent
549 way (and may never do so...), we have to do it ourselves. We will never
550 be called unless this is an a.out (or very similar) file.
551 FIXME, there should be a cleaner peephole into the BFD environment here. */
553 #define DBX_STRINGTAB_SIZE_SIZE sizeof(long) /* FIXME */
556 dbx_symfile_init (objfile
)
557 struct objfile
*objfile
;
560 bfd
*sym_bfd
= objfile
->obfd
;
561 char *name
= bfd_get_filename (sym_bfd
);
562 unsigned char size_temp
[DBX_STRINGTAB_SIZE_SIZE
];
564 /* Allocate struct to keep track of the symfile */
565 objfile
->sym_stab_info
= (PTR
)
566 xmmalloc (objfile
-> md
, sizeof (struct dbx_symfile_info
));
568 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
569 #define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd))
570 #define SYMBOL_TABLE_OFFSET (sym_bfd->origin + obj_sym_filepos (sym_bfd))
572 /* FIXME POKING INSIDE BFD DATA STRUCTURES */
574 DBX_SYMFILE_INFO (objfile
)->stab_section_info
= NULL
;
575 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
576 if (!DBX_TEXT_SECT (objfile
))
577 error ("Can't find .text section in symbol file");
579 DBX_SYMBOL_SIZE (objfile
) = obj_symbol_entry_size (sym_bfd
);
580 DBX_SYMCOUNT (objfile
) = bfd_get_symcount (sym_bfd
);
581 DBX_SYMTAB_OFFSET (objfile
) = SYMBOL_TABLE_OFFSET
;
583 /* Read the string table and stash it away in the psymbol_obstack. It is
584 only needed as long as we need to expand psymbols into full symbols,
585 so when we blow away the psymbol the string table goes away as well.
586 Note that gdb used to use the results of attempting to malloc the
587 string table, based on the size it read, as a form of sanity check
588 for botched byte swapping, on the theory that a byte swapped string
589 table size would be so totally bogus that the malloc would fail. Now
590 that we put in on the psymbol_obstack, we can't do this since gdb gets
591 a fatal error (out of virtual memory) if the size is bogus. We can
592 however at least check to see if the size is less than the size of
593 the size field itself, or larger than the size of the entire file.
594 Note that all valid string tables have a size greater than zero, since
595 the bytes used to hold the size are included in the count. */
597 if (STRING_TABLE_OFFSET
== 0)
599 /* It appears that with the existing bfd code, STRING_TABLE_OFFSET
600 will never be zero, even when there is no string table. This
601 would appear to be a bug in bfd. */
602 DBX_STRINGTAB_SIZE (objfile
) = 0;
603 DBX_STRINGTAB (objfile
) = NULL
;
607 val
= bfd_seek (sym_bfd
, STRING_TABLE_OFFSET
, SEEK_SET
);
609 perror_with_name (name
);
611 memset ((PTR
) size_temp
, 0, sizeof (size_temp
));
612 val
= bfd_read ((PTR
) size_temp
, sizeof (size_temp
), 1, sym_bfd
);
615 perror_with_name (name
);
619 /* With the existing bfd code, STRING_TABLE_OFFSET will be set to
620 EOF if there is no string table, and attempting to read the size
621 from EOF will read zero bytes. */
622 DBX_STRINGTAB_SIZE (objfile
) = 0;
623 DBX_STRINGTAB (objfile
) = NULL
;
627 /* Read some data that would appear to be the string table size.
628 If there really is a string table, then it is probably the right
629 size. Byteswap if necessary and validate the size. Note that
630 the minimum is DBX_STRINGTAB_SIZE_SIZE. If we just read some
631 random data that happened to be at STRING_TABLE_OFFSET, because
632 bfd can't tell us there is no string table, the sanity checks may
633 or may not catch this. */
634 DBX_STRINGTAB_SIZE (objfile
) = bfd_h_get_32 (sym_bfd
, size_temp
);
636 if (DBX_STRINGTAB_SIZE (objfile
) < sizeof (size_temp
)
637 || DBX_STRINGTAB_SIZE (objfile
) > bfd_get_size (sym_bfd
))
638 error ("ridiculous string table size (%d bytes).",
639 DBX_STRINGTAB_SIZE (objfile
));
641 DBX_STRINGTAB (objfile
) =
642 (char *) obstack_alloc (&objfile
-> psymbol_obstack
,
643 DBX_STRINGTAB_SIZE (objfile
));
645 /* Now read in the string table in one big gulp. */
647 val
= bfd_seek (sym_bfd
, STRING_TABLE_OFFSET
, SEEK_SET
);
649 perror_with_name (name
);
650 val
= bfd_read (DBX_STRINGTAB (objfile
), DBX_STRINGTAB_SIZE (objfile
), 1,
652 if (val
!= DBX_STRINGTAB_SIZE (objfile
))
653 perror_with_name (name
);
658 /* Perform any local cleanups required when we are done with a particular
659 objfile. I.E, we are in the process of discarding all symbol information
660 for an objfile, freeing up all memory held for it, and unlinking the
661 objfile struct from the global list of known objfiles. */
664 dbx_symfile_finish (objfile
)
665 struct objfile
*objfile
;
667 if (objfile
->sym_stab_info
!= NULL
)
669 mfree (objfile
-> md
, objfile
->sym_stab_info
);
671 free_header_files ();
675 /* Buffer for reading the symbol table entries. */
676 static struct internal_nlist symbuf
[4096];
677 static int symbuf_idx
;
678 static int symbuf_end
;
680 /* Name of last function encountered. Used in Solaris to approximate
681 object file boundaries. */
682 static char *last_function_name
;
684 /* The address in memory of the string table of the object file we are
685 reading (which might not be the "main" object file, but might be a
686 shared library or some other dynamically loaded thing). This is set
687 by read_dbx_symtab when building psymtabs, and by read_ofile_symtab
688 when building symtabs, and is used only by next_symbol_text. */
689 static char *stringtab_global
;
691 /* Refill the symbol table input buffer
692 and set the variables that control fetching entries from it.
693 Reports an error if no data available.
694 This function can read past the end of the symbol table
695 (into the string table) but this does no harm. */
698 fill_symbuf (sym_bfd
)
701 int nbytes
= bfd_read ((PTR
)symbuf
, sizeof (symbuf
), 1, sym_bfd
);
703 perror_with_name (bfd_get_filename (sym_bfd
));
704 else if (nbytes
== 0)
705 error ("Premature end of file reading symbol table");
706 symbuf_end
= nbytes
/ symbol_size
;
710 #define SWAP_SYMBOL(symp, abfd) \
712 (symp)->n_strx = bfd_h_get_32(abfd, \
713 (unsigned char *)&(symp)->n_strx); \
714 (symp)->n_desc = bfd_h_get_16 (abfd, \
715 (unsigned char *)&(symp)->n_desc); \
716 (symp)->n_value = bfd_h_get_32 (abfd, \
717 (unsigned char *)&(symp)->n_value); \
720 /* Invariant: The symbol pointed to by symbuf_idx is the first one
721 that hasn't been swapped. Swap the symbol at the same time
722 that symbuf_idx is incremented. */
724 /* dbx allows the text of a symbol name to be continued into the
725 next symbol name! When such a continuation is encountered
726 (a \ at the end of the text of a name)
727 call this function to get the continuation. */
730 dbx_next_symbol_text ()
732 if (symbuf_idx
== symbuf_end
)
733 fill_symbuf (symfile_bfd
);
735 SWAP_SYMBOL(&symbuf
[symbuf_idx
], symfile_bfd
);
736 return symbuf
[symbuf_idx
++].n_strx
+ stringtab_global
737 + file_string_table_offset
;
740 /* Initializes storage for all of the partial symbols that will be
741 created by read_dbx_symtab and subsidiaries. */
744 init_psymbol_list (objfile
)
745 struct objfile
*objfile
;
747 /* Free any previously allocated psymbol lists. */
748 if (objfile
-> global_psymbols
.list
)
749 mfree (objfile
-> md
, (PTR
)objfile
-> global_psymbols
.list
);
750 if (objfile
-> static_psymbols
.list
)
751 mfree (objfile
-> md
, (PTR
)objfile
-> static_psymbols
.list
);
753 /* Current best guess is that there are approximately a twentieth
754 of the total symbols (in a debugging file) are global or static
756 objfile
-> global_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
757 objfile
-> static_psymbols
.size
= DBX_SYMCOUNT (objfile
) / 10;
758 objfile
-> global_psymbols
.next
= objfile
-> global_psymbols
.list
= (struct partial_symbol
*)
759 xmmalloc (objfile
-> md
, objfile
-> global_psymbols
.size
* sizeof (struct partial_symbol
));
760 objfile
-> static_psymbols
.next
= objfile
-> static_psymbols
.list
= (struct partial_symbol
*)
761 xmmalloc (objfile
-> md
, objfile
-> static_psymbols
.size
* sizeof (struct partial_symbol
));
764 /* Initialize the list of bincls to contain none and have some
768 init_bincl_list (number
, objfile
)
770 struct objfile
*objfile
;
772 bincls_allocated
= number
;
773 next_bincl
= bincl_list
= (struct header_file_location
*)
774 xmmalloc (objfile
-> md
, bincls_allocated
* sizeof(struct header_file_location
));
777 /* Add a bincl to the list. */
780 add_bincl_to_list (pst
, name
, instance
)
781 struct partial_symtab
*pst
;
785 if (next_bincl
>= bincl_list
+ bincls_allocated
)
787 int offset
= next_bincl
- bincl_list
;
788 bincls_allocated
*= 2;
789 bincl_list
= (struct header_file_location
*)
790 xmrealloc (pst
->objfile
->md
, (char *)bincl_list
,
791 bincls_allocated
* sizeof (struct header_file_location
));
792 next_bincl
= bincl_list
+ offset
;
794 next_bincl
->pst
= pst
;
795 next_bincl
->instance
= instance
;
796 next_bincl
++->name
= name
;
799 /* Given a name, value pair, find the corresponding
800 bincl in the list. Return the partial symtab associated
801 with that header_file_location. */
803 static struct partial_symtab
*
804 find_corresponding_bincl_psymtab (name
, instance
)
808 struct header_file_location
*bincl
;
810 for (bincl
= bincl_list
; bincl
< next_bincl
; bincl
++)
811 if (bincl
->instance
== instance
812 && STREQ (name
, bincl
->name
))
815 return (struct partial_symtab
*) 0;
818 /* Free the storage allocated for the bincl list. */
821 free_bincl_list (objfile
)
822 struct objfile
*objfile
;
824 mfree (objfile
-> md
, (PTR
)bincl_list
);
825 bincls_allocated
= 0;
828 /* Given pointers to an a.out symbol table in core containing dbx
829 style data, setup partial_symtab's describing each source file for
830 which debugging information is available.
831 SYMFILE_NAME is the name of the file we are reading from
832 and SECTION_OFFSETS is the set of offsets for the various sections
833 of the file (a set of zeros if the mainline program). */
836 read_dbx_symtab (section_offsets
, objfile
, text_addr
, text_size
)
837 struct section_offsets
*section_offsets
;
838 struct objfile
*objfile
;
842 register struct internal_nlist
*bufp
= 0; /* =0 avoids gcc -Wall glitch */
843 register char *namestring
;
845 int past_first_source_file
= 0;
846 CORE_ADDR last_o_file_start
= 0;
847 struct cleanup
*back_to
;
850 /* End of the text segment of the executable file. */
851 CORE_ADDR end_of_text_addr
;
853 /* Current partial symtab */
854 struct partial_symtab
*pst
;
856 /* List of current psymtab's include files */
857 char **psymtab_include_list
;
858 int includes_allocated
;
861 /* Index within current psymtab dependency list */
862 struct partial_symtab
**dependency_list
;
863 int dependencies_used
, dependencies_allocated
;
865 /* FIXME. We probably want to change stringtab_global rather than add this
866 while processing every symbol entry. FIXME. */
867 file_string_table_offset
= 0;
868 next_file_string_table_offset
= 0;
870 stringtab_global
= DBX_STRINGTAB (objfile
);
872 pst
= (struct partial_symtab
*) 0;
874 includes_allocated
= 30;
876 psymtab_include_list
= (char **) alloca (includes_allocated
*
879 dependencies_allocated
= 30;
880 dependencies_used
= 0;
882 (struct partial_symtab
**) alloca (dependencies_allocated
*
883 sizeof (struct partial_symtab
*));
885 /* Init bincl list */
886 init_bincl_list (20, objfile
);
887 back_to
= make_cleanup (free_bincl_list
, objfile
);
889 last_source_file
= NULL
;
891 lowest_text_address
= (CORE_ADDR
)-1;
893 symfile_bfd
= objfile
->obfd
; /* For next_text_symbol */
894 abfd
= objfile
->obfd
;
895 symbuf_end
= symbuf_idx
= 0;
896 next_symbol_text_func
= dbx_next_symbol_text
;
898 for (symnum
= 0; symnum
< DBX_SYMCOUNT (objfile
); symnum
++)
900 /* Get the symbol for this run and pull out some info */
901 QUIT
; /* allow this to be interruptable */
902 if (symbuf_idx
== symbuf_end
)
904 bufp
= &symbuf
[symbuf_idx
++];
907 * Special case to speed up readin.
909 if (bufp
->n_type
== (unsigned char)N_SLINE
) continue;
911 SWAP_SYMBOL (bufp
, abfd
);
913 /* Ok. There is a lot of code duplicated in the rest of this
914 switch statement (for efficiency reasons). Since I don't
915 like duplicating code, I will do my penance here, and
916 describe the code which is duplicated:
918 *) The assignment to namestring.
919 *) The call to strchr.
920 *) The addition of a partial symbol the the two partial
921 symbol lists. This last is a large section of code, so
922 I've imbedded it in the following macro.
925 /* Set namestring based on bufp. If the string table index is invalid,
926 give a fake name, and print a single error message per symbol file read,
927 rather than abort the symbol reading or flood the user with messages. */
929 /*FIXME: Too many adds and indirections in here for the inner loop. */
930 #define SET_NAMESTRING()\
931 if (((unsigned)bufp->n_strx + file_string_table_offset) >= \
932 DBX_STRINGTAB_SIZE (objfile)) { \
933 complain (&string_table_offset_complaint, symnum); \
934 namestring = "foo"; \
936 namestring = bufp->n_strx + file_string_table_offset + \
937 DBX_STRINGTAB (objfile)
939 #define CUR_SYMBOL_TYPE bufp->n_type
940 #define CUR_SYMBOL_VALUE bufp->n_value
942 #define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
943 start_psymtab(ofile, secoff, fname, low, symoff, global_syms, static_syms)
944 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)\
945 end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps)
947 #include "partial-stab.h"
950 /* If there's stuff to be cleaned up, clean it up. */
951 if (DBX_SYMCOUNT (objfile
) > 0 /* We have some syms */
952 /*FIXME, does this have a bug at start address 0? */
954 && objfile
-> ei
.entry_point
< bufp
->n_value
955 && objfile
-> ei
.entry_point
>= last_o_file_start
)
957 objfile
-> ei
.entry_file_lowpc
= last_o_file_start
;
958 objfile
-> ei
.entry_file_highpc
= bufp
->n_value
;
963 end_psymtab (pst
, psymtab_include_list
, includes_used
,
964 symnum
* symbol_size
,
965 (lowest_text_address
== (CORE_ADDR
)-1
966 ? text_addr
: lowest_text_address
)
968 dependency_list
, dependencies_used
);
971 do_cleanups (back_to
);
974 /* Allocate and partially fill a partial symtab. It will be
975 completely filled at the end of the symbol list.
977 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
978 is the address relative to which its symbols are (incremental) or 0
982 struct partial_symtab
*
983 start_psymtab (objfile
, section_offsets
,
984 filename
, textlow
, ldsymoff
, global_syms
, static_syms
)
985 struct objfile
*objfile
;
986 struct section_offsets
*section_offsets
;
990 struct partial_symbol
*global_syms
;
991 struct partial_symbol
*static_syms
;
993 struct partial_symtab
*result
=
994 start_psymtab_common(objfile
, section_offsets
,
995 filename
, textlow
, global_syms
, static_syms
);
997 result
->read_symtab_private
= (char *)
998 obstack_alloc (&objfile
-> psymbol_obstack
, sizeof (struct symloc
));
999 LDSYMOFF(result
) = ldsymoff
;
1000 result
->read_symtab
= dbx_psymtab_to_symtab
;
1001 SYMBOL_SIZE(result
) = symbol_size
;
1002 SYMBOL_OFFSET(result
) = symbol_table_offset
;
1003 STRING_OFFSET(result
) = string_table_offset
;
1004 FILE_STRING_OFFSET(result
) = file_string_table_offset
;
1006 /* If we're handling an ELF file, drag some section-relocation info
1007 for this source file out of the ELF symbol table, to compensate for
1008 Sun brain death. This replaces the section_offsets in this psymtab,
1010 elfstab_offset_sections (objfile
, result
);
1012 /* Deduce the source language from the filename for this psymtab. */
1013 psymtab_language
= deduce_language_from_filename (filename
);
1018 /* Close off the current usage of PST.
1019 Returns PST or NULL if the partial symtab was empty and thrown away.
1021 FIXME: List variables and peculiarities of same. */
1023 struct partial_symtab
*
1024 end_psymtab (pst
, include_list
, num_includes
, capping_symbol_offset
,
1025 capping_text
, dependency_list
, number_dependencies
)
1026 struct partial_symtab
*pst
;
1027 char **include_list
;
1029 int capping_symbol_offset
;
1030 CORE_ADDR capping_text
;
1031 struct partial_symtab
**dependency_list
;
1032 int number_dependencies
;
1035 struct partial_symtab
*p1
;
1036 struct objfile
*objfile
= pst
-> objfile
;
1038 if (capping_symbol_offset
!= -1)
1039 LDSYMLEN(pst
) = capping_symbol_offset
- LDSYMOFF(pst
);
1040 pst
->texthigh
= capping_text
;
1042 #ifdef N_SO_ADDRESS_MAYBE_MISSING
1043 /* Under Solaris, the N_SO symbols always have a value of 0,
1044 instead of the usual address of the .o file. Therefore,
1045 we have to do some tricks to fill in texthigh and textlow.
1046 The first trick is in partial-stab.h: if we see a static
1047 or global function, and the textlow for the current pst
1048 is still 0, then we use that function's address for
1049 the textlow of the pst.
1051 Now, to fill in texthigh, we remember the last function seen
1052 in the .o file (also in partial-stab.h). Also, there's a hack in
1053 bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
1054 to here via the misc_info field. Therefore, we can fill in
1055 a reliable texthigh by taking the address plus size of the
1056 last function in the file.
1058 Unfortunately, that does not cover the case where the last function
1059 in the file is static. See the paragraph below for more comments
1062 Finally, if we have a valid textlow for the current file, we run
1063 down the partial_symtab_list filling in previous texthighs that
1064 are still unknown. */
1066 if (pst
->texthigh
== 0 && last_function_name
) {
1069 struct minimal_symbol
*minsym
;
1071 p
= strchr (last_function_name
, ':');
1073 p
= last_function_name
;
1074 n
= p
- last_function_name
;
1076 strncpy (p
, last_function_name
, n
);
1079 minsym
= lookup_minimal_symbol (p
, objfile
);
1082 pst
->texthigh
= SYMBOL_VALUE_ADDRESS (minsym
) +
1083 (long) MSYMBOL_INFO (minsym
);
1085 /* This file ends with a static function, and it's
1086 difficult to imagine how hard it would be to track down
1087 the elf symbol. Luckily, most of the time no one will notice,
1088 since the next file will likely be compiled with -g, so
1089 the code below will copy the first fuction's start address
1090 back to our texthigh variable. (Also, if this file is the
1091 last one in a dynamically linked program, texthigh already
1092 has the right value.) If the next file isn't compiled
1093 with -g, then the last function in this file winds up owning
1094 all of the text space up to the next -g file, or the end (minus
1095 shared libraries). This only matters for single stepping,
1096 and even then it will still work, except that it will single
1097 step through all of the covered functions, instead of setting
1098 breakpoints around them as it usualy does. This makes it
1099 pretty slow, but at least it doesn't fail.
1101 We can fix this with a fairly big change to bfd, but we need
1102 to coordinate better with Cygnus if we want to do that. FIXME. */
1104 last_function_name
= NULL
;
1107 /* this test will be true if the last .o file is only data */
1108 if (pst
->textlow
== 0)
1109 /* This loses if the text section really starts at address zero
1110 (generally true when we are debugging a .o file, for example).
1111 That is why this whole thing is inside N_SO_ADDRESS_MAYBE_MISSING. */
1112 pst
->textlow
= pst
->texthigh
;
1114 /* If we know our own starting text address, then walk through all other
1115 psymtabs for this objfile, and if any didn't know their ending text
1116 address, set it to our starting address. Take care to not set our
1117 own ending address to our starting address, nor to set addresses on
1118 `dependency' files that have both textlow and texthigh zero. */
1120 ALL_OBJFILE_PSYMTABS (objfile
, p1
) {
1121 if (p1
->texthigh
== 0 && p1
->textlow
!= 0 && p1
!= pst
) {
1122 p1
->texthigh
= pst
->textlow
;
1123 /* if this file has only data, then make textlow match texthigh */
1124 if (p1
->textlow
== 0)
1125 p1
->textlow
= p1
->texthigh
;
1130 /* End of kludge for patching Solaris textlow and texthigh. */
1131 #endif /* N_SO_ADDRESS_MAYBE_MISSING. */
1133 pst
->n_global_syms
=
1134 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
1135 pst
->n_static_syms
=
1136 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
1138 pst
->number_of_dependencies
= number_dependencies
;
1139 if (number_dependencies
)
1141 pst
->dependencies
= (struct partial_symtab
**)
1142 obstack_alloc (&objfile
->psymbol_obstack
,
1143 number_dependencies
* sizeof (struct partial_symtab
*));
1144 memcpy (pst
->dependencies
, dependency_list
,
1145 number_dependencies
* sizeof (struct partial_symtab
*));
1148 pst
->dependencies
= 0;
1150 for (i
= 0; i
< num_includes
; i
++)
1152 struct partial_symtab
*subpst
=
1153 allocate_psymtab (include_list
[i
], objfile
);
1155 subpst
->section_offsets
= pst
->section_offsets
;
1156 subpst
->read_symtab_private
=
1157 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
1158 sizeof (struct symloc
));
1162 subpst
->texthigh
= 0;
1164 /* We could save slight bits of space by only making one of these,
1165 shared by the entire set of include files. FIXME-someday. */
1166 subpst
->dependencies
= (struct partial_symtab
**)
1167 obstack_alloc (&objfile
->psymbol_obstack
,
1168 sizeof (struct partial_symtab
*));
1169 subpst
->dependencies
[0] = pst
;
1170 subpst
->number_of_dependencies
= 1;
1172 subpst
->globals_offset
=
1173 subpst
->n_global_syms
=
1174 subpst
->statics_offset
=
1175 subpst
->n_static_syms
= 0;
1179 subpst
->read_symtab
= pst
->read_symtab
;
1182 sort_pst_symbols (pst
);
1184 /* If there is already a psymtab or symtab for a file of this name, remove it.
1185 (If there is a symtab, more drastic things also happen.)
1186 This happens in VxWorks. */
1187 free_named_symtabs (pst
->filename
);
1189 if (num_includes
== 0
1190 && number_dependencies
== 0
1191 && pst
->n_global_syms
== 0
1192 && pst
->n_static_syms
== 0) {
1193 /* Throw away this psymtab, it's empty. We can't deallocate it, since
1194 it is on the obstack, but we can forget to chain it on the list. */
1195 struct partial_symtab
*prev_pst
;
1197 /* First, snip it out of the psymtab chain */
1199 if (pst
->objfile
->psymtabs
== pst
)
1200 pst
->objfile
->psymtabs
= pst
->next
;
1202 for (prev_pst
= pst
->objfile
->psymtabs
; prev_pst
; prev_pst
= pst
->next
)
1203 if (prev_pst
->next
== pst
)
1204 prev_pst
->next
= pst
->next
;
1206 /* Next, put it on a free list for recycling */
1208 pst
->next
= pst
->objfile
->free_psymtabs
;
1209 pst
->objfile
->free_psymtabs
= pst
;
1211 /* Indicate that psymtab was thrown away. */
1212 pst
= (struct partial_symtab
*)NULL
;
1218 dbx_psymtab_to_symtab_1 (pst
)
1219 struct partial_symtab
*pst
;
1221 struct cleanup
*old_chain
;
1229 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1234 /* Read in all partial symtabs on which this one is dependent */
1235 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
1236 if (!pst
->dependencies
[i
]->readin
)
1238 /* Inform about additional files that need to be read in. */
1241 fputs_filtered (" ", gdb_stdout
);
1243 fputs_filtered ("and ", gdb_stdout
);
1245 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
1246 wrap_here (""); /* Flush output */
1247 gdb_flush (gdb_stdout
);
1249 dbx_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
1252 if (LDSYMLEN(pst
)) /* Otherwise it's a dummy */
1254 /* Init stuff necessary for reading in symbols */
1257 old_chain
= make_cleanup (really_free_pendings
, 0);
1258 file_string_table_offset
= FILE_STRING_OFFSET (pst
);
1259 symbol_size
= SYMBOL_SIZE (pst
);
1261 /* Read in this file's symbols */
1262 bfd_seek (pst
->objfile
->obfd
, SYMBOL_OFFSET (pst
), SEEK_SET
);
1263 read_ofile_symtab (pst
);
1264 sort_symtab_syms (pst
->symtab
);
1266 do_cleanups (old_chain
);
1272 /* Read in all of the symbols for a given psymtab for real.
1273 Be verbose about it if the user wants that. */
1276 dbx_psymtab_to_symtab (pst
)
1277 struct partial_symtab
*pst
;
1286 fprintf_unfiltered (gdb_stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
1291 if (LDSYMLEN(pst
) || pst
->number_of_dependencies
)
1293 /* Print the message now, before reading the string table,
1294 to avoid disconcerting pauses. */
1297 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
1298 gdb_flush (gdb_stdout
);
1301 sym_bfd
= pst
->objfile
->obfd
;
1303 next_symbol_text_func
= dbx_next_symbol_text
;
1305 dbx_psymtab_to_symtab_1 (pst
);
1307 /* Match with global symbols. This only needs to be done once,
1308 after all of the symtabs and dependencies have been read in. */
1309 scan_file_globals (pst
->objfile
);
1311 /* Finish up the debug error message. */
1313 printf_filtered ("done.\n");
1317 /* Read in a defined section of a specific object file's symbols. */
1320 read_ofile_symtab (pst
)
1321 struct partial_symtab
*pst
;
1323 register char *namestring
;
1324 register struct internal_nlist
*bufp
;
1326 unsigned max_symnum
;
1328 struct objfile
*objfile
;
1329 int sym_offset
; /* Offset to start of symbols to read */
1330 int sym_size
; /* Size of symbols to read */
1331 CORE_ADDR text_offset
; /* Start of text segment for symbols */
1332 int text_size
; /* Size of text segment for symbols */
1333 struct section_offsets
*section_offsets
;
1335 objfile
= pst
->objfile
;
1336 sym_offset
= LDSYMOFF(pst
);
1337 sym_size
= LDSYMLEN(pst
);
1338 text_offset
= pst
->textlow
;
1339 text_size
= pst
->texthigh
- pst
->textlow
;
1340 section_offsets
= pst
->section_offsets
;
1342 current_objfile
= objfile
;
1343 subfile_stack
= NULL
;
1345 stringtab_global
= DBX_STRINGTAB (objfile
);
1346 last_source_file
= NULL
;
1348 abfd
= objfile
->obfd
;
1349 symfile_bfd
= objfile
->obfd
; /* Implicit param to next_text_symbol */
1350 symbuf_end
= symbuf_idx
= 0;
1352 /* It is necessary to actually read one symbol *before* the start
1353 of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
1354 occurs before the N_SO symbol.
1356 Detecting this in read_dbx_symtab
1357 would slow down initial readin, so we look for it here instead. */
1358 if (!processing_acc_compilation
&& sym_offset
>= (int)symbol_size
)
1360 bfd_seek (symfile_bfd
, sym_offset
- symbol_size
, SEEK_CUR
);
1362 bufp
= &symbuf
[symbuf_idx
++];
1363 SWAP_SYMBOL (bufp
, abfd
);
1367 processing_gcc_compilation
= 0;
1368 if (bufp
->n_type
== N_TEXT
)
1370 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1371 processing_gcc_compilation
= 1;
1372 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1373 processing_gcc_compilation
= 2;
1376 /* Try to select a C++ demangling based on the compilation unit
1379 if (processing_gcc_compilation
)
1381 if (AUTO_DEMANGLING
)
1383 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1389 /* The N_SO starting this symtab is the first symbol, so we
1390 better not check the symbol before it. I'm not this can
1391 happen, but it doesn't hurt to check for it. */
1392 bfd_seek (symfile_bfd
, sym_offset
, SEEK_CUR
);
1393 processing_gcc_compilation
= 0;
1396 if (symbuf_idx
== symbuf_end
)
1398 bufp
= &symbuf
[symbuf_idx
];
1399 if (bufp
->n_type
!= (unsigned char)N_SO
)
1400 error("First symbol in segment of executable not a source symbol");
1402 max_symnum
= sym_size
/ symbol_size
;
1405 symnum
< max_symnum
;
1408 QUIT
; /* Allow this to be interruptable */
1409 if (symbuf_idx
== symbuf_end
)
1411 bufp
= &symbuf
[symbuf_idx
++];
1412 SWAP_SYMBOL (bufp
, abfd
);
1414 type
= bufp
->n_type
;
1418 if (type
& N_STAB
) {
1419 process_one_symbol (type
, bufp
->n_desc
, bufp
->n_value
,
1420 namestring
, section_offsets
, objfile
);
1422 /* We skip checking for a new .o or -l file; that should never
1423 happen in this routine. */
1424 else if (type
== N_TEXT
)
1426 /* I don't think this code will ever be executed, because
1427 the GCC_COMPILED_FLAG_SYMBOL usually is right before
1428 the N_SO symbol which starts this source file.
1429 However, there is no reason not to accept
1430 the GCC_COMPILED_FLAG_SYMBOL anywhere. */
1432 if (STREQ (namestring
, GCC_COMPILED_FLAG_SYMBOL
))
1433 processing_gcc_compilation
= 1;
1434 else if (STREQ (namestring
, GCC2_COMPILED_FLAG_SYMBOL
))
1435 processing_gcc_compilation
= 2;
1437 if (AUTO_DEMANGLING
)
1439 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1442 else if (type
& N_EXT
|| type
== (unsigned char)N_TEXT
1443 || type
== (unsigned char)N_NBTEXT
1445 /* Global symbol: see if we came across a dbx defintion for
1446 a corresponding symbol. If so, store the value. Remove
1447 syms from the chain when their values are stored, but
1448 search the whole chain, as there may be several syms from
1449 different files with the same name. */
1450 /* This is probably not true. Since the files will be read
1451 in one at a time, each reference to a global symbol will
1452 be satisfied in each file as it appears. So we skip this
1458 current_objfile
= NULL
;
1460 /* In a Solaris elf file, this variable, which comes from the
1461 value of the N_SO symbol, will still be 0. Luckily, text_offset,
1462 which comes from pst->textlow is correct. */
1463 if (last_source_start_addr
== 0)
1464 last_source_start_addr
= text_offset
;
1466 pst
->symtab
= end_symtab (text_offset
+ text_size
, 0, 0, objfile
,
1472 /* This handles a single symbol from the symbol-file, building symbols
1473 into a GDB symtab. It takes these arguments and an implicit argument.
1475 TYPE is the type field of the ".stab" symbol entry.
1476 DESC is the desc field of the ".stab" entry.
1477 VALU is the value field of the ".stab" entry.
1478 NAME is the symbol name, in our address space.
1479 SECTION_OFFSETS is a set of amounts by which the sections of this object
1480 file were relocated when it was loaded into memory.
1481 All symbols that refer
1482 to memory locations need to be offset by these amounts.
1483 OBJFILE is the object file from which we are reading symbols.
1484 It is used in end_symtab. */
1487 process_one_symbol (type
, desc
, valu
, name
, section_offsets
, objfile
)
1491 struct section_offsets
*section_offsets
;
1492 struct objfile
*objfile
;
1494 #ifdef SUN_FIXED_LBRAC_BUG
1495 /* If SUN_FIXED_LBRAC_BUG is defined, then it tells us whether we need
1496 to correct the address of N_LBRAC's. If it is not defined, then
1497 we never need to correct the addresses. */
1499 /* This records the last pc address we've seen. We depend on there being
1500 an SLINE or FUN or SO before the first LBRAC, since the variable does
1501 not get reset in between reads of different symbol files. */
1502 static CORE_ADDR last_pc_address
;
1505 register struct context_stack
*new;
1506 /* This remembers the address of the start of a function. It is used
1507 because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries are
1508 relative to the current function's start address. On systems
1509 other than Solaris 2, this just holds the SECT_OFF_TEXT value, and is
1510 used to relocate these symbol types rather than SECTION_OFFSETS. */
1511 static CORE_ADDR function_start_offset
;
1513 /* If this is nonzero, N_LBRAC, N_RBRAC, and N_SLINE entries are relative
1514 to the function start address. */
1515 int block_address_function_relative
;
1517 /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
1518 file. Used to detect the SunPRO solaris compiler. */
1519 static int n_opt_found
;
1521 /* The stab type used for the definition of the last function.
1522 N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
1523 static int function_stab_type
= 0;
1525 /* This is true for Solaris (and all other systems which put stabs
1526 in sections, hopefully, since it would be silly to do things
1527 differently from Solaris), and false for SunOS4 and other a.out
1529 block_address_function_relative
=
1530 ((0 == strncmp (bfd_get_target (objfile
->obfd
), "elf", 3))
1531 || (0 == strncmp (bfd_get_target (objfile
->obfd
), "som", 3))
1532 || (0 == strncmp (bfd_get_target (objfile
->obfd
), "coff", 4)));
1534 if (!block_address_function_relative
)
1535 /* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
1536 function start address, so just use the text offset. */
1537 function_start_offset
= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1539 /* Something is wrong if we see real data before
1540 seeing a source file name. */
1542 if (last_source_file
== NULL
&& type
!= (unsigned char)N_SO
)
1544 /* Ignore any symbols which appear before an N_SO symbol. Currently
1545 no one puts symbols there, but we should deal gracefully with the
1546 case. A complain()t might be in order (if !IGNORE_SYMBOL (type)),
1547 but this should not be an error (). */
1555 /* Relocate for dynamic loading */
1556 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1557 goto define_a_symbol
;
1560 /* This "symbol" just indicates the start of an inner lexical
1561 context within a function. */
1563 #if defined(BLOCK_ADDRESS_ABSOLUTE)
1564 /* Relocate for dynamic loading (?). */
1565 valu
+= function_start_offset
;
1567 if (block_address_function_relative
)
1568 /* Relocate for Sun ELF acc fn-relative syms. */
1569 valu
+= function_start_offset
;
1571 /* On most machines, the block addresses are relative to the
1572 N_SO, the linker did not relocate them (sigh). */
1573 valu
+= last_source_start_addr
;
1576 #ifdef SUN_FIXED_LBRAC_BUG
1577 if (!SUN_FIXED_LBRAC_BUG
&& valu
< last_pc_address
) {
1578 /* Patch current LBRAC pc value to match last handy pc value */
1579 complain (&lbrac_complaint
);
1580 valu
= last_pc_address
;
1583 new = push_context (desc
, valu
);
1587 /* This "symbol" just indicates the end of an inner lexical
1588 context that was started with N_LBRAC. */
1590 #if defined(BLOCK_ADDRESS_ABSOLUTE)
1591 /* Relocate for dynamic loading (?). */
1592 valu
+= function_start_offset
;
1594 if (block_address_function_relative
)
1595 /* Relocate for Sun ELF acc fn-relative syms. */
1596 valu
+= function_start_offset
;
1598 /* On most machines, the block addresses are relative to the
1599 N_SO, the linker did not relocate them (sigh). */
1600 valu
+= last_source_start_addr
;
1603 new = pop_context();
1604 if (desc
!= new->depth
)
1605 complain (&lbrac_mismatch_complaint
, symnum
);
1607 /* Some compilers put the variable decls inside of an
1608 LBRAC/RBRAC block. This macro should be nonzero if this
1609 is true. DESC is N_DESC from the N_RBRAC symbol.
1610 GCC_P is true if we've detected the GCC_COMPILED_SYMBOL
1611 or the GCC2_COMPILED_SYMBOL. */
1612 #if !defined (VARIABLES_INSIDE_BLOCK)
1613 #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) 0
1616 /* Can only use new->locals as local symbols here if we're in
1617 gcc or on a machine that puts them before the lbrack. */
1618 if (!VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1619 local_symbols
= new->locals
;
1621 if (context_stack_depth
1622 > !VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1624 /* This is not the outermost LBRAC...RBRAC pair in the function,
1625 its local symbols preceded it, and are the ones just recovered
1626 from the context stack. Define the block for them (but don't
1627 bother if the block contains no symbols. Should we complain
1628 on blocks without symbols? I can't think of any useful purpose
1630 if (local_symbols
!= NULL
)
1632 /* Muzzle a compiler bug that makes end < start. (which
1633 compilers? Is this ever harmful?). */
1634 if (new->start_addr
> valu
)
1636 complain (&lbrac_rbrac_complaint
);
1637 new->start_addr
= valu
;
1639 /* Make a block for the local symbols within. */
1640 finish_block (0, &local_symbols
, new->old_blocks
,
1641 new->start_addr
, valu
, objfile
);
1646 /* This is the outermost LBRAC...RBRAC pair. There is no
1647 need to do anything; leave the symbols that preceded it
1648 to be attached to the function's own block. We need to
1649 indicate that we just moved outside of the function. */
1650 within_function
= 0;
1653 if (VARIABLES_INSIDE_BLOCK(desc
, processing_gcc_compilation
))
1654 /* Now pop locals of block just finished. */
1655 local_symbols
= new->locals
;
1660 /* This kind of symbol indicates the start of an object file. */
1661 /* Relocate for dynamic loading */
1662 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1666 /* This type of symbol indicates the start of data
1667 for one source file.
1668 Finish the symbol table of the previous source file
1669 (if any) and start accumulating a new symbol table. */
1670 /* Relocate for dynamic loading */
1671 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1675 #ifdef SUN_FIXED_LBRAC_BUG
1676 last_pc_address
= valu
; /* Save for SunOS bug circumcision */
1679 #ifdef PCC_SOL_BROKEN
1680 /* pcc bug, occasionally puts out SO for SOL. */
1681 if (context_stack_depth
> 0)
1683 start_subfile (name
, NULL
);
1687 if (last_source_file
)
1689 /* Check if previous symbol was also an N_SO (with some
1690 sanity checks). If so, that one was actually the directory
1691 name, and the current one is the real file name.
1693 if (previous_stab_code
== (unsigned char) N_SO
)
1695 patch_subfile_names (current_subfile
, name
);
1696 break; /* Ignore repeated SOs */
1698 end_symtab (valu
, 0, 0, objfile
, SECT_OFF_TEXT
);
1702 start_symtab (name
, NULL
, valu
);
1707 /* This type of symbol indicates the start of data for
1708 a sub-source-file, one whose contents were copied or
1709 included in the compilation of the main source file
1710 (whose name was given in the N_SO symbol.) */
1711 /* Relocate for dynamic loading */
1712 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1713 start_subfile (name
, current_subfile
->dirname
);
1718 add_new_header_file (name
, valu
);
1719 start_subfile (name
, current_subfile
->dirname
);
1723 start_subfile (pop_subfile (), current_subfile
->dirname
);
1727 add_old_header_file (name
, valu
);
1731 /* This type of "symbol" really just records
1732 one line-number -- core-address correspondence.
1733 Enter it in the line list for this symbol table. */
1734 /* Relocate for dynamic loading and for ELF acc fn-relative syms. */
1735 valu
+= function_start_offset
;
1736 #ifdef SUN_FIXED_LBRAC_BUG
1737 last_pc_address
= valu
; /* Save for SunOS bug circumcision */
1739 record_line (current_subfile
, desc
, valu
);
1743 common_block_start (name
, objfile
);
1747 common_block_end (objfile
);
1750 /* The following symbol types need to have the appropriate offset added
1751 to their value; then we process symbol definitions in the name. */
1753 case N_STSYM
: /* Static symbol in data seg */
1754 case N_LCSYM
: /* Static symbol in BSS seg */
1755 case N_ROSYM
: /* Static symbol in Read-only data seg */
1756 /* HORRID HACK DEPT. However, it's Sun's furgin' fault.
1757 Solaris2's stabs-in-elf makes *most* symbols relative
1758 but leaves a few absolute (at least for Solaris 2.1 and version
1759 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on the fence.
1760 .stab "foo:S...",N_STSYM is absolute (ld relocates it)
1761 .stab "foo:V...",N_STSYM is relative (section base subtracted).
1762 This leaves us no choice but to search for the 'S' or 'V'...
1763 (or pass the whole section_offsets stuff down ONE MORE function
1764 call level, which we really don't want to do). */
1767 p
= strchr (name
, ':');
1768 if (p
!= 0 && p
[1] == 'S')
1770 /* The linker relocated it. We don't want to add an
1771 elfstab_offset_sections-type offset, but we *do* want
1772 to add whatever solib.c passed to symbol_file_add as
1773 addr (this is known to affect SunOS4, and I suspect ELF
1774 too). Since elfstab_offset_sections currently does not
1775 muck with the text offset (there is no Ttext.text
1776 symbol), we can get addr from the text offset. If
1777 elfstab_offset_sections ever starts dealing with the
1778 text offset, and we still need to do this, we need to
1779 invent a SECT_OFF_ADDR_KLUDGE or something. */
1780 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1781 goto define_a_symbol
;
1783 /* Since it's not the kludge case, re-dispatch to the right handler. */
1785 case N_STSYM
: goto case_N_STSYM
;
1786 case N_LCSYM
: goto case_N_LCSYM
;
1787 case N_ROSYM
: goto case_N_ROSYM
;
1792 case_N_STSYM
: /* Static symbol in data seg */
1793 case N_DSLINE
: /* Source line number, data seg */
1794 valu
+= ANOFFSET (section_offsets
, SECT_OFF_DATA
);
1795 goto define_a_symbol
;
1797 case_N_LCSYM
: /* Static symbol in BSS seg */
1798 case N_BSLINE
: /* Source line number, bss seg */
1799 /* N_BROWS: overlaps with N_BSLINE */
1800 valu
+= ANOFFSET (section_offsets
, SECT_OFF_BSS
);
1801 goto define_a_symbol
;
1803 case_N_ROSYM
: /* Static symbol in Read-only data seg */
1804 valu
+= ANOFFSET (section_offsets
, SECT_OFF_RODATA
);
1805 goto define_a_symbol
;
1807 case N_ENTRY
: /* Alternate entry point */
1808 /* Relocate for dynamic loading */
1809 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1810 goto define_a_symbol
;
1812 /* The following symbol types we don't know how to process. Handle
1813 them in a "default" way, but complain to people who care. */
1815 case N_CATCH
: /* Exception handler catcher */
1816 case N_EHDECL
: /* Exception handler name */
1817 case N_PC
: /* Global symbol in Pascal */
1818 case N_M2C
: /* Modula-2 compilation unit */
1819 /* N_MOD2: overlaps with N_EHDECL */
1820 case N_SCOPE
: /* Modula-2 scope information */
1821 case N_ECOML
: /* End common (local name) */
1822 case N_NBTEXT
: /* Gould Non-Base-Register symbols??? */
1827 complain (&unknown_symtype_complaint
, local_hex_string (type
));
1830 /* The following symbol types don't need the address field relocated,
1831 since it is either unused, or is absolute. */
1833 case N_GSYM
: /* Global variable */
1834 case N_NSYMS
: /* Number of symbols (ultrix) */
1835 case N_NOMAP
: /* No map? (ultrix) */
1836 case N_RSYM
: /* Register variable */
1837 case N_DEFD
: /* Modula-2 GNU module dependency */
1838 case N_SSYM
: /* Struct or union element */
1839 case N_LSYM
: /* Local symbol in stack */
1840 case N_PSYM
: /* Parameter variable */
1841 case N_LENG
: /* Length of preceding symbol type */
1845 char *colon_pos
= strchr (name
, ':');
1846 if (colon_pos
== NULL
)
1849 deftype
= colon_pos
[1];
1855 function_stab_type
= type
;
1857 #ifdef SUN_FIXED_LBRAC_BUG
1858 /* The Sun acc compiler, under SunOS4, puts out
1859 functions with N_GSYM or N_STSYM. The problem is
1860 that the address of the symbol is no good (for N_GSYM
1861 it doesn't even attept an address; for N_STSYM it
1862 puts out an address but then it gets relocated
1863 relative to the data segment, not the text segment).
1864 Currently we can't fix this up later as we do for
1865 some types of symbol in scan_file_globals.
1866 Fortunately we do have a way of finding the address -
1867 we know that the value in last_pc_address is either
1868 the one we want (if we're dealing with the first
1869 function in an object file), or somewhere in the
1870 previous function. This means that we can use the
1871 minimal symbol table to get the address. */
1873 /* On solaris up to 2.2, the N_FUN stab gets relocated.
1874 On Solaris 2.3, ld no longer relocates stabs (which
1875 is good), and the N_FUN's value is now always zero.
1876 The following code can't deal with this, because
1877 last_pc_address depends on getting the address from a
1878 N_SLINE or some such and in Solaris those are function
1879 relative. Best fix is probably to create a Ttext.text symbol
1880 and handle this like Ddata.data and so on. */
1882 if (type
== N_GSYM
|| type
== N_STSYM
)
1884 struct minimal_symbol
*m
;
1885 int l
= colon_pos
- name
;
1887 m
= lookup_minimal_symbol_by_pc (last_pc_address
);
1888 if (m
&& STREQN (SYMBOL_NAME (m
), name
, l
))
1889 /* last_pc_address was in this function */
1890 valu
= SYMBOL_VALUE (m
);
1891 else if (m
&& STREQN (SYMBOL_NAME (m
+1), name
, l
))
1892 /* last_pc_address was in last function */
1893 valu
= SYMBOL_VALUE (m
+1);
1895 /* Not found - use last_pc_address (for finish_block) */
1896 valu
= last_pc_address
;
1899 last_pc_address
= valu
; /* Save for SunOS bug circumcision */
1902 if (block_address_function_relative
)
1903 /* For Solaris 2.0 compilers, the block addresses and
1904 N_SLINE's are relative to the start of the
1905 function. On normal systems, and when using gcc on
1906 Solaris 2.0, these addresses are just absolute, or
1907 relative to the N_SO, depending on
1908 BLOCK_ADDRESS_ABSOLUTE. */
1909 function_start_offset
= valu
;
1911 within_function
= 1;
1912 if (context_stack_depth
> 0)
1914 new = pop_context ();
1915 /* Make a block for the local symbols within. */
1916 finish_block (new->name
, &local_symbols
, new->old_blocks
,
1917 new->start_addr
, valu
, objfile
);
1919 /* Stack must be empty now. */
1920 if (context_stack_depth
!= 0)
1921 complain (&lbrac_unmatched_complaint
, symnum
);
1923 new = push_context (0, valu
);
1924 new->name
= define_symbol (valu
, name
, desc
, type
, objfile
);
1928 define_symbol (valu
, name
, desc
, type
, objfile
);
1934 /* We use N_OPT to carry the gcc2_compiled flag. Sun uses it
1935 for a bunch of other flags, too. Someday we may parse their
1936 flags; for now we ignore theirs and hope they'll ignore ours. */
1937 case N_OPT
: /* Solaris 2: Compiler options */
1940 if (STREQ (name
, GCC2_COMPILED_FLAG_SYMBOL
))
1942 processing_gcc_compilation
= 2;
1943 #if 1 /* Works, but is experimental. -fnf */
1944 if (AUTO_DEMANGLING
)
1946 set_demangling_style (GNU_DEMANGLING_STYLE_STRING
);
1955 /* The following symbol types can be ignored. */
1956 case N_OBJ
: /* Solaris 2: Object file dir and name */
1957 /* N_UNDF: Solaris 2: file separator mark */
1958 /* N_UNDF: -- we will never encounter it, since we only process one
1959 file's symbols at once. */
1960 case N_ENDM
: /* Solaris 2: End of module */
1961 case N_MAIN
: /* Name of main routine. */
1965 previous_stab_code
= type
;
1968 /* FIXME: The only difference between this and elfstab_build_psymtabs is
1969 the call to install_minimal_symbols for elf. If the differences are
1970 really that small, the code should be shared. */
1972 /* Scan and build partial symbols for an coff symbol file.
1973 The coff file has already been processed to get its minimal symbols.
1975 This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
1978 OBJFILE is the object file we are reading symbols from.
1979 ADDR is the address relative to which the symbols are (e.g.
1980 the base address of the text segment).
1981 MAINLINE is true if we are reading the main symbol
1982 table (as opposed to a shared lib or dynamically loaded file).
1983 STABOFFSET and STABSIZE define the location in OBJFILE where the .stab
1985 STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
1986 .stabstr section exists.
1988 This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
1989 adjusted for coff details. */
1992 coffstab_build_psymtabs (objfile
, section_offsets
, mainline
,
1993 staboffset
, stabsize
,
1994 stabstroffset
, stabstrsize
)
1995 struct objfile
*objfile
;
1996 struct section_offsets
*section_offsets
;
1998 file_ptr staboffset
;
1999 unsigned int stabsize
;
2000 file_ptr stabstroffset
;
2001 unsigned int stabstrsize
;
2004 bfd
*sym_bfd
= objfile
->obfd
;
2005 char *name
= bfd_get_filename (sym_bfd
);
2006 struct dbx_symfile_info
*info
;
2008 /* There is already a dbx_symfile_info allocated by our caller.
2009 It might even contain some info from the coff symtab to help us. */
2010 info
= (struct dbx_symfile_info
*) objfile
->sym_stab_info
;
2012 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
2013 if (!DBX_TEXT_SECT (objfile
))
2014 error ("Can't find .text section in symbol file");
2016 #define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
2017 DBX_SYMBOL_SIZE (objfile
) = COFF_STABS_SYMBOL_SIZE
;
2018 DBX_SYMCOUNT (objfile
) = stabsize
/ DBX_SYMBOL_SIZE (objfile
);
2019 DBX_STRINGTAB_SIZE (objfile
) = stabstrsize
;
2020 DBX_SYMTAB_OFFSET (objfile
) = staboffset
;
2022 if (stabstrsize
> bfd_get_size (sym_bfd
))
2023 error ("ridiculous string table size: %d bytes", stabstrsize
);
2024 DBX_STRINGTAB (objfile
) = (char *)
2025 obstack_alloc (&objfile
->psymbol_obstack
, stabstrsize
+1);
2027 /* Now read in the string table in one big gulp. */
2029 val
= bfd_seek (sym_bfd
, stabstroffset
, SEEK_SET
);
2031 perror_with_name (name
);
2032 val
= bfd_read (DBX_STRINGTAB (objfile
), stabstrsize
, 1, sym_bfd
);
2033 if (val
!= stabstrsize
)
2034 perror_with_name (name
);
2036 stabsread_new_init ();
2037 buildsym_new_init ();
2038 free_header_files ();
2039 init_header_files ();
2041 processing_acc_compilation
= 1;
2043 /* In a coff file, we've already installed the minimal symbols that came
2044 from the coff (non-stab) symbol table, so always act like an
2045 incremental load here. */
2046 dbx_symfile_read (objfile
, section_offsets
, 0);
2049 /* Scan and build partial symbols for an ELF symbol file.
2050 This ELF file has already been processed to get its minimal symbols,
2051 and any DWARF symbols that were in it.
2053 This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
2056 OBJFILE is the object file we are reading symbols from.
2057 ADDR is the address relative to which the symbols are (e.g.
2058 the base address of the text segment).
2059 MAINLINE is true if we are reading the main symbol
2060 table (as opposed to a shared lib or dynamically loaded file).
2061 STABOFFSET and STABSIZE define the location in OBJFILE where the .stab
2063 STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
2064 .stabstr section exists.
2066 This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
2067 adjusted for elf details. */
2070 elfstab_build_psymtabs (objfile
, section_offsets
, mainline
,
2071 staboffset
, stabsize
,
2072 stabstroffset
, stabstrsize
)
2073 struct objfile
*objfile
;
2074 struct section_offsets
*section_offsets
;
2076 file_ptr staboffset
;
2077 unsigned int stabsize
;
2078 file_ptr stabstroffset
;
2079 unsigned int stabstrsize
;
2082 bfd
*sym_bfd
= objfile
->obfd
;
2083 char *name
= bfd_get_filename (sym_bfd
);
2084 struct dbx_symfile_info
*info
;
2086 /* There is already a dbx_symfile_info allocated by our caller.
2087 It might even contain some info from the ELF symtab to help us. */
2088 info
= (struct dbx_symfile_info
*) objfile
->sym_stab_info
;
2090 DBX_TEXT_SECT (objfile
) = bfd_get_section_by_name (sym_bfd
, ".text");
2091 if (!DBX_TEXT_SECT (objfile
))
2092 error ("Can't find .text section in symbol file");
2094 #define ELF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
2095 DBX_SYMBOL_SIZE (objfile
) = ELF_STABS_SYMBOL_SIZE
;
2096 DBX_SYMCOUNT (objfile
) = stabsize
/ DBX_SYMBOL_SIZE (objfile
);
2097 DBX_STRINGTAB_SIZE (objfile
) = stabstrsize
;
2098 DBX_SYMTAB_OFFSET (objfile
) = staboffset
;
2100 if (stabstrsize
> bfd_get_size (sym_bfd
))
2101 error ("ridiculous string table size: %d bytes", stabstrsize
);
2102 DBX_STRINGTAB (objfile
) = (char *)
2103 obstack_alloc (&objfile
->psymbol_obstack
, stabstrsize
+1);
2105 /* Now read in the string table in one big gulp. */
2107 val
= bfd_seek (sym_bfd
, stabstroffset
, SEEK_SET
);
2109 perror_with_name (name
);
2110 val
= bfd_read (DBX_STRINGTAB (objfile
), stabstrsize
, 1, sym_bfd
);
2111 if (val
!= stabstrsize
)
2112 perror_with_name (name
);
2114 stabsread_new_init ();
2115 buildsym_new_init ();
2116 free_header_files ();
2117 init_header_files ();
2118 install_minimal_symbols (objfile
);
2120 processing_acc_compilation
= 1;
2122 /* In an elf file, we've already installed the minimal symbols that came
2123 from the elf (non-stab) symbol table, so always act like an
2124 incremental load here. */
2125 dbx_symfile_read (objfile
, section_offsets
, 0);
2128 /* Scan and build partial symbols for a PA symbol file.
2129 This PA file has already been processed to get its minimal symbols.
2131 OBJFILE is the object file we are reading symbols from.
2132 ADDR is the address relative to which the symbols are (e.g.
2133 the base address of the text segment).
2134 MAINLINE is true if we are reading the main symbol
2135 table (as opposed to a shared lib or dynamically loaded file).
2140 pastab_build_psymtabs (objfile
, section_offsets
, mainline
)
2141 struct objfile
*objfile
;
2142 struct section_offsets
*section_offsets
;
2145 free_header_files ();
2146 init_header_files ();
2148 /* This is needed to debug objects assembled with gas2. */
2149 processing_acc_compilation
= 1;
2151 /* In a PA file, we've already installed the minimal symbols that came
2152 from the PA (non-stab) symbol table, so always act like an
2153 incremental load here. */
2155 dbx_symfile_read (objfile
, section_offsets
, mainline
);
2158 /* Parse the user's idea of an offset for dynamic linking, into our idea
2159 of how to represent it for fast symbol reading. */
2161 static struct section_offsets
*
2162 dbx_symfile_offsets (objfile
, addr
)
2163 struct objfile
*objfile
;
2166 struct section_offsets
*section_offsets
;
2169 objfile
->num_sections
= SECT_OFF_MAX
;
2170 section_offsets
= (struct section_offsets
*)
2171 obstack_alloc (&objfile
-> psymbol_obstack
,
2172 sizeof (struct section_offsets
)
2173 + sizeof (section_offsets
->offsets
) * (SECT_OFF_MAX
-1));
2175 for (i
= 0; i
< SECT_OFF_MAX
; i
++)
2176 ANOFFSET (section_offsets
, i
) = addr
;
2178 return section_offsets
;
2181 static struct sym_fns aout_sym_fns
=
2183 bfd_target_aout_flavour
,
2184 dbx_new_init
, /* sym_new_init: init anything gbl to entire symtab */
2185 dbx_symfile_init
, /* sym_init: read initial info, setup for sym_read() */
2186 dbx_symfile_read
, /* sym_read: read a symbol file into symtab */
2187 dbx_symfile_finish
, /* sym_finish: finished with file, cleanup */
2188 dbx_symfile_offsets
, /* sym_offsets: parse user's offsets to internal form */
2189 NULL
/* next: pointer to next struct sym_fns */
2193 _initialize_dbxread ()
2195 add_symtab_fns(&aout_sym_fns
);