This introduces a partial_symbol::address method. This method takes
an objfile argument. This is necessary so that we can later relocate
a partial symbol at its point of use. It also adds an accessor to
compute the unrelocated value; and a method to be used for setting the
field.
Note that the new method doesn't actually perform any relocation yet.
That will come in a subsequent patch. However, the comments are
written to reflect the intended, rather than the temporary, semantics.
gdb/ChangeLog
2018-07-26 Tom Tromey <tromey@redhat.com>
* psympriv.h (struct partial_symbol) <unrelocated_address,
address, set_address>: New methods.
* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
(fixup_psymbol_section, relocate_psymtabs): Update.
(print_partial_symbols): Add 'objfile' parameter. Update.
(dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map):
Update.
+2018-07-26 Tom Tromey <tromey@redhat.com>
+
+ * psympriv.h (struct partial_symbol) <unrelocated_address,
+ address, set_address>: New methods.
+ * psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
+ (fixup_psymbol_section, relocate_psymtabs): Update.
+ (print_partial_symbols): Add 'objfile' parameter. Update.
+ (dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map):
+ Update.
+
2018-07-26 Tom Tromey <tom@tromey.com>
* dwarf-index-write.c (write_psymbols, debug_names::insert)
2018-07-26 Tom Tromey <tom@tromey.com>
* dwarf-index-write.c (write_psymbols, debug_names::insert)
+ /* Return the unrelocated address of this partial symbol. */
+ CORE_ADDR unrelocated_address () const
+ {
+ return value.address;
+ }
+
+ /* Return the address of this partial symbol, relocated according to
+ the offsets provided in OBJFILE. */
+ CORE_ADDR address (const struct objfile *objfile) const
+ {
+ return value.address;
+ }
+
+ /* Set the address of this partial symbol. The address must be
+ unrelocated. */
+ void set_address (CORE_ADDR addr)
+ {
+ value.address = addr;
+ }
+
/* Name space code. */
ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;
/* Name space code. */
ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;
object's symbol table. */
p = find_pc_sect_psymbol (objfile, tpst, pc, section);
if (p != NULL
object's symbol table. */
p = find_pc_sect_psymbol (objfile, tpst, pc, section);
if (p != NULL
- && (p->value.address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
+ && (p->address (objfile) == BMSYMBOL_VALUE_ADDRESS (msymbol)))
return tpst;
/* Also accept the textlow value of a psymtab as a
return tpst;
/* Also accept the textlow value of a psymtab as a
symbol tables with line information but no debug
symbols (e.g. those produced by an assembler). */
if (p != NULL)
symbol tables with line information but no debug
symbols (e.g. those produced by an assembler). */
if (p != NULL)
- this_addr = p->value.address;
+ this_addr = p->address (objfile);
else
this_addr = tpst->textlow;
else
this_addr = tpst->textlow;
object's symbol table. */
p = find_pc_sect_psymbol (objfile, pst, pc, section);
if (p == NULL
object's symbol table. */
p = find_pc_sect_psymbol (objfile, pst, pc, section);
if (p == NULL
- || (p->value.address != BMSYMBOL_VALUE_ADDRESS (msymbol)))
+ || (p->address (objfile)
+ != BMSYMBOL_VALUE_ADDRESS (msymbol)))
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
- && pc >= p->value.address
- && (p->value.address > best_pc
+ && pc >= p->address (objfile)
+ && (p->address (objfile) > best_pc
|| (psymtab->textlow == 0
|| (psymtab->textlow == 0
- && best_pc == 0 && p->value.address == 0)))
+ && best_pc == 0 && p->address (objfile) == 0)))
{
if (section != NULL) /* Match on a specific section. */
{
{
if (section != NULL) /* Match on a specific section. */
{
- best_pc = p->value.address;
+ best_pc = p->address (objfile);
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
if (p->domain == VAR_DOMAIN
&& p->aclass == LOC_BLOCK
- && pc >= p->value.address
- && (p->value.address > best_pc
+ && pc >= p->address (objfile)
+ && (p->address (objfile) > best_pc
|| (psymtab->textlow == 0
|| (psymtab->textlow == 0
- && best_pc == 0 && p->value.address == 0)))
+ && best_pc == 0 && p->address (objfile) == 0)))
{
if (section != NULL) /* Match on a specific section. */
{
{
if (section != NULL) /* Match on a specific section. */
{
- best_pc = p->value.address;
+ best_pc = p->address (objfile);
case LOC_STATIC:
case LOC_LABEL:
case LOC_BLOCK:
case LOC_STATIC:
case LOC_LABEL:
case LOC_BLOCK:
- addr = psym->value.address;
+ addr = psym->address (objfile);
break;
default:
/* Nothing else will be listed in the minsyms -- no use looking
break;
default:
/* Nothing else will be listed in the minsyms -- no use looking
{
fixup_psymbol_section (psym, objfile);
if (psym->section >= 0)
{
fixup_psymbol_section (psym, objfile);
if (psym->section >= 0)
- psym->value.address += ANOFFSET (delta, psym->section);
+ psym->set_address (psym->unrelocated_address ()
+ + ANOFFSET (delta, psym->section));
}
for (partial_symbol *psym : objfile->static_psymbols)
{
fixup_psymbol_section (psym, objfile);
if (psym->section >= 0)
}
for (partial_symbol *psym : objfile->static_psymbols)
{
fixup_psymbol_section (psym, objfile);
if (psym->section >= 0)
- psym->value.address += ANOFFSET (delta, psym->section);
+ psym->set_address (psym->unrelocated_address ()
+ + ANOFFSET (delta, psym->section));
}
objfile->psymbol_map.clear ();
}
objfile->psymbol_map.clear ();
-print_partial_symbols (struct gdbarch *gdbarch,
+print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
struct partial_symbol **p, int count, const char *what,
struct ui_file *outfile)
{
struct partial_symbol **p, int count, const char *what,
struct ui_file *outfile)
{
break;
}
fputs_filtered (", ", outfile);
break;
}
fputs_filtered (", ", outfile);
- fputs_filtered (paddress (gdbarch, (*p)->value.address), outfile);
+ fputs_filtered (paddress (gdbarch, (*p)->unrelocated_address ()), outfile);
fprintf_filtered (outfile, "\n");
p++;
}
fprintf_filtered (outfile, "\n");
p++;
}
}
if (psymtab->n_global_syms > 0)
{
}
if (psymtab->n_global_syms > 0)
{
- print_partial_symbols (gdbarch,
+ print_partial_symbols (gdbarch, objfile,
&objfile->global_psymbols[psymtab->globals_offset],
psymtab->n_global_syms, "Global", outfile);
}
if (psymtab->n_static_syms > 0)
{
&objfile->global_psymbols[psymtab->globals_offset],
psymtab->n_global_syms, "Global", outfile);
}
if (psymtab->n_static_syms > 0)
{
- print_partial_symbols (gdbarch,
+ print_partial_symbols (gdbarch, objfile,
&objfile->static_psymbols[psymtab->statics_offset],
psymtab->n_static_syms, "Static", outfile);
}
&objfile->static_psymbols[psymtab->statics_offset],
psymtab->n_static_syms, "Static", outfile);
}
if (psym->aclass == LOC_STATIC)
{
if (psym->aclass == LOC_STATIC)
{
- CORE_ADDR addr = psym->value.address;
+ CORE_ADDR addr = psym->address (objfile);
if (seen_addrs->find (addr) == seen_addrs->end ())
{
seen_addrs->insert (addr);
if (seen_addrs->find (addr) == seen_addrs->end ())
{
seen_addrs->insert (addr);
{
struct partial_symbol psymbol;
{
struct partial_symbol psymbol;
- psymbol.value.address = coreaddr;
+ psymbol.set_address (coreaddr);
psymbol.section = -1;
psymbol.domain = domain;
psymbol.aclass = theclass;
psymbol.section = -1;
psymbol.domain = domain;
psymbol.aclass = theclass;