libabigail
|
symtab is the actual data container of the symtab_reader implementation. More...
#include <abg-symtab-reader.h>
Public Types | |
typedef symtab_iterator | const_iterator |
The (only) iterator type we offer is a const_iterator implemented by the symtab_iterator. More... | |
typedef std::function< bool(const elf_symbol_sptr &)> | 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. More... | |
const_iterator | end () const |
Obtain an iterator to the end of the symtab. More... | |
bool | has_symbols () const |
Indicate whether any (kernel) symbols have been seen at construction. More... | |
const elf_symbols & | lookup_symbol (const std::string &name) const |
Get a vector of symbols that are associated with a certain name. More... | |
const elf_symbol_sptr & | lookup_symbol (GElf_Addr symbol_addr) const |
Lookup a symbol by its address. More... | |
symtab_filter | make_filter () const |
symtab implementations More... | |
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. More... | |
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. More... | |
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). More... | |
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 201 of file abg-symtab-reader.h.
typedef symtab_iterator const_iterator |
The (only) iterator type we offer is a const_iterator implemented by the symtab_iterator.
Definition at line 218 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 228 of file abg-symtab-reader.h.
|
inline |
Obtain an iterator to the end of the symtab.
Definition at line 235 of file abg-symtab-reader.h.
|
inline |
Indicate whether any (kernel) symbols have been seen at construction.
Definition at line 210 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 141 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 164 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.
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 504 of file abg-symtab-reader.cc.