+2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
+ and set_section_index member functions where appropriate.
+ * coffread.c (coff_symtab_read): Likewise.
+ (process_coff_symbol): Likewise.
+ * ctfread.c (set_symbol_address): Likewise.
+ * dwarf2/read.c (add_partial_symbol): Likewise.
+ (var_decode_location): Likewise.
+ * language.c: Likewise.
+ * minsyms.c (minimal_symbol_reader::record_full): Likewise.
+ (compact_minimal_symbols): Likewise.
+ (minimal_symbol_upper_bound): Likewise.
+ * objfiles.c (relocate_one_symbol): Likewise.
+ * psympriv.h (partial_symbol::obj_section): Likewise.
+ (partial_symbol::address): Likewise.
+ * psymtab.c (partial_symtab::add_psymbol): Likewise.
+ * stabsread.c (scan_file_globals): Likewise.
+ * symmisc.c (dump_msymbols): Likewise.
+ * symtab.c (general_symbol_info::obj_section): Likewise.
+ (fixup_section): Likewise.
+ (get_msymbol_address): Likewise.
+ * symtab.h (general_symbol_info::section): Rename to...
+ (general_symbol_info::m_section): ...this.
+ (general_symbol_info::set_section_index): New member function.
+ (general_symbol_info::section_index): Likewise.
+ (SYMBOL_SECTION): Delete.
+ (MSYMBOL_VALUE_ADDRESS): Make use of section_index and
+ set_section_index member functions where appropriate.
+ (MSYMBOL_SECTION): Delete.
+ (symbol::symbol): Update to initialize 'm_section'.
+ * xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
+ (process_xcoff_symbol): Likewise.
+
2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com>
* breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and
vma = BMSYMBOL_VALUE_ADDRESS (msymbol);
msymtype = MSYMBOL_TYPE (msymbol.minsym);
- section = MSYMBOL_SECTION (msymbol.minsym);
+ section = msymbol.minsym->section_index ();
/* Generate a (hopefully unique) qualified name using the first part
of the dll name, e.g. KERNEL32!AddAtomA. This matches the style
sym = process_coff_symbol
(cs, &main_aux, objfile);
SYMBOL_VALUE (sym) = tmpaddr + offset;
- SYMBOL_SECTION (sym) = sec;
+ sym->set_section_index (sec);
}
}
break;
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
+ sym->set_section_index (cs_to_section (cs, objfile));
if (ISFCN (cs->c_type))
{
{
SET_SYMBOL_VALUE_ADDRESS (sym, BMSYMBOL_VALUE_ADDRESS (msym));
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
- SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msym.minsym);
+ sym->set_section_index (msym.minsym->section_index ());
}
}
partial_symbol psymbol;
memset (&psymbol, 0, sizeof (psymbol));
psymbol.ginfo.set_language (cu->language, &objfile->objfile_obstack);
- psymbol.ginfo.section = -1;
+ psymbol.ginfo.set_section_index (-1);
/* The code below indicates that the psymbol should be installed by
setting this. */
psymbol.domain = VAR_DOMAIN;
psymbol.aclass = LOC_BLOCK;
- psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+ psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
psymbol.ginfo.value.address = addr;
if (pdi->main_subprogram && actual_name != NULL)
{
psymbol.domain = VAR_DOMAIN;
psymbol.aclass = LOC_STATIC;
- psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+ psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
psymbol.ginfo.value.address = addr;
where = psymbol_placement::GLOBAL;
}
psymbol.domain = VAR_DOMAIN;
psymbol.aclass = LOC_STATIC;
- psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+ psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
if (has_loc)
psymbol.ginfo.value.address = addr;
where = psymbol_placement::STATIC;
SET_SYMBOL_VALUE_ADDRESS
(sym,
SYMBOL_VALUE_ADDRESS (sym)
- + objfile->section_offsets[SYMBOL_SECTION (sym)]);
+ + objfile->section_offsets[sym->section_index ()]);
return;
}
}
symbol->set_language (lang, nullptr);
symbol->owner.arch = gdbarch;
SYMBOL_OBJFILE_OWNED (symbol) = 0;
- SYMBOL_SECTION (symbol) = 0;
+ symbol->set_section_index (0);
SYMBOL_TYPE (symbol) = type;
SYMBOL_DOMAIN (symbol) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (symbol) = LOC_TYPEDEF;
msymbol->m_name = name.data ();
SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
- MSYMBOL_SECTION (msymbol) = section;
+ msymbol->set_section_index (section);
MSYMBOL_TYPE (msymbol) = ms_type;
{
if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom)
== MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1))
- && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1)
+ && (copyfrom->section_index ()
+ == (copyfrom + 1)->section_index ())
&& strcmp (copyfrom->linkage_name (),
(copyfrom + 1)->linkage_name ()) == 0)
{
= (minsym.objfile->per_bfd->msymbols.get ()
+ minsym.objfile->per_bfd->minimal_symbol_count);
msymbol = minsym.minsym;
- section = MSYMBOL_SECTION (msymbol);
+ section = msymbol->section_index ();
for (iter = msymbol + 1; iter != past_the_end; ++iter)
{
if ((MSYMBOL_VALUE_RAW_ADDRESS (iter)
!= MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
- && MSYMBOL_SECTION (iter) == section)
+ && iter->section_index () == section)
break;
}
they can't possibly pass the tests below. */
if ((SYMBOL_CLASS (sym) == LOC_LABEL
|| SYMBOL_CLASS (sym) == LOC_STATIC)
- && SYMBOL_SECTION (sym) >= 0)
+ && sym->section_index () >= 0)
{
SET_SYMBOL_VALUE_ADDRESS (sym,
SYMBOL_VALUE_ADDRESS (sym)
- + delta[SYMBOL_SECTION (sym)]);
+ + delta[sym->section_index ()]);
}
}
section has been set. */
struct obj_section *obj_section (struct objfile *objfile) const
{
- if (ginfo.section >= 0)
- return &objfile->sections[ginfo.section];
- return nullptr;
+ return ginfo.obj_section (objfile);
}
/* Return the unrelocated address of this partial symbol. */
the offsets provided in OBJFILE. */
CORE_ADDR address (const struct objfile *objfile) const
{
- return ginfo.value.address + objfile->section_offsets[ginfo.section];
+ return (ginfo.value.address
+ + objfile->section_offsets[ginfo.section_index ()]);
}
/* Set the address of this partial symbol. The address must be
memset (&psymbol, 0, sizeof (psymbol));
psymbol.set_unrelocated_address (coreaddr);
- psymbol.ginfo.section = section;
+ psymbol.ginfo.set_section_index (section);
psymbol.domain = domain;
psymbol.aclass = theclass;
psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
(sym, MSYMBOL_VALUE_ADDRESS (resolve_objfile,
msymbol));
}
- SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msymbol);
+ sym->set_section_index (msymbol->section_index ());
}
if (prev)
/* Use the relocated address as shown in the symbol here -- do
not try to respect copy relocations. */
CORE_ADDR addr = (msymbol->value.address
- + objfile->section_offsets[msymbol->section]);
+ + objfile->section_offsets[msymbol->section_index ()]);
fputs_filtered (paddress (gdbarch, addr), outfile);
fprintf_filtered (outfile, " %s", msymbol->linkage_name ());
if (section)
struct obj_section *
general_symbol_info::obj_section (const struct objfile *objfile) const
{
- if (section >= 0)
- return &objfile->sections[section];
+ if (section_index () >= 0)
+ return &objfile->sections[section_index ()];
return nullptr;
}
msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
objfile);
if (msym)
- ginfo->section = MSYMBOL_SECTION (msym);
+ ginfo->set_section_index (msym->section_index ());
else
{
/* Static, function-local variables do appear in the linker
if (obj_section_addr (s) - offset <= addr
&& addr < obj_section_endaddr (s) - offset)
{
- ginfo->section = idx;
+ ginfo->set_section_index (idx);
return;
}
}
section. If there is no allocated section, then it hardly
matters what we pick, so just pick zero. */
if (fallback == -1)
- ginfo->section = 0;
+ ginfo->set_section_index (0);
else
- ginfo->section = fallback;
+ ginfo->set_section_index (fallback);
}
}
return BMSYMBOL_VALUE_ADDRESS (found);
}
}
- return minsym->value.address + objf->section_offsets[minsym->section];
+ return (minsym->value.address
+ + objf->section_offsets[minsym->section_index ()]);
}
\f
section_offsets for this objfile. Negative means that the symbol
does not get relocated relative to a section. */
- short section;
+ short m_section;
+
+ /* Set the index into the obj_section list (within the containing
+ objfile) for the section that contains this symbol. See M_SECTION
+ for more details. */
+
+ void set_section_index (short idx)
+ { m_section = idx; }
+
+ /* Return the index into the obj_section list (within the containing
+ objfile) for the section that contains this symbol. See M_SECTION
+ for more details. */
+
+ short section_index () const
+ { return m_section; }
/* Return the obj_section from OBJFILE for this symbol. The symbol
returned is based on the SECTION member variable, and can be nullptr
#define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
-#define SYMBOL_SECTION(symbol) (symbol)->section
/* Try to determine the demangled name for a symbol, based on the
language of that symbol. If the language is set to language_auto,
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \
(((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol) \
: ((symbol)->value.address \
- + (objfile)->section_offsets[(symbol)->section]))
+ + (objfile)->section_offsets[(symbol)->section_index ()]))
/* For a bound minsym, we can easily compute the address directly. */
#define BMSYMBOL_VALUE_ADDRESS(symbol) \
MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
#define MSYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
#define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
#define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
-#define MSYMBOL_SECTION(symbol) (symbol)->section
#include "minsyms.h"
language_specific.obstack = nullptr;
m_language = language_unknown;
ada_mangled = 0;
- section = -1;
+ m_section = -1;
/* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
initialization of unions, so we initialize it manually here. */
owner.symtab = nullptr;
(fcn_cs_saved.c_value + off,
fcn_stab_saved.c_name, 0, 0, objfile);
if (newobj->name != NULL)
- SYMBOL_SECTION (newobj->name) = SECT_OFF_TEXT (objfile);
+ newobj->name->set_section_index (SECT_OFF_TEXT (objfile));
}
else if (strcmp (cs->c_name, ".ef") == 0)
{
/* default assumptions */
SET_SYMBOL_VALUE_ADDRESS (sym, cs->c_value + off);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- SYMBOL_SECTION (sym) = secnum_to_section (cs->c_secnum, objfile);
+ sym->set_section_index (secnum_to_section (cs->c_secnum, objfile));
if (ISFCN (cs->c_type))
{
sym = define_symbol (cs->c_value + off, cs->c_name, 0, 0, objfile);
if (sym != NULL)
{
- SYMBOL_SECTION (sym) = sec;
+ sym->set_section_index (sec);
}
return sym;
}
SET_SYMBOL_VALUE_ADDRESS (sym,
SYMBOL_VALUE_ADDRESS (sym)
+ static_block_base);
- SYMBOL_SECTION (sym) = static_block_section;
+ sym->set_section_index (static_block_section);
}
return sym;