source file. Used to detect the SunPRO solaris compiler. */
static int n_opt_found;
+ /* The section index for this symbol. */
+ int section_index = -1;
+
/* Something is wrong if we see real data before seeing a source
file name. */
sline_found_in_function = 0;
/* Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
valu = gdbarch_addr_bits_remove (gdbarch, valu);
last_function_start = valu;
case N_FN_SEQ:
/* This kind of symbol indicates the start of an object file.
Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
break;
source file. Finish the symbol table of the previous source
file (if any) and start accumulating a new symbol table.
Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
n_opt_found = 0;
sub-source-file, one whose contents were copied or included
in the compilation of the main source file (whose name was
given in the N_SO symbol). Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
start_subfile (name);
break;
symbol_file_add as addr (this is known to affect
SunOS 4, and I suspect ELF too). Since there is no
Ttext.text symbol, we can get addr from the text offset. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
goto define_a_symbol;
}
case_N_STSYM: /* Static symbol in data segment. */
case N_DSLINE: /* Source line number, data segment. */
+ section_index = SECT_OFF_DATA (objfile);
valu += section_offsets[SECT_OFF_DATA (objfile)];
goto define_a_symbol;
case_N_LCSYM: /* Static symbol in BSS segment. */
case N_BSLINE: /* Source line number, BSS segment. */
/* N_BROWS: overlaps with N_BSLINE. */
+ section_index = SECT_OFF_BSS (objfile);
valu += section_offsets[SECT_OFF_BSS (objfile)];
goto define_a_symbol;
case_N_ROSYM: /* Static symbol in read-only data segment. */
+ section_index = SECT_OFF_RODATA (objfile);
valu += section_offsets[SECT_OFF_RODATA (objfile)];
goto define_a_symbol;
case N_ENTRY: /* Alternate entry point. */
/* Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
valu += section_offsets[SECT_OFF_TEXT (objfile)];
goto define_a_symbol;
newobj = push_context (0, valu);
newobj->name = define_symbol (valu, name, desc, type, objfile);
+ if (newobj->name != nullptr)
+ newobj->name->set_section_index (section_index);
break;
default:
- define_symbol (valu, name, desc, type, objfile);
+ {
+ struct symbol *sym = define_symbol (valu, name, desc, type,
+ objfile);
+ if (sym != nullptr)
+ sym->set_section_index (section_index);
+ }
break;
}
}
addr = attr->as_address ();
addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
+ sym->set_section_index (SECT_OFF_TEXT (objfile));
sym->set_value_address (addr);
sym->set_aclass_index (LOC_LABEL);
}
else
name = debug_info->ss + cur_fdr->issBase + sh->iss;
+ int section_index = -1;
switch (sh->sc)
{
case scText:
The value of a stBlock symbol is the displacement from the
procedure address. */
if (sh->st != stEnd && sh->st != stBlock)
- sh->value += section_offsets[SECT_OFF_TEXT (objfile)];
+ section_index = SECT_OFF_TEXT (objfile);
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
- sh->value += section_offsets[SECT_OFF_DATA (objfile)];
+ section_index = SECT_OFF_DATA (objfile);
break;
case scBss:
case scSBss:
- sh->value += section_offsets[SECT_OFF_BSS (objfile)];
+ section_index = SECT_OFF_BSS (objfile);
break;
}
+ if (section_index != -1)
+ sh->value += section_offsets[section_index];
+
switch (sh->st)
{
case stNil:
case stGlobal: /* External symbol, goes into global block. */
b = top_stack->cur_st->compunit ()->blockvector ()->global_block ();
s = new_symbol (name);
+ s->set_section_index (section_index);
s->set_value_address (sh->value);
add_data_symbol (sh, ax, bigend, s, LOC_STATIC, b, objfile, name);
break;
global_sym_chain[bucket] = s;
}
else
- s->set_value_address (sh->value);
+ {
+ s->set_section_index (section_index);
+ s->set_value_address (sh->value);
+ }
add_data_symbol (sh, ax, bigend, s, LOC_STATIC, b, objfile, name);
break;
s = new_symbol (name);
s->set_domain (VAR_DOMAIN); /* So that it can be used */
s->set_aclass_index (LOC_LABEL); /* but not misused. */
+ s->set_section_index (section_index);
s->set_value_address (sh->value);
s->set_type (objfile_type (objfile)->builtin_int);
add_symbol (s, top_stack->cur_st, top_stack->cur_block);
s = new_symbol (name);
s->set_domain (VAR_DOMAIN);
s->set_aclass_index (LOC_BLOCK);
+ s->set_section_index (section_index);
/* Type of the return value. */
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
t = objfile_type (objfile)->builtin_int;
patch_block_stabs (struct pending *, struct pending_stabs *,
struct objfile *);
-static void fix_common_block (struct symbol *, CORE_ADDR);
-
static int read_type_number (const char **, int *);
static struct type *read_type (const char **, struct objfile *);
the common block name). */
static void
-fix_common_block (struct symbol *sym, CORE_ADDR valu)
+fix_common_block (struct symbol *sym, CORE_ADDR valu, int section_index)
{
struct pending *next = (struct pending *) sym->type ();
int j;
for (j = next->nsyms - 1; j >= 0; j--)
- next->symbol[j]->set_value_address
- (next->symbol[j]->value_address () + valu);
+ {
+ next->symbol[j]->set_value_address
+ (next->symbol[j]->value_address () + valu);
+ next->symbol[j]->set_section_index (section_index);
+ }
}
}
\f
{
if (sym->aclass () == LOC_BLOCK)
fix_common_block
- (sym, msymbol->value_address (resolve_objfile));
+ (sym, msymbol->value_address (resolve_objfile),
+ msymbol->section_index ());
else
sym->set_value_address
(msymbol->value_address (resolve_objfile));