#define IGNORE_SYMBOL(type) (type == (int)N_NSYMS)
#endif
-/* Macro for name of symbol to indicate a file compiled with gcc. */
-#ifndef GCC_COMPILED_FLAG_SYMBOL
-#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled."
-#endif
-
-/* Macro for name of symbol to indicate a file compiled with gcc2. */
-#ifndef GCC2_COMPILED_FLAG_SYMBOL
-#define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
-#endif
-
-/* Define this as 1 if a pcc declaration of a char or short argument
- gives the correct address. Otherwise assume pcc gives the
- address of the corresponding int, which is not the same on a
- big-endian machine. */
-
-#ifndef BELIEVE_PCC_PROMOTION
-#define BELIEVE_PCC_PROMOTION 0
-#endif
-
/* Remember what we deduced to be the source language of this psymtab. */
static enum language psymtab_language = language_unknown;
{"unknown symbol type %s", 0, 0};
struct complaint unknown_symchar_complaint =
- {"unknown symbol type character `%c'", 0, 0};
+ {"unknown symbol descriptor `%c'", 0, 0};
struct complaint lbrac_rbrac_complaint =
{"block start larger than block end", 0, 0};
static void
init_header_files PARAMS ((void));
-static struct pending *
-copy_pending PARAMS ((struct pending *, int, struct pending *));
-
static void
read_ofile_symtab PARAMS ((struct partial_symtab *));
break;
#endif
case N_TEXT:
- /* Don't put gcc_compiled, __gnu_compiled_cplus, and friends into
- the minimal symbols, because if there is also another symbol
- at the same address (e.g. the first function of the file),
- lookup_minimal_symbol_by_pc would have no way of getting the
- right one. */
- if (name[0] == 'g'
- && (strcmp (name, GCC_COMPILED_FLAG_SYMBOL) == 0
- || strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0))
- return;
-
- {
- char *tempstring = name;
- if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
- ++tempstring;
- if (STREQN (tempstring, "__gnu_compiled", 14))
- return;
- }
-
case N_NBTEXT:
case N_FN:
case N_FN_SEQ:
prim_record_minimal_symbol
(obsavestring (name, strlen (name), &objfile -> symbol_obstack),
address,
- ms_type);
+ ms_type,
+ objfile);
}
\f
/* Scan and build partial symbols for a symbol file.
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 ();
}
LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst);
pst->texthigh = capping_text;
+#ifdef N_SO_ADDRESS_MAYBE_MISSING
/* Under Solaris, the N_SO symbols always have a value of 0,
instead of the usual address of the .o file. Therefore,
we have to do some tricks to fill in texthigh and textlow.
/* this test will be true if the last .o file is only data */
if (pst->textlow == 0)
+ /* This loses if the text section really starts at address zero
+ (generally true when we are debugging a .o file, for example).
+ That is why this whole thing is inside N_SO_ADDRESS_MIGHT_LIE. */
pst->textlow = pst->texthigh;
/* If we know our own starting text address, then walk through all other
}
/* End of kludge for patching Solaris textlow and texthigh. */
-
+#endif /* NO_SO_ADDRESS_MAYBE_MISSING. */
pst->n_global_syms =
objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
if (pst->readin)
{
- fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
+ fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
pst->filename);
return;
}
/* Inform about additional files that need to be read in. */
if (info_verbose)
{
- fputs_filtered (" ", stdout);
+ fputs_filtered (" ", gdb_stdout);
wrap_here ("");
- fputs_filtered ("and ", stdout);
+ fputs_filtered ("and ", gdb_stdout);
wrap_here ("");
printf_filtered ("%s...", pst->dependencies[i]->filename);
wrap_here (""); /* Flush output */
- fflush (stdout);
+ gdb_flush (gdb_stdout);
}
dbx_psymtab_to_symtab_1 (pst->dependencies[i]);
}
if (pst->readin)
{
- fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
+ fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
pst->filename);
return;
}
if (info_verbose)
{
printf_filtered ("Reading in symbols for %s...", pst->filename);
- fflush (stdout);
+ gdb_flush (gdb_stdout);
}
sym_bfd = pst->objfile->obfd;
/* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
file. Used to detect the SunPRO solaris compiler. */
- int n_opt_found;
+ static int n_opt_found;
/* The stab type used for the definition of the last function.
N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers. */
since it would be silly to do things differently from Solaris), and
false for SunOS4 and other a.out file formats. */
block_address_function_relative =
- 0 == strncmp (bfd_get_target (objfile->obfd), "elf", 3);
+ (0 == strncmp (bfd_get_target (objfile->obfd), "elf", 3))
+ || (0 == strncmp (bfd_get_target (objfile->obfd), "som", 3));
if (!block_address_function_relative)
/* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
if (!VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
local_symbols = new->locals;
- /* If this is not the outermost LBRAC...RBRAC pair in the
- function, its local symbols preceded it, and are the ones
- just recovered from the context stack. Defined the block for them.
-
- If this is the outermost LBRAC...RBRAC pair, there is no
- need to do anything; leave the symbols that preceded it
- to be attached to the function's own block. However, if
- it is so, we need to indicate that we just moved outside
- of the function. */
- if (local_symbols
- && (context_stack_depth
- > !VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)))
+ if (context_stack_depth
+ > !VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
{
- /* FIXME Muzzle a compiler bug that makes end < start. */
- if (new->start_addr > valu)
+ /* This is not the outermost LBRAC...RBRAC pair in the function,
+ its local symbols preceded it, and are the ones just recovered
+ from the context stack. Define the block for them (but don't
+ bother if the block contains no symbols. Should we complain
+ on blocks without symbols? I can't think of any useful purpose
+ for them). */
+ if (local_symbols != NULL)
{
- complain (&lbrac_rbrac_complaint);
- new->start_addr = valu;
+ /* Muzzle a compiler bug that makes end < start. (which
+ compilers? Is this ever harmful?). */
+ if (new->start_addr > valu)
+ {
+ complain (&lbrac_rbrac_complaint);
+ new->start_addr = valu;
+ }
+ /* Make a block for the local symbols within. */
+ finish_block (0, &local_symbols, new->old_blocks,
+ new->start_addr, valu, objfile);
}
- /* Make a block for the local symbols within. */
- finish_block (0, &local_symbols, new->old_blocks,
- new->start_addr, valu, objfile);
}
else
{
+ /* This is the outermost LBRAC...RBRAC pair. There is no
+ need to do anything; leave the symbols that preceded it
+ to be attached to the function's own block. We need to
+ indicate that we just moved outside of the function. */
within_function = 0;
}
+
if (VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))
/* Now pop locals of block just finished. */
local_symbols = new->locals;
break;
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};
- complain (&msg, symnum);
- }
- common_block = local_symbols;
- common_block_i = local_symbols ? local_symbols->nsyms : 0;
+ common_block_start (name, objfile);
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 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 =
- (struct symbol *) xmmalloc (objfile -> md, sizeof (struct symbol));
- memset (sym, 0, sizeof *sym);
- SYMBOL_NAME (sym) = savestring (name, strlen (name));
- SYMBOL_CLASS (sym) = LOC_BLOCK;
- SYMBOL_NAMESPACE (sym) = (enum namespace)((long)
- copy_pending (local_symbols, common_block_i, common_block));
- i = hashname (SYMBOL_NAME (sym));
- SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
- global_sym_chain[i] = sym;
- common_block = 0;
- break;
- }
+ common_block_end (objfile);
+ break;
/* The following symbol types need to have the appropriate offset added
to their value; then we process symbol definitions in the name. */
case N_STSYM: /* Static symbol in data seg */
case N_LCSYM: /* Static symbol in BSS seg */
case N_ROSYM: /* Static symbol in Read-only data seg */
- /* HORRID HACK DEPT. However, it's Sun's furgin' fault. FIXME.
- Solaris2's stabs-in-coff makes *most* symbols relative
- but leaves a few absolute. N_STSYM and friends sit on the fence.
+ /* HORRID HACK DEPT. However, it's Sun's furgin' fault.
+ Solaris2's stabs-in-elf makes *most* symbols relative
+ but leaves a few absolute (at least for Solaris 2.1 and version
+ 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on the fence.
.stab "foo:S...",N_STSYM is absolute (ld relocates it)
.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).
-
- 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. */
+ call level, which we really don't want to do). */
{
char *p;
p = strchr (name, ':');
if (p != 0 && p[1] == 'S')
{
- /* 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. (I suspect that
- the text offset is always zero anyway--elfread.c doesn't
- process (and Sun cc doesn't produce) Ttext.text symbols). */
+ /* The linker relocated it. We don't want to add an
+ elfstab_offset_sections-type offset, but we *do* want
+ to add whatever solib.c passed to symbol_file_add as
+ addr (this is known to affect SunOS4, and I suspect ELF
+ too). Since elfstab_offset_sections currently does not
+ muck with the text offset (there is no Ttext.text
+ symbol), we can get addr from the text offset. If
+ elfstab_offset_sections ever starts dealing with the
+ text offset, and we still need to do this, we need to
+ invent a SECT_OFF_ADDR_KLUDGE or something. */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
goto define_a_symbol;
}
previous_stab_code = type;
}
\f
-/* Copy a pending list, used to record the contents of a common
- block for later fixup. We copy the symbols starting with all
- symbols in BEG, and ending with the symbols which are in
- END at index ENDI. */
-static struct pending *
-copy_pending (beg, endi, end)
- struct pending *beg;
- int endi;
- struct pending *end;
-{
- struct pending *new = 0;
- struct pending *next;
- int j;
-
- /* Copy all the struct pendings before end. */
- for (next = beg; next != NULL && next != end; next = next->next)
- {
- for (j = 0; j < next->nsyms; j++)
- add_symbol_to_list (next->symbol[j], &new);
- }
+/* 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. */
- /* 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
/* Scan and build partial symbols for an coff symbol file.
The coff file has already been processed to get its minimal symbols.
/* 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_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))
/* 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))
free_header_files ();
init_header_files ();
+ /* This is needed to debug objects assembled with gas2. */
+ processing_acc_compilation = 1;
+
/* In a PA file, we've already installed the minimal symbols that came
from the PA (non-stab) symbol table, so always act like an
incremental load here. */
{
struct section_offsets *section_offsets;
int i;
-
+
+ objfile->num_sections = SECT_OFF_MAX;
section_offsets = (struct section_offsets *)
obstack_alloc (&objfile -> psymbol_obstack,
- sizeof (struct section_offsets) +
- sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
+ sizeof (struct section_offsets)
+ + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
for (i = 0; i < SECT_OFF_MAX; i++)
ANOFFSET (section_offsets, i) = addr;
return section_offsets;
}
\f
-/* Register our willingness to decode symbols for SunOS and a.out and
- NetBSD and b.out files handled by BFD... */
-static struct sym_fns sunos_sym_fns =
-{
- "sunOs", /* sym_name: name or name prefix of BFD target type */
- 6, /* sym_namelen: number of significant sym_name chars */
- dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
- dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
- dbx_symfile_read, /* sym_read: read a symbol file into symtab */
- dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
- dbx_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */
- NULL /* next: pointer to next struct sym_fns */
-};
-
static struct sym_fns aout_sym_fns =
{
- "a.out", /* sym_name: name or name prefix of BFD target type */
- 5, /* sym_namelen: number of significant sym_name chars */
- dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
- dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
- dbx_symfile_read, /* sym_read: read a symbol file into symtab */
- dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
- dbx_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */
- NULL /* next: pointer to next struct sym_fns */
-};
-
-static struct sym_fns bout_sym_fns =
-{
- "b.out", /* sym_name: name or name prefix of BFD target type */
- 5, /* sym_namelen: number of significant sym_name chars */
+ bfd_target_aout_flavour,
dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
dbx_symfile_read, /* sym_read: read a symbol file into symtab */
void
_initialize_dbxread ()
{
- add_symtab_fns(&sunos_sym_fns);
add_symtab_fns(&aout_sym_fns);
- add_symtab_fns(&bout_sym_fns);
}