From 23e6f781518fd600041fc12ce68a19c00b9018de Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 23 Oct 2023 14:05:02 -0400 Subject: [PATCH] gdb: make get_msymbol_address a private method of minimal_symbol get_msymbol_address is only used in minimal_symbol::value_address. Make it a private helper method. Change-Id: I3f30e1b9d89ace6682fb08a7ebb91746db0ccf0f Approved-By: Tom Tromey --- gdb/symtab.c | 12 ++++++------ gdb/symtab.h | 16 +++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 46547f8b0ae..96bc481dbf5 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -439,7 +439,7 @@ CORE_ADDR minimal_symbol::value_address (objfile *objfile) const { if (this->maybe_copied (objfile)) - return get_msymbol_address (objfile, this); + return this->get_maybe_copied_address (objfile); else return (CORE_ADDR (this->unrelocated_address ()) + objfile->section_offsets[this->section_index ()]); @@ -6533,18 +6533,18 @@ get_symbol_address (const struct symbol *sym) /* See symtab.h. */ CORE_ADDR -get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym) +minimal_symbol::get_maybe_copied_address (objfile *objf) const { - gdb_assert (minsym->maybe_copied (objf)); + gdb_assert (this->maybe_copied (objf)); gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); - const char *linkage_name = minsym->linkage_name (); + const char *linkage_name = this->linkage_name (); bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, true); if (found.minsym != nullptr) return found.value_address (); - return (minsym->m_value.address - + objf->section_offsets[minsym->section_index ()]); + return (this->m_value.address + + objf->section_offsets[this->section_index ()]); } diff --git a/gdb/symtab.h b/gdb/symtab.h index 365743384e1..07f13e8952f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -716,15 +716,6 @@ enum minimal_symbol_type #define MINSYM_TYPE_BITS 4 gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS)); -/* Return the address of MINSYM, which comes from OBJF. The - MAYBE_COPIED flag must be set on MINSYM. If MINSYM appears in the - main program's minimal symbols, then that minsym's address is - returned; otherwise, MINSYM's address is returned. This should - generally only be used via the MSYMBOL_VALUE_ADDRESS macro. */ - -extern CORE_ADDR get_msymbol_address (struct objfile *objf, - const struct minimal_symbol *minsym); - /* Define a simple structure used to hold some very basic information about all defined global symbols (text, data, bss, abs, etc). The only required information is the general_symbol_info. @@ -885,6 +876,13 @@ struct minimal_symbol : public general_symbol_info address in this symbol is used. */ bool maybe_copied (objfile *objfile) const; + +private: + /* Return the address of this minimal symbol, in the context of OBJF. The + MAYBE_COPIED flag must be set. If the minimal symbol appears in the + main program's minimal symbols, then that minsym's address is + returned; otherwise, this minimal symbol's address is returned. */ + CORE_ADDR get_maybe_copied_address (objfile *objf) const; }; #include "minsyms.h" -- 2.30.2