aboutsummaryrefslogtreecommitdiff
path: root/gdb/dbxread.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dbxread.c')
-rw-r--r--gdb/dbxread.c74
1 files changed, 54 insertions, 20 deletions
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 7acc01d..6ed23c6 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -58,6 +58,7 @@
#include "language.h" /* Needed for local_hex_string */
#include "complaints.h"
#include "cp-abi.h"
+#include "gdb_assert.h"
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
@@ -351,8 +352,8 @@ add_this_object_header_file (int i)
static void
add_old_header_file (char *name, int instance)
{
- register struct header_file *p = HEADER_FILES (current_objfile);
- register int i;
+ struct header_file *p = HEADER_FILES (current_objfile);
+ int i;
for (i = 0; i < N_HEADER_FILES (current_objfile); i++)
if (STREQ (p[i].name, name) && instance == p[i].instance)
@@ -377,8 +378,8 @@ add_old_header_file (char *name, int instance)
static void
add_new_header_file (char *name, int instance)
{
- register int i;
- register struct header_file *hfile;
+ int i;
+ struct header_file *hfile;
/* Make sure there is room for one more header file. */
@@ -420,7 +421,7 @@ add_new_header_file (char *name, int instance)
static struct type **
explicit_lookup_type (int real_filenum, int index)
{
- register struct header_file *f = &HEADER_FILES (current_objfile)[real_filenum];
+ struct header_file *f = &HEADER_FILES (current_objfile)[real_filenum];
if (index >= f->length)
{
@@ -751,8 +752,8 @@ dbx_symfile_finish (struct objfile *objfile)
{
if (HEADER_FILES (objfile) != NULL)
{
- register int i = N_HEADER_FILES (objfile);
- register struct header_file *hfiles = HEADER_FILES (objfile);
+ int i = N_HEADER_FILES (objfile);
+ struct header_file *hfiles = HEADER_FILES (objfile);
while (--i >= 0)
{
@@ -1291,12 +1292,12 @@ function_outside_compilation_unit_complaint (const char *arg1)
static void
read_dbx_symtab (struct objfile *objfile)
{
- register struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */
+ struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */
struct internal_nlist nlist;
CORE_ADDR text_addr;
int text_size;
- register char *namestring;
+ char *namestring;
int nsl;
int past_first_source_file = 0;
CORE_ADDR last_o_file_start = 0;
@@ -1304,6 +1305,7 @@ read_dbx_symtab (struct objfile *objfile)
struct cleanup *back_to;
bfd *abfd;
int textlow_not_set;
+ int data_sect_index;
/* Current partial symtab */
struct partial_symtab *pst;
@@ -1355,6 +1357,38 @@ read_dbx_symtab (struct objfile *objfile)
textlow_not_set = 1;
has_line_numbers = 0;
+ /* FIXME: jimb/2003-09-12: We don't apply the right section's offset
+ to global and static variables. The stab for a global or static
+ variable doesn't give us any indication of which section it's in,
+ so we can't tell immediately which offset in
+ objfile->section_offsets we should apply to the variable's
+ address.
+
+ We could certainly find out which section contains the variable
+ by looking up the variable's unrelocated address with
+ find_pc_section, but that would be expensive; this is the
+ function that constructs the partial symbol tables by examining
+ every symbol in the entire executable, and it's
+ performance-critical. So that expense would not be welcome. I'm
+ not sure what to do about this at the moment.
+
+ What we have done for years is to simply assume that the .data
+ section's offset is appropriate for all global and static
+ variables. Recently, this was expanded to fall back to the .bss
+ section's offset if there is no .data section, and then to the
+ .rodata section's offset. */
+ data_sect_index = objfile->sect_index_data;
+ if (data_sect_index == -1)
+ data_sect_index = SECT_OFF_BSS (objfile);
+ if (data_sect_index == -1)
+ data_sect_index = SECT_OFF_RODATA (objfile);
+
+ /* If data_sect_index is still -1, that's okay. It's perfectly fine
+ for the file to have no .data, no .bss, and no .text at all, if
+ it also has no global or static variables. If it does, we will
+ get an internal error from an ANOFFSET macro below when we try to
+ use data_sect_index. */
+
for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
{
/* Get the symbol for this run and pull out some info */
@@ -1442,8 +1476,8 @@ read_dbx_symtab (struct objfile *objfile)
if (objfile->ei.entry_point < nlist.n_value &&
objfile->ei.entry_point >= last_o_file_start)
{
- objfile->ei.entry_file_lowpc = last_o_file_start;
- objfile->ei.entry_file_highpc = nlist.n_value;
+ objfile->ei.deprecated_entry_file_lowpc = last_o_file_start;
+ objfile->ei.deprecated_entry_file_highpc = nlist.n_value;
}
if (past_first_source_file && pst
/* The gould NP1 uses low values for .o and -l symbols
@@ -1681,7 +1715,7 @@ read_dbx_symtab (struct objfile *objfile)
if (pst && STREQ (namestring, pst->filename))
continue;
{
- register int i;
+ int i;
for (i = 0; i < includes_used; i++)
if (STREQ (namestring, psymtab_include_list[i]))
{
@@ -1757,7 +1791,7 @@ read_dbx_symtab (struct objfile *objfile)
switch (p[1])
{
case 'S':
- nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+ nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
#ifdef STATIC_TRANSFORM_NAME
namestring = STATIC_TRANSFORM_NAME (namestring);
#endif
@@ -1768,7 +1802,7 @@ read_dbx_symtab (struct objfile *objfile)
psymtab_language, objfile);
continue;
case 'G':
- nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
+ nlist.n_value += ANOFFSET (objfile->section_offsets, data_sect_index);
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
add_psymbol_to_list (namestring, p - namestring,
@@ -2206,8 +2240,8 @@ read_dbx_symtab (struct objfile *objfile)
&& objfile->ei.entry_point < nlist.n_value
&& objfile->ei.entry_point >= last_o_file_start)
{
- objfile->ei.entry_file_lowpc = last_o_file_start;
- objfile->ei.entry_file_highpc = nlist.n_value;
+ objfile->ei.deprecated_entry_file_lowpc = last_o_file_start;
+ objfile->ei.deprecated_entry_file_highpc = nlist.n_value;
}
if (pst)
@@ -2554,12 +2588,12 @@ dbx_psymtab_to_symtab (struct partial_symtab *pst)
static void
read_ofile_symtab (struct partial_symtab *pst)
{
- register char *namestring;
- register struct external_nlist *bufp;
+ char *namestring;
+ struct external_nlist *bufp;
struct internal_nlist nlist;
unsigned char type;
unsigned max_symnum;
- register bfd *abfd;
+ bfd *abfd;
struct objfile *objfile;
int sym_offset; /* Offset to start of symbols to read */
int sym_size; /* Size of symbols to read */
@@ -2771,7 +2805,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
static CORE_ADDR last_pc_address;
#endif
- register struct context_stack *new;
+ struct context_stack *new;
/* This remembers the address of the start of a function. It is used
because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries are
relative to the current function's start address. On systems