libabigail
Public Member Functions | List of all members
reader Class Reference

This is the interface an ELF reader. More...

#include <abg-elf-reader.h>

Inheritance diagram for reader:
[legend]

Public Member Functions

 reader (const std::string &elf_path, const vector< char ** > &debug_info_roots, environment &env)
 
 ~reader ()
 The destructor of the elf::reader type. More...
 
const Dwarf * alternate_dwarf_debug_info () const
 Getter of the handle use to access DWARF information from the alternate split DWARF information. More...
 
const string & alternate_dwarf_debug_info_path () const
 Getter of the path to the alternate split DWARF information file, on disk. In othe words, this returns the path to the factorized DWARF information used by the current ELF file, created by the 'DWZ' tool. More...
 
const vector< char ** > & debug_info_root_paths () const
 Getter of the vector of directory paths to look into for split debug information files. More...
 
const vector< string > & dt_needed () const
 Get the value of the DT_NEEDED property of the current ELF file. More...
 
const Dwarf * dwarf_debug_info () const
 Getter of the handle used to access DWARF information from the current ELF file. More...
 
Dwfl_Callbacks & dwfl_offline_callbacks ()
 Getter of the functions used by the DWARF Front End library of elfutils to locate DWARF debug information. More...
 
const Dwfl_Callbacks & dwfl_offline_callbacks () const
 Getter of the functions used by the DWARF Front End library of elfutils to locate DWARF debug information. More...
 
const string & elf_architecture () const
 Get the value of the 'ARCHITECTURE' property of the current ELF file. More...
 
Elf * elf_handle () const
 Getter of the handle used to access ELF information from the current ELF file. More...
 
const Elf_Scn * find_alternate_ctf_section () const
 Find and return a pointer to the alternate CTF section of the current ELF file. More...
 
const Elf_Scn * find_btf_section () const
 Find and return a pointer to the BTF section of the current ELF file. More...
 
const Elf_Scn * find_ctf_section () const
 Find and return a pointer to the the CTF section. More...
 
const Elf_Scn * find_symbol_table_section () const
 Find and return a pointer to the ELF symbol table section. More...
 
elf_symbol_sptr function_symbol_is_exported (const string &name) const
 Test if a given function symbol has been exported. More...
 
elf_symbol_sptr function_symbol_is_exported (GElf_Addr symbol_address) const
 Test if a given function symbol has been exported. More...
 
elf_symbol_sptr function_symbol_is_undefined (const string &name) const
 Test if a name is the name of an undefined function symbol. More...
 
bool has_btf_debug_info () const
 Test if the binary has BTF debug info. More...
 
bool has_ctf_debug_info () const
 Test if the binary has CTF debug info. More...
 
bool has_dwarf_debug_info () const
 Test if the binary has DWARF debug info. More...
 
virtual void initialize (const std::string &elf_path)
 Re-initialize the resources used by the current elf::reader type. More...
 
virtual void initialize (const std::string &elf_path, const vector< char ** > &debug_info_roots)
 Re-initialize the resources used by the current elf::reader type. More...
 
void load_dt_soname_and_needed ()
 Load the DT_NEEDED and DT_SONAME elf TAGS. More...
 
void load_elf_architecture ()
 Read the string representing the architecture of the current ELF file. More...
 
void load_elf_properties ()
 Load various ELF data. More...
 
virtual ir::corpus_sptr read_corpus (status &status)
 Read the ELF information associated to the current ELF file and construct an ABI representation from it. More...
 
bool refers_to_alt_debug_info (string &alt_di_path) const
 Check if the underlying elf file refers to an alternate debug info file associated to it. More...
 
void reset_symbol_table_section ()
 Clear the pointer to the ELF symbol table section. More...
 
symtab_reader::symtab_sptrsymtab () const
 Getter of an abstract representation of the symbol table of the underlying ELF file. More...
 
elf_symbol_sptr variable_symbol_is_exported (const string &name) const
 Test if a given variable symbol has been exported. More...
 
elf_symbol_sptr variable_symbol_is_exported (GElf_Addr symbol_address) const
 Test if a given variable symbol has been exported. More...
 
elf_symbol_sptr variable_symbol_is_undefined (const string &name) const
 Test if a name is the name of an undefined variable symbol. More...
 
- Public Member Functions inherited from fe_iface
 fe_iface (const std::string &corpus_path, environment &e)
 Constructor of the type fe_iface. More...
 
virtual ~fe_iface ()
 Desctructor of the Front End Interface. More...
 
