libabigail
|
symtab is the actual data container of the symtab_reader implementation. More...
#include <abg-symtab-reader.h>
Public Types | |
using | const_iterator |
The (only) iterator type we offer is a const_iterator implemented by the symtab_iterator. | |
using | symbol_predicate |
Public Member Functions | |
const_iterator | begin (const symtab_filter &filter) const |
Obtain an iterator to the beginning of the symtab according to the filter criteria. Whenever this iterator advances, it skips elements that do not match the filter criteria. | |
const_iterator | end () const |
Obtain an iterator to the end of the symtab. | |
elf_symbol_sptr | function_symbol_is_exported (const GElf_Addr symbol_address) |
Test if a given function symbol has been exported. | |
elf_symbol_sptr | function_symbol_is_exported (const string &) |
Test if a given function symbol has been exported. | |
elf_symbol_sptr | function_symbol_is_undefined (const string &) |
Test if a name is a the name of an undefined function symbol. | |
bool | has_symbols () const |
Indicate whether any (kernel) symbols have been seen at construction. | |
const elf_symbols & | lookup_symbol (const std::string &name) const |
Get a vector of symbols that are associated with a certain name. | |
const elf_symbol_sptr & | lookup_symbol (GElf_Addr symbol_addr) const |
Lookup a symbol by its address. | |
const elf_symbol_sptr | lookup_undefined_function_symbol (const std::string &name) |
Lookup an undefined function symbol with a given name. | |
const elf_symbol_sptr | lookup_undefined_variable_symbol (const std::string &name) |
Lookup an undefined variable symbol with a given name. | |
symtab_filter | make_filter () const |
symtab implementations | |
void | update_main_symbol (GElf_Addr addr, const std::string &name) |
Notify the symtab about the name of the main symbol at a given address. | |
elf_symbol_sptr | variable_symbol_is_exported (const GElf_Addr symbol_address) |
Test if a given variable symbol has been exported. | |
elf_symbol_sptr | variable_symbol_is_exported (const string &) |
Test if a given variable symbol has been exported. | |
elf_symbol_sptr | variable_symbol_is_undefined (const string &) |
Test if a name is a the name of an undefined variable symbol. | |
Static Public Member Functions | |
static symtab_ptr | load (Elf *elf_handle, const ir::environment &env, symbol_predicate is_suppressed=NULL) |
Construct a symtab object and instantiate it from an ELF handle. Also pass in the ir::environment we are living in. If specified, the symbol_predicate will be respected when creating the full vector of symbols. | |
static symtab_ptr | load (string_elf_symbols_map_sptr function_symbol_map, string_elf_symbols_map_sptr variables_symbol_map) |
Construct a symtab object from existing name->symbol lookup maps. They were possibly read from a different representation (XML maybe). | |
symtab is the actual data container of the symtab_reader implementation.
The symtab is instantiated either via an Elf handle (from binary) or from a set of existing symbol maps (usually when instantiated from XML). It will then discover the symtab, possibly the ksymtab (for Linux Kernel binaries) and setup the data containers and lookup maps for later perusal.
The symtab is supposed to be used in a const context as all information is already computed at construction time. Symbols are stored sorted to allow deterministic reading of the entries.
An example use of the symtab class is
const auto symtab = symtab::load(elf_handle, env); symtab_filter filter = symtab->make_filter(); filter.set_public_symbols(); filter.set_functions();
for (const auto& symbol : filtered_symtab(*symtab, filter)) { std::cout << symbol->get_name() << "\n"; }
This uses the filtered_symtab proxy object to capture the filter.
Definition at line 202 of file abg-symtab-reader.h.
using const_iterator |
The (only) iterator type we offer is a const_iterator implemented by the symtab_iterator.
Definition at line 219 of file abg-symtab-reader.h.
using symbol_predicate |
Definition at line 205 of file abg-symtab-reader.h.
|
inline |
Obtain an iterator to the beginning of the symtab according to the filter criteria. Whenever this iterator advances, it skips elements that do not match the filter criteria.
filter | the symtab_filter to match symbols against |
Definition at line 229 of file abg-symtab-reader.h.
|
inline |
Obtain an iterator to the end of the symtab.
Definition at line 236 of file abg-symtab-reader.h.
elf_symbol_sptr function_symbol_is_exported | ( | const GElf_Addr | symbol_address | ) |
Test if a given function symbol has been exported.
Note that this doesn't test if the symbol is defined or not, but assumes the symbol is defined.
symbol_address | the address of the symbol we are looking for. Note that this address must be a relative offset from the beginning of the .text section, just like the kind of addresses that are present in the .symtab section. |
Definition at line 200 of file abg-symtab-reader.cc.
elf_symbol_sptr function_symbol_is_exported | ( | const string & | name | ) |
Test if a given function symbol has been exported.
Note that this doesn't test if the symbol is defined or not, but assumes the symbol is defined.
name | the name of the symbol we are looking for. |
Definition at line 178 of file abg-symtab-reader.cc.
elf_symbol_sptr function_symbol_is_undefined | ( | const string & | sym_name | ) |
Test if a name is a the name of an undefined function symbol.
sym_name | the symbol name to consider. |
Definition at line 262 of file abg-symtab-reader.cc.
|
inline |
Indicate whether any (kernel) symbols have been seen at construction.
Definition at line 211 of file abg-symtab-reader.h.
|
static |
Construct a symtab object and instantiate it from an ELF handle. Also pass in the ir::environment we are living in. If specified, the symbol_predicate will be respected when creating the full vector of symbols.
elf_handle | the elf handle to load the symbol table from |
env | the environment we are operating in |
is_suppressed | a predicate function to determine if a symbol should be suppressed |
Definition at line 319 of file abg-symtab-reader.cc.
|
static |
Construct a symtab object from existing name->symbol lookup maps. They were possibly read from a different representation (XML maybe).
function_symbol_map | a map from ELF function name to elf_symbol |
variable_symbol_map | a map from ELF variable name to elf_symbol |
Definition at line 342 of file abg-symtab-reader.cc.
const elf_symbols & lookup_symbol | ( | const std::string & | name | ) | const |
Get a vector of symbols that are associated with a certain name.
name | the name the symbols need to match |
Definition at line 86 of file abg-symtab-reader.cc.
const elf_symbol_sptr & lookup_symbol | ( | GElf_Addr | symbol_addr | ) | const |
Lookup a symbol by its address.
symbol_addr | the starting address of the symbol |
Definition at line 101 of file abg-symtab-reader.cc.
const elf_symbol_sptr lookup_undefined_function_symbol | ( | const std::string & | sym_name | ) |
Lookup an undefined function symbol with a given name.
sym_name | the name of the function symbol to lookup. |
Definition at line 125 of file abg-symtab-reader.cc.
const elf_symbol_sptr lookup_undefined_variable_symbol | ( | const std::string & | sym_name | ) |
Lookup an undefined variable symbol with a given name.
sym_name | the name of the variable symbol to lookup. |
Definition at line 151 of file abg-symtab-reader.cc.
symtab_filter make_filter | ( | ) | const |
symtab implementations
Obtain a suitable default filter for iterating this symtab object.
The symtab_filter obtained is populated with some sensible default settings, such as public_symbols(true) and kernel_symbols(true) if the binary has been identified as Linux Kernel binary.
Definition at line 71 of file abg-symtab-reader.cc.
void update_main_symbol | ( | GElf_Addr | addr, |
const std::string & | name ) |
Notify the symtab about the name of the main symbol at a given address.
From just alone the symtab we can't guess the main symbol of a bunch of aliased symbols that all point to the same address. During processing of additional information (such as DWARF), this information becomes apparent and we can adjust the addr->symbol lookup map as well as the alias reference of the symbol objects.
addr | the addr that we are updating the main symbol for |
name | the name of the main symbol |
Definition at line 686 of file abg-symtab-reader.cc.
elf_symbol_sptr variable_symbol_is_exported | ( | const GElf_Addr | symbol_address | ) |
Test if a given variable symbol has been exported.
Note that this assumes the symbol is exported but doesn't test for it.
symbol_address | the address of the symbol we are looking for. Note that this address must be a relative offset from the beginning of the .text section, just like the kind of addresses that are present in the .symtab section. |
Definition at line 244 of file abg-symtab-reader.cc.
elf_symbol_sptr variable_symbol_is_exported | ( | const string & | name | ) |
Test if a given variable symbol has been exported.
Note that this assumes the symbol is exported but doesn't test for it.
name | the name of the symbol we are looking for. |
Definition at line 222 of file abg-symtab-reader.cc.
elf_symbol_sptr variable_symbol_is_undefined | ( | const string & | sym_name | ) |
Test if a name is a the name of an undefined variable symbol.
sym_name | the symbol name to consider. |
Definition at line 282 of file abg-symtab-reader.cc.