forked from Imagelibrary/binutils-gdb
Introduce lookup_minimal_symbol_linkage
This introduces a new function, lookup_minimal_symbol_linkage, and refactors a couple other existing functions to call it. This function will be used in a subsequent patch.
This commit is contained in:
@@ -592,6 +592,28 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf)
|
|||||||
|
|
||||||
/* See minsyms.h. */
|
/* See minsyms.h. */
|
||||||
|
|
||||||
|
struct bound_minimal_symbol
|
||||||
|
lookup_minimal_symbol_linkage (const char *name, bool only_main)
|
||||||
|
{
|
||||||
|
for (objfile *objfile : current_program_space->objfiles ())
|
||||||
|
{
|
||||||
|
if (objfile->separate_debug_objfile_backlink != nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (only_main && (objfile->flags & OBJF_MAINLINE) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name,
|
||||||
|
objfile);
|
||||||
|
if (minsym.minsym != nullptr)
|
||||||
|
return minsym;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See minsyms.h. */
|
||||||
|
|
||||||
struct bound_minimal_symbol
|
struct bound_minimal_symbol
|
||||||
lookup_minimal_symbol_text (const char *name, struct objfile *objf)
|
lookup_minimal_symbol_text (const char *name, struct objfile *objf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -236,6 +236,14 @@ extern struct bound_minimal_symbol lookup_minimal_symbol_linkage
|
|||||||
(const char *name, struct objfile *objf)
|
(const char *name, struct objfile *objf)
|
||||||
ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2);
|
ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2);
|
||||||
|
|
||||||
|
/* A variant of lookup_minimal_symbol_linkage that iterates over all
|
||||||
|
objfiles. If ONLY_MAIN is true, then only an objfile with
|
||||||
|
OBJF_MAINLINE will be considered. */
|
||||||
|
|
||||||
|
extern struct bound_minimal_symbol lookup_minimal_symbol_linkage
|
||||||
|
(const char *name, bool only_main)
|
||||||
|
ATTRIBUTE_NONNULL (1);
|
||||||
|
|
||||||
/* Look through all the current minimal symbol tables and find the
|
/* Look through all the current minimal symbol tables and find the
|
||||||
first minimal symbol that matches NAME and PC. If OBJF is non-NULL,
|
first minimal symbol that matches NAME and PC. If OBJF is non-NULL,
|
||||||
limit the search to that objfile. Returns a pointer to the minimal
|
limit the search to that objfile. Returns a pointer to the minimal
|
||||||
|
|||||||
31
gdb/symtab.c
31
gdb/symtab.c
@@ -6496,17 +6496,10 @@ get_symbol_address (const struct symbol *sym)
|
|||||||
gdb_assert (sym->aclass () == LOC_STATIC);
|
gdb_assert (sym->aclass () == LOC_STATIC);
|
||||||
|
|
||||||
const char *linkage_name = sym->linkage_name ();
|
const char *linkage_name = sym->linkage_name ();
|
||||||
|
bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name,
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
false);
|
||||||
{
|
if (minsym.minsym != nullptr)
|
||||||
if (objfile->separate_debug_objfile_backlink != nullptr)
|
return minsym.value_address ();
|
||||||
continue;
|
|
||||||
|
|
||||||
bound_minimal_symbol minsym
|
|
||||||
= lookup_minimal_symbol_linkage (linkage_name, objfile);
|
|
||||||
if (minsym.minsym != nullptr)
|
|
||||||
return minsym.value_address ();
|
|
||||||
}
|
|
||||||
return sym->m_value.address;
|
return sym->m_value.address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6519,18 +6512,10 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
|
|||||||
gdb_assert ((objf->flags & OBJF_MAINLINE) == 0);
|
gdb_assert ((objf->flags & OBJF_MAINLINE) == 0);
|
||||||
|
|
||||||
const char *linkage_name = minsym->linkage_name ();
|
const char *linkage_name = minsym->linkage_name ();
|
||||||
|
bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name,
|
||||||
for (objfile *objfile : current_program_space->objfiles ())
|
true);
|
||||||
{
|
if (found.minsym != nullptr)
|
||||||
if (objfile->separate_debug_objfile_backlink == nullptr
|
return found.value_address ();
|
||||||
&& (objfile->flags & OBJF_MAINLINE) != 0)
|
|
||||||
{
|
|
||||||
bound_minimal_symbol found
|
|
||||||
= lookup_minimal_symbol_linkage (linkage_name, objfile);
|
|
||||||
if (found.minsym != nullptr)
|
|
||||||
return found.value_address ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (minsym->m_value.address
|
return (minsym->m_value.address
|
||||||
+ objf->section_offsets[minsym->section_index ()]);
|
+ objf->section_offsets[minsym->section_index ()]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user