void add_fn_to_exported_or_undefined_decls (const function_decl *fn)
 Add the representation of the ABI of a function to the set of exported declarations or undefined declarations of the current corpus. More...
 
void add_suppressions (const suppr::suppressions_type &)
 Add suppressions specifications to the set of suppressions to be used during the construction of the ABI internal representation (the ABI corpus) from the input file. More...
 
void add_var_to_exported_or_undefined_decls (const var_decl *var)
 Add the representation of the ABI of a variable to the set of exported or undefined declarations of the current corpus. More...
 
corpus_sptr corpus ()
 Getter for the ABI corpus being built by the current front-end. More...
 
const corpus_sptr corpus () const
 Getter for the ABI corpus being built by the current front-end. More...
 
corpus_group_sptr & corpus_group ()
 Getter for the ABI corpus group being built by the current front-end. More...
 
const corpus_group_sptr & corpus_group () const
 Getter for the ABI corpus group being built by the current front-end. More...
 
void corpus_group (const ir::corpus_group_sptr &cg)
 Setter for the ABI corpus group being built by the current front-end. More...
 
const std::string & corpus_path () const
 Getter of the path to the file which an ABI corpus is to be created for. More...
 
void corpus_path (const std::string &)
 Setter of the path to the file which an ABI corpus is to be created for. More...
 
bool current_corpus_is_main_corpus_from_current_group ()
 Test if the current corpus being built is the main corpus of the current corpus group. More...
 
const string & dt_soname () const
 Getter for the SONAME of the analyzed binary. More...
 
void dt_soname (const string &)
 Getter for the SONAME of the analyzed binary. More...
 
bool has_corpus_group () const
 Test if there is a corpus group being built. More...
 
bool load_in_linux_kernel_mode () const
 Test if the input binary is to be considered as a Linux Kernel binary. More...
 
corpus_sptr main_corpus_from_current_group ()
 Return the main corpus from the current corpus group, if any. More...
 
options_typeoptions ()
 Getter of the the options of the current Front End Interface. More...
 
const options_typeoptions () const
 Getter of the the options of the current Front End Interface. More...
 
corpus_sptr should_reuse_type_from_corpus_group ()
 Return true if the current corpus is part of a corpus group being built and if it's not the main corpus of the group. More...
 
suppr::suppressions_typesuppressions ()
 Getter of the vector of suppression specifications associated with the current front-end. More...
 
const suppr::suppressions_typesuppressions () const
 Getter of the vector of suppression specifications associated with the current front-end. More...
 
void suppressions (suppr::suppressions_type &)
 Setter of the vector of suppression specifications associated with the current front-end. More...
 

Additional Inherited Members

- Public Types inherited from fe_iface
enum  status {
  STATUS_UNKNOWN , STATUS_OK , STATUS_DEBUG_INFO_NOT_FOUND , STATUS_ALT_DEBUG_INFO_NOT_FOUND ,
  STATUS_NO_SYMBOLS_FOUND
}
 The status of the fe_iface::read_corpus call. More...
 
- Protected Attributes inherited from fe_iface
priv * priv_
 

Detailed Description

This is the interface an ELF reader.

It knows how to open an ELF file, read its content and expose an interface for its symbol table and other properties.

Note that the ABI corpus returned by the elf::read_corpus() member function doesn't contain any type representation. It only contains the representations of the the ELF symbols found in the ELF file.

To construct the type representations for the functions and global variables present in the ELF file, please use the implementations of the elf_based_reader interface. Those know how to read the debug information from the ELF file to build type representation in the abigail::ir::corpus instance.

Definition at line 62 of file abg-elf-reader.h.

Constructor & Destructor Documentation

◆ ~reader()

~reader ( )

The destructor of the elf::reader type.

Definition at line 527 of file abg-elf-reader.cc.

Member Function Documentation

◆ alternate_dwarf_debug_info()

const Dwarf * alternate_dwarf_debug_info ( ) const

Getter of the handle use to access DWARF information from the alternate split DWARF information.

In other words, this accesses the factorized DWARF information that has been constructed by the DWZ tool to de-duplicate DWARF information on disk.

Returns
the handle use to access DWARF information from the alternate split DWARF information.

Definition at line 641 of file abg-elf-reader.cc.

◆ alternate_dwarf_debug_info_path()

const string & alternate_dwarf_debug_info_path ( ) const

Getter of the path to the alternate split DWARF information file, on disk. In othe words, this returns the path to the factorized DWARF information used by the current ELF file, created by the 'DWZ' tool.

