12#ifndef __ABG_SYMTAB_READER_H__
13#define __ABG_SYMTAB_READER_H__
20#include <unordered_map>
28namespace symtab_reader
51 {functions_ = new_value;};
58 {variables_ = new_value;};
65 {public_symbols_ = new_value;};
72 {undefined_symbols_ = new_value;};
79 {kernel_symbols_ = new_value;};
113 using value_type = base_iterator::value_type;
114 using reference = base_iterator::reference;
115 using pointer = base_iterator::pointer;
116 using difference_type = base_iterator::difference_type;
117 using iterator_category = std::forward_iterator_tag;
118 using iterator_concept = std::forward_iterator_tag;
141 base_iterator::operator++();
169 while (*
this != end_ && !filter_.
matches(***
this))
176using symtab_ptr = std::unique_ptr<symtab>;
212 {
return is_kernel_binary_ ? has_ksymtab_entries_ : !symbols_.empty();}
270 load(Elf* elf_handle,
272 symbol_predicate is_suppressed = NULL);
289 bool is_kernel_binary_;
296 bool has_ksymtab_entries_;
299 using name_symbol_map_type =
300 std::unordered_map<std::string, std::vector<elf_symbol_sptr>>;
301 name_symbol_map_type name_symbol_map_;
304 using addr_symbol_map_type = std::unordered_map<GElf_Addr, elf_symbol_sptr>;
305 addr_symbol_map_type addr_symbol_map_;
308 addr_symbol_map_type entry_addr_symbol_map_;
311 std::unordered_set<std::string> undefined_function_linkage_names_;
314 std::unordered_set<std::string> undefined_variable_linkage_names_;
316 bool cached_undefined_symbol_names_;
319 load_(Elf* elf_handle,
321 symbol_predicate is_suppressed);
328 setup_symbol_lookup_tables(Elf* elf_handle,
333 update_function_entry_address_symbol_map(Elf* elf_handle,
334 GElf_Sym* native_symbol,
338 add_alternative_address_lookups(Elf* elf_handle);
341 collect_undefined_fns_and_vars_linkage_names();
365 : tab_(tab), filter_(filter)
371 {
return tab_.
begin(filter_);}
Types of the main internal representation of libabigail.
Simplified implementation of std::optional just enough to be used as a replacement for our purposes a...
Abstraction of an elf symbol.
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Helper class to allow range-for loops on symtabs for C++11 and later code. It serves as a proxy for t...
symtab::const_iterator begin() const
Pass through symtab.begin(), but also pass on the filter.
symtab::const_iterator end() const
Pass through symtab.end().
filtered_symtab(const symtab &tab, const symtab_filter &filter)
Construct the proxy object keeping references to the underlying symtab and the filter object.
The symtab filter is the object passed to the symtab object in order to iterate over the symbols in t...
void set_public_symbols(bool new_value=true)
Enable or disable public symbol filtering.
bool matches(const elf_symbol &symbol) const
symtab_filter implementations
void set_functions(bool new_value=true)
Enable or disable function filtering.
void set_kernel_symbols(bool new_value=true)
Enable or disable kernel symbol filtering.
void set_variables(bool new_value=true)
Enable or disable variable filtering.
void set_undefined_symbols(bool new_value=true)
Enable or disable undefined symbol filtering.
An iterator to walk a vector of elf_symbols filtered by symtab_filter.
symtab_iterator(base_iterator begin, base_iterator end, const symtab_filter &filter=symtab_filter())
Construct the iterator based on a pair of underlying iterators and a symtab_filter object....
symtab_iterator operator++(int)
Post-increment operator to advance to the next matching element.
symtab_iterator & operator++()
Pre-increment operator to advance to the next matching element.
symtab is the actual data container of the symtab_reader implementation.
const elf_symbol_sptr lookup_undefined_variable_symbol(const std::string &name)
Lookup an undefined variable symbol with a given name.
const_iterator begin(const symtab_filter &filter) const
Obtain an iterator to the beginning of the symtab according to the filter criteria....
const elf_symbols & lookup_symbol(const std::string &name) const
Get a vector of symbols that are associated with a certain name.
bool has_symbols() const
Indicate whether any (kernel) symbols have been seen at construction.
symtab_filter make_filter() const
symtab implementations
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 ...
elf_symbol_sptr function_symbol_is_undefined(const string &)
Test if a name is a the name of an undefined function symbol.
elf_symbol_sptr variable_symbol_is_undefined(const string &)
Test if a name is a the name of an undefined variable symbol.
elf_symbol_sptr function_symbol_is_exported(const string &)
Test if a given function symbol has been exported.
const_iterator end() const
Obtain an iterator to the end of the symtab.
elf_symbol_sptr variable_symbol_is_exported(const string &)
Test if a given variable symbol has been exported.
const elf_symbol_sptr lookup_undefined_function_symbol(const std::string &name)
Lookup an undefined function symbol with a given name.
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.
symtab_iterator const_iterator
The (only) iterator type we offer is a const_iterator implemented by the symtab_iterator.
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
std::vector< elf_symbol_sptr > elf_symbols
Convenience typedef for a vector of elf_symbol.
shared_ptr< string_elf_symbols_map_type > string_elf_symbols_map_sptr
Convenience typedef for a shared pointer to string_elf_symbols_map_type.
Toplevel namespace for libabigail.