unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
/* Allocate struct to keep track of the symfile */
- objfile->sym_private = (PTR)
+ objfile->sym_stab_info = (PTR)
xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
dbx_symfile_finish (objfile)
struct objfile *objfile;
{
- if (objfile->sym_private != NULL)
+ if (objfile->sym_stab_info != NULL)
{
- mfree (objfile -> md, objfile->sym_private);
+ mfree (objfile -> md, objfile->sym_stab_info);
}
free_header_files ();
}
if (minsym) {
pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) +
- (int) MSYMBOL_INFO (minsym);
+ (long) MSYMBOL_INFO (minsym);
} else {
/* This file ends with a static function, and it's
difficult to imagine how hard it would be to track down
case N_BCOMM:
if (common_block)
{
+ /* Note: this does not detect nesting if the previous N_BCOMM
+ was at the beginning of a scope (and thus common_block was
+ NULL). Not necessarily worth worrying about unless we run
+ into a compiler which actually has this bug. */
static struct complaint msg = {
"Invalid symbol data: common within common at symtab pos %d",
0, 0};
break;
case N_ECOMM:
+
/* Symbols declared since the BCOMM are to have the common block
- start address added in when we know it. common_block points to
- the first symbol after the BCOMM in the local_symbols list;
- copy the list and hang it off the symbol for the common block name
- for later fixup. */
+ start address added in when we know it. common_block and
+ common_block_i point to the first symbol after the BCOMM in
+ the local_symbols list; copy the list and hang it off the
+ symbol for the common block name for later fixup. */
+
+ /* If there is a N_ECOMM unmatched by a N_BCOMM, we treat all
+ the local_symbols as part of the common block. It might be
+ better to just ignore the N_ECOMM, but then we'd need to
+ distinguish between a N_BCOMM at the start of a scope, or no
+ N_BCOMM at all (currently they both have common_block NULL).
+ Not necessarily worth worrying about unless we run into a
+ compiler which actually has this bug. */
+
{
int i;
struct symbol *sym =
.stab "foo:V...",N_STSYM is relative (section base subtracted).
This leaves us no choice but to search for the 'S' or 'V'...
(or pass the whole section_offsets stuff down ONE MORE function
- call level, which we really don't want to do). */
+ call level, which we really don't want to do).
+
+ The above is indeed true for Solaris 2.1. I'm not sure what
+ happens in Solaris 2.3, in which ld stops relocating stabs. */
{
char *p;
p = strchr (name, ':');
{
/* FIXME! We relocate it by the TEXT offset, in case the
whole module moved in memory. But this is wrong, since
- the sections can side around independently. */
+ the sections can side around independently. (I suspect that
+ the text offset is always zero anyway--elfread.c doesn't
+ process (and Sun cc doesn't produce) Ttext.text symbols). */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
goto define_a_symbol;
}
case N_NBBSS:
case N_NBSTS:
case N_NBLCS:
- complain (&unknown_symtype_complaint, local_hex_string(type));
+ complain (&unknown_symtype_complaint,
+ local_hex_string((unsigned long) type));
/* FALLTHROUGH */
/* The following symbol types don't need the address field relocated,
/* On solaris up to 2.2, the N_FUN stab gets relocated.
On Solaris 2.3, ld no longer relocates stabs (which
is good), and the N_FUN's value is now always zero.
- We only provide this correction for functions, not for
- all N_FUN symbols, because that is easiest and all
- readonly variables seem to go in the .rodata on Solaris. */
+ The following code can't deal with this, because
+ last_pc_address depends on getting the address from a
+ N_SLINE or some such and in Solaris those are function
+ relative. Best fix is probably to create a Ttext.text symbol
+ and handle this like Ddata.data and so on. */
- if (type == N_GSYM || type == N_STSYM
- || (type == N_FUN && valu == 0))
+ if (type == N_GSYM || type == N_STSYM)
{
struct minimal_symbol *m;
int l = colon_pos - name;
add_symbol_to_list (next->symbol[j], &new);
}
- /* Copy however much of END we need. */
- for (j = endi; j < end->nsyms; j++)
- add_symbol_to_list (end->symbol[j], &new);
+ /* Copy however much of END we need. If END is NULL, it means copy
+ all the local symbols (which we already did above). */
+ if (end != NULL)
+ for (j = endi; j < end->nsyms; j++)
+ add_symbol_to_list (end->symbol[j], &new);
return new;
}
\f
+/* FIXME: The only difference between this and elfstab_build_psymtabs is
+ the call to install_minimal_symbols for elf. If the differences are
+ really that small, the code should be shared. */
+
+/* Scan and build partial symbols for an coff symbol file.
+ The coff file has already been processed to get its minimal symbols.
+
+ This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
+ rolled into one.
+
+ OBJFILE is the object file we are reading symbols from.
+ ADDR is the address relative to which the symbols are (e.g.
+ the base address of the text segment).
+ MAINLINE is true if we are reading the main symbol
+ table (as opposed to a shared lib or dynamically loaded file).
+ STABOFFSET and STABSIZE define the location in OBJFILE where the .stab
+ section exists.
+ STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
+ .stabstr section exists.
+
+ This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
+ adjusted for coff details. */
+
+void
+coffstab_build_psymtabs (objfile, section_offsets, mainline,
+ staboffset, stabsize,
+ stabstroffset, stabstrsize)
+ struct objfile *objfile;
+ struct section_offsets *section_offsets;
+ int mainline;
+ file_ptr staboffset;
+ unsigned int stabsize;
+ file_ptr stabstroffset;
+ unsigned int stabstrsize;
+{
+ int val;
+ bfd *sym_bfd = objfile->obfd;
+ char *name = bfd_get_filename (sym_bfd);
+ struct dbx_symfile_info *info;
+
+ /* There is already a dbx_symfile_info allocated by our caller.
+ It might even contain some info from the coff symtab to help us. */
+ info = (struct dbx_symfile_info *) objfile->sym_stab_info;
+
+ DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
+ if (!DBX_TEXT_SECT (objfile))
+ error ("Can't find .text section in symbol file");
+
+#define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
+ DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE;
+ DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
+ DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
+ DBX_SYMTAB_OFFSET (objfile) = staboffset;
+
+ if (stabstrsize > bfd_get_size (sym_bfd))
+ error ("ridiculous string table size: %d bytes", stabstrsize);
+ DBX_STRINGTAB (objfile) = (char *)
+ obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
+
+ /* Now read in the string table in one big gulp. */
+
+ val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
+ if (val < 0)
+ perror_with_name (name);
+ val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, 1, sym_bfd);
+ if (val != stabstrsize)
+ perror_with_name (name);
+
+ stabsread_new_init ();
+ buildsym_new_init ();
+ free_header_files ();
+ init_header_files ();
+
+ processing_acc_compilation = 1;
+
+ /* In a coff file, we've already installed the minimal symbols that came
+ from the coff (non-stab) symbol table, so always act like an
+ incremental load here. */
+ dbx_symfile_read (objfile, section_offsets, 0);
+}
+\f
/* Scan and build partial symbols for an ELF symbol file.
This ELF file has already been processed to get its minimal symbols,
and any DWARF symbols that were in it.
/* There is already a dbx_symfile_info allocated by our caller.
It might even contain some info from the ELF symtab to help us. */
- info = (struct dbx_symfile_info *) objfile->sym_private;
+ info = (struct dbx_symfile_info *) objfile->sym_stab_info;
DBX_TEXT_SECT (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
if (!DBX_TEXT_SECT (objfile))