Returns
the path to the alternate split DWARF information file, on disk.

Definition at line 653 of file abg-elf-reader.cc.

◆ debug_info_root_paths()

const vector< char ** > & debug_info_root_paths ( ) const

Getter of the vector of directory paths to look into for split debug information files.

Returns
the vector of directory paths to look into for split debug information files.

Definition at line 572 of file abg-elf-reader.cc.

◆ dt_needed()

const vector< string > & dt_needed ( ) const

Get the value of the DT_NEEDED property of the current ELF file.

Returns
the value of the DT_NEEDED property.

Definition at line 744 of file abg-elf-reader.cc.

◆ dwarf_debug_info()

const Dwarf * dwarf_debug_info ( ) const

Getter of the handle used to access DWARF information from the current ELF file.

Returns
the handle used to access DWARF information from the current ELF file.

Definition at line 606 of file abg-elf-reader.cc.

◆ dwfl_offline_callbacks() [1/2]

Dwfl_Callbacks & dwfl_offline_callbacks ( )

Getter of the functions used by the DWARF Front End library of elfutils to locate DWARF debug information.

Returns
the functions used by the DWARF Front End library of

Definition at line 588 of file abg-elf-reader.cc.

◆ dwfl_offline_callbacks() [2/2]

const Dwfl_Callbacks & dwfl_offline_callbacks ( ) const

Getter of the functions used by the DWARF Front End library of elfutils to locate DWARF debug information.

Returns
the functions used by the DWARF Front End library of

Definition at line 580 of file abg-elf-reader.cc.

◆ elf_architecture()

const string & elf_architecture ( ) const

Get the value of the 'ARCHITECTURE' property of the current ELF file.

Returns
the value of the 'ARCHITECTURE' property of the current ELF file.

Definition at line 753 of file abg-elf-reader.cc.

◆ elf_handle()

Elf * elf_handle ( ) const

Getter of the handle used to access ELF information from the current ELF file.

Returns
the handle used to access ELF information from the current ELF file.

Definition at line 597 of file abg-elf-reader.cc.

◆ find_alternate_ctf_section()

const Elf_Scn * find_alternate_ctf_section ( ) const

Find and return a pointer to the alternate CTF section of the current ELF file.

Returns
a pointer to the alternate CTF section of the current ELF file.

Definition at line 718 of file abg-elf-reader.cc.

◆ find_btf_section()

const Elf_Scn * find_btf_section ( ) const

Find and return a pointer to the BTF section of the current ELF file.

Returns
a pointer to the BTF section of the current ELF file.

Definition at line 731 of file abg-elf-reader.cc.

◆ find_ctf_section()

const Elf_Scn * find_ctf_section ( ) const

Find and return a pointer to the the CTF section.

Returns
a pointer to the the CTF section.

Definition at line 701 of file abg-elf-reader.cc.

◆ find_symbol_table_section()

const Elf_Scn * find_symbol_table_section ( ) const

Find and return a pointer to the ELF symbol table section.

Returns
a pointer to the ELF symbol table section.

Definition at line 684 of file abg-elf-reader.cc.

◆ function_symbol_is_exported() [1/2]

elf_symbol_sptr function_symbol_is_exported ( const string &  name) const

Test if a given function symbol has been exported.

Parameters
namethe name of the symbol we are looking for.
Returns
the elf symbol if found, or nil otherwise.

Definition at line 847 of file abg-elf-reader.cc.

◆ function_symbol_is_exported() [2/2]

elf_symbol_sptr function_symbol_is_exported ( GElf_Addr  symbol_address) const

Test if a given function symbol has been exported.

Parameters
symbol_addressthe 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.
Returns
the elf symbol if found, or nil otherwise.

Definition at line 789 of file abg-elf-reader.cc.

◆ function_symbol_is_undefined()

elf_symbol_sptr function_symbol_is_undefined ( const string &  name) const

Test if a name is the name of an undefined function symbol.

Parameters
namethe symbol name to consider.
Returns
the undefined function symbol or nil if none was found.

Definition at line 900 of file abg-elf-reader.cc.

◆ has_btf_debug_info()

bool has_btf_debug_info ( ) const

Test if the binary has BTF debug info.

Returns
true iff the binary has BTF debug info

Definition at line 628 of file abg-elf-reader.cc.

◆ has_ctf_debug_info()

bool has_ctf_debug_info ( ) const

Test if the binary has CTF debug info.

Returns
true iff the binary has CTF debug info.

