aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-01-13 08:57:08 -0700
committerTom Tromey <tromey@adacore.com>2023-02-08 08:20:12 -0700
commitb8a6e9878141f5f1ac6c790e85257eadd51fff8f (patch)
tree8016847c255500606857c94e63a1e38db594acd2 /gdb/stabsread.c
parent3f01c12b9006227529823a07aee8a21627da63dd (diff)
downloadgdb-b8a6e9878141f5f1ac6c790e85257eadd51fff8f.zip
gdb-b8a6e9878141f5f1ac6c790e85257eadd51fff8f.tar.gz
gdb-b8a6e9878141f5f1ac6c790e85257eadd51fff8f.tar.bz2
Set section indices when symbols are made
Most places in gdb that create a new symbol will apply a section offset to the address. It seems to me that the choice of offset here is also an implicit choice of the section. This is particularly true if you examine fixup_section, which notes that it must be called before such offsets are applied -- meaning that if any such call has an effect, it's purely by accident. This patch cleans up this area by tracking the section index and applying it to a symbol when the address is set. This is done for nearly every case -- the remaining cases will be handled in later patches.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 8d1b998..ca9132b 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -107,8 +107,6 @@ static void
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 *);
@@ -4305,7 +4303,7 @@ common_block_end (struct objfile *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 ();
@@ -4314,8 +4312,11 @@ fix_common_block (struct symbol *sym, CORE_ADDR valu)
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);
+ }
}
}
@@ -4585,7 +4586,8 @@ scan_file_globals (struct objfile *objfile)
{
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));