mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-17 13:10:12 +08:00
gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros
Delete two more symbol/section related macros. This time it's SYMBOL_SECTION and MSYMBOL_SECTION. As with general_symbol_info::m_name it is not currently possible to make general_symbol_info::m_section private as general_symbol_info must remain a POD type. But other than failing to make the new m_section private, this change does what you'd expect, adds a get and set member function and updates all users to use the new functions instead of the previous wrapper macros. There should be no user visible change after this commit. gdb/ChangeLog: * 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.
This commit is contained in:
parent
ebbc3a7d56
commit
a52d653e91
@ -1,3 +1,37 @@
|
||||
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
|
||||
|
@ -246,7 +246,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
|
||||
|
||||
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
|
||||
|
@ -1026,7 +1026,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
|
||||
sym = process_coff_symbol
|
||||
(cs, &main_aux, objfile);
|
||||
SYMBOL_VALUE (sym) = tmpaddr + offset;
|
||||
SYMBOL_SECTION (sym) = sec;
|
||||
sym->set_section_index (sec);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1565,7 +1565,7 @@ process_coff_symbol (struct coff_symbol *cs,
|
||||
/* 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))
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
|
||||
{
|
||||
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 ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8612,7 +8612,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
|
||||
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. */
|
||||
@ -8641,7 +8641,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
|
||||
|
||||
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)
|
||||
@ -8686,7 +8686,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -8702,7 +8702,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
|
||||
|
||||
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;
|
||||
@ -22100,7 +22100,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
|
||||
SET_SYMBOL_VALUE_ADDRESS
|
||||
(sym,
|
||||
SYMBOL_VALUE_ADDRESS (sym)
|
||||
+ objfile->section_offsets[SYMBOL_SECTION (sym)]);
|
||||
+ objfile->section_offsets[sym->section_index ()]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1052,7 +1052,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
|
||||
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;
|
||||
|
@ -1157,7 +1157,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
|
||||
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;
|
||||
|
||||
@ -1246,7 +1246,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -1551,12 +1552,12 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
|
||||
= (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;
|
||||
}
|
||||
|
||||
|
@ -621,11 +621,11 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
|
||||
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 ()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,7 @@ struct partial_symbol
|
||||
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. */
|
||||
@ -55,7 +53,8 @@ struct 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
|
||||
|
@ -1556,7 +1556,7 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
|
||||
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 ());
|
||||
|
@ -4590,7 +4590,7 @@ scan_file_globals (struct objfile *objfile)
|
||||
(sym, MSYMBOL_VALUE_ADDRESS (resolve_objfile,
|
||||
msymbol));
|
||||
}
|
||||
SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msymbol);
|
||||
sym->set_section_index (msymbol->section_index ());
|
||||
}
|
||||
|
||||
if (prev)
|
||||
|
@ -240,7 +240,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
|
||||
/* 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)
|
||||
|
15
gdb/symtab.c
15
gdb/symtab.c
@ -1015,8 +1015,8 @@ general_symbol_info::search_name () const
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1655,7 +1655,7 @@ fixup_section (struct general_symbol_info *ginfo,
|
||||
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
|
||||
@ -1707,7 +1707,7 @@ fixup_section (struct general_symbol_info *ginfo,
|
||||
if (obj_section_addr (s) - offset <= addr
|
||||
&& addr < obj_section_endaddr (s) - offset)
|
||||
{
|
||||
ginfo->section = idx;
|
||||
ginfo->set_section_index (idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1716,9 +1716,9 @@ fixup_section (struct general_symbol_info *ginfo,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6472,7 +6472,8 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
|
||||
return BMSYMBOL_VALUE_ADDRESS (found);
|
||||
}
|
||||
}
|
||||
return minsym->value.address + objf->section_offsets[minsym->section];
|
||||
return (minsym->value.address
|
||||
+ objf->section_offsets[minsym->section_index ()]);
|
||||
}
|
||||
|
||||
|
||||
|
22
gdb/symtab.h
22
gdb/symtab.h
@ -539,7 +539,21 @@ struct general_symbol_info
|
||||
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
|
||||
@ -570,7 +584,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
|
||||
#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,
|
||||
@ -755,7 +768,7 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
|
||||
#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)
|
||||
@ -764,7 +777,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
|
||||
#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"
|
||||
|
||||
@ -1118,7 +1130,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
|
||||
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;
|
||||
|
@ -1372,7 +1372,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
|
||||
(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)
|
||||
{
|
||||
@ -1559,7 +1559,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
|
||||
/* 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))
|
||||
{
|
||||
@ -1625,7 +1625,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
|
||||
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;
|
||||
}
|
||||
@ -1657,7 +1657,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user