Definition at line 621 of file abg-elf-reader.cc.

◆ has_dwarf_debug_info()

bool has_dwarf_debug_info ( ) const

Test if the binary has DWARF debug info.

Returns
true iff the binary has DWARF debug info.

Definition at line 613 of file abg-elf-reader.cc.

◆ initialize() [1/2]

void initialize ( const std::string &  elf_path)
virtual

Re-initialize the resources used by the current elf::reader type.

This lets the reader in a state where it's ready to read from another ELF file.

Parameters
elf_paththe new ELF path to read from.

Reimplemented from fe_iface.

Reimplemented in elf_based_reader.

Definition at line 560 of file abg-elf-reader.cc.

◆ initialize() [2/2]

void initialize ( const std::string &  elf_path,
const vector< char ** > &  debug_info_roots 
)
virtual

Re-initialize the resources used by the current elf::reader type.

This lets the reader in a state where it's ready to read from another ELF file.

Parameters
elf_paththe new ELF path to read from.
debug_info_rootsa vector of directory paths to look into for split debug information files.

Reimplemented in elf_based_reader.

Definition at line 541 of file abg-elf-reader.cc.

◆ load_dt_soname_and_needed()

void load_dt_soname_and_needed ( )

Load the DT_NEEDED and DT_SONAME elf TAGS.

Definition at line 914 of file abg-elf-reader.cc.

◆ load_elf_architecture()

void load_elf_architecture ( )

Read the string representing the architecture of the current ELF file.

Definition at line 931 of file abg-elf-reader.cc.

◆ load_elf_properties()

void load_elf_properties ( )

Load various ELF data.

This function loads ELF data that are not symbol maps or debug info. That is, things like various tags, elf architecture and so on.

Definition at line 949 of file abg-elf-reader.cc.

◆ read_corpus()

ir::corpus_sptr read_corpus ( status status)
virtual

Read the ELF information associated to the current ELF file and construct an ABI representation from it.

Note that this reader doesn't know how to interpret any debug information so the resulting ABI corpus won't have any type information. Rather, it will only have ELF symbol representation.

To have type information, consider using readers that know how to interpret the symbolic type information comprised in DWARF, CTF or other symbolic debug information format, like the or abigail::dwarf_reader::reader, abigail::ctf_reader::reader readers.

Returns
the resulting ABI corpus.

Implements fe_iface.

Definition at line 973 of file abg-elf-reader.cc.

◆ refers_to_alt_debug_info()

bool refers_to_alt_debug_info ( string &  alt_di_path) const

Check if the underlying elf file refers to an alternate debug info file associated to it.

Note that "alternate debug info sections" is a GNU extension as of DWARF4 and is described at http://www.dwarfstd.org/ShowIssue.php?issue=120604.1.

Parameters
alt_dithe path to the alternate debug info file. This is set iff the function returns true.
Returns
true if the ELF file refers to an alternate debug info file.

Definition at line 669 of file abg-elf-reader.cc.

◆ reset_symbol_table_section()

void reset_symbol_table_section ( )

Clear the pointer to the ELF symbol table section.

Definition at line 694 of file abg-elf-reader.cc.

◆ symtab()

symtab_reader::symtab_sptr & symtab ( ) const

Getter of an abstract representation of the symbol table of the underlying ELF file.

Note that the symbol table is loaded lazily, upon the first invocation of this member function.

@returnt the symbol table.

Definition at line 764 of file abg-elf-reader.cc.

◆ variable_symbol_is_exported() [1/2]

elf_symbol_sptr variable_symbol_is_exported ( const string &  name) const

Test if a given variable symbol has been exported.

Parameters
namethe name of the symbol we are looking for.
Returns
the elf symbol if found, or nil otherwise.

Definition at line 874 of file abg-elf-reader.cc.

◆ variable_symbol_is_exported() [2/2]

elf_symbol_sptr variable_symbol_is_exported ( GElf_Addr  symbol_address) const

Test if a given variable symbol has been exported.

Parameters
symbol_addressthe 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.
Returns
the elf symbol if found, or nil otherwise.

Definition at line 820 of file abg-elf-reader.cc.

◆ variable_symbol_is_undefined()

elf_symbol_sptr variable_symbol_is_undefined ( const string &  name) const

Test if a name is the name of an undefined variable symbol.

Parameters
namethe symbol name to consider.
Returns
the undefined variable symbol or nil if none was found.

Definition at line 909 of file abg-elf-reader.cc.


The documentation for this class was generated from the following files: