LIEF: Library to Instrument Executable Formats Version 0.17.0
|
This class represents a DWARF compilation unit. More...
#include <CompilationUnit.hpp>
Classes | |
class | Iterator |
class | Language |
Languages supported by the DWARF (v5) format. See: https://dwarfstd.org/languages.html. More... | |
Public Types | |
using | functions_it = iterator_range<Function::Iterator> |
Iterator over the dwarf::Function. | |
using | types_it = iterator_range<Type::Iterator> |
Iterator over the dwarf::Type. | |
using | vars_it = iterator_range<Variable::Iterator> |
Iterator over the CompilationUnit's variables. | |
Public Member Functions | |
CompilationUnit (std::unique_ptr< details::CompilationUnit > impl) | |
~CompilationUnit () | |
std::string | name () const |
Name of the file associated with this compilation unit (e.g. test.cpp ) Return an empty string if the name is not found or can't be resolved. | |
std::string | producer () const |
Information about the program (or library) that generated this compilation unit. For instance, it can output: Debian clang version 17.0.6 . | |
std::string | compilation_dir () const |
Return the path to the directory in which the compilation took place for compiling this compilation unit (e.g. /workdir/build ) | |
Language | language () const |
Original Language of this compilation unit. | |
uint64_t | low_address () const |
Return the lowest virtual address owned by this compilation unit. | |
uint64_t | high_address () const |
Return the highest virtual address owned by this compilation unit. | |
uint64_t | size () const |
Return the size of the compilation unit according to its range of address. | |
std::vector< range_t > | ranges () const |
Return a list of address ranges owned by this compilation unit. | |
std::unique_ptr< Function > | find_function (const std::string &name) const |
Try to find the function whose name is given in parameter. | |
std::unique_ptr< Function > | find_function (uint64_t addr) const |
Try to find the function at the given address. | |
std::unique_ptr< Variable > | find_variable (uint64_t addr) const |
Try to find the Variable at the given address. | |
std::unique_ptr< Variable > | find_variable (const std::string &name) const |
Try to find the Variable with the given name. | |
functions_it | functions () const |
Return an iterator over the functions implemented in this compilation unit. | |
functions_it | imported_functions () const |
Return an iterator over the functions imported in this compilation unit but not implemented. | |
types_it | types () const |
Return an iterator over the different types defined in this compilation unit. | |
vars_it | variables () const |
Return an iterator over all the variables defined in the this compilation unit: | |
This class represents a DWARF compilation unit.
Iterator over the dwarf::Function.
Iterator over the dwarf::Type.
Iterator over the CompilationUnit's variables.
LIEF::dwarf::CompilationUnit::CompilationUnit | ( | std::unique_ptr< details::CompilationUnit > | impl | ) |
LIEF::dwarf::CompilationUnit::~CompilationUnit | ( | ) |
std::string LIEF::dwarf::CompilationUnit::compilation_dir | ( | ) | const |
Return the path to the directory in which the compilation took place for compiling this compilation unit (e.g. /workdir/build
)
It returns an empty string if the entry is not present or can't be resolved
This value matches the DW_AT_comp_dir
attribute
std::unique_ptr< Function > LIEF::dwarf::CompilationUnit::find_function | ( | const std::string & | name | ) | const |
Try to find the function whose name is given in parameter.
The provided name can be demangled
std::unique_ptr< Function > LIEF::dwarf::CompilationUnit::find_function | ( | uint64_t | addr | ) | const |
Try to find the function at the given address.
std::unique_ptr< Variable > LIEF::dwarf::CompilationUnit::find_variable | ( | const std::string & | name | ) | const |
Try to find the Variable with the given name.
std::unique_ptr< Variable > LIEF::dwarf::CompilationUnit::find_variable | ( | uint64_t | addr | ) | const |
Try to find the Variable at the given address.
functions_it LIEF::dwarf::CompilationUnit::functions | ( | ) | const |
Return an iterator over the functions implemented in this compilation unit.
Note that this iterator only iterates over the functions that have a concrete implementation in the compilation unit.
For instance with this code:
The iterator will only return one function for main
since get_secret_env
is inlined and thus, its implementation is located in main
.
uint64_t LIEF::dwarf::CompilationUnit::high_address | ( | ) | const |
Return the highest virtual address owned by this compilation unit.
functions_it LIEF::dwarf::CompilationUnit::imported_functions | ( | ) | const |
Return an iterator over the functions imported in this compilation unit but not implemented.
For instance with this code:
printf
is imported from the standard libc so the function is returned by the iterator. On the other hand, main()
is implemented in this compilation unit so it is not returned by imported_function() but functions().
Language LIEF::dwarf::CompilationUnit::language | ( | ) | const |
Original Language of this compilation unit.
This value matches the DW_AT_language
attribute.
uint64_t LIEF::dwarf::CompilationUnit::low_address | ( | ) | const |
Return the lowest virtual address owned by this compilation unit.
std::string LIEF::dwarf::CompilationUnit::name | ( | ) | const |
Name of the file associated with this compilation unit (e.g. test.cpp
) Return an empty string if the name is not found or can't be resolved.
This value matches the DW_AT_name
attribute
std::string LIEF::dwarf::CompilationUnit::producer | ( | ) | const |
Information about the program (or library) that generated this compilation unit. For instance, it can output: Debian clang version 17.0.6
.
It returns an empty string if the producer is not present or can't be resolved
This value matches the DW_AT_producer
attribute
std::vector< range_t > LIEF::dwarf::CompilationUnit::ranges | ( | ) | const |
Return a list of address ranges owned by this compilation unit.
If the compilation unit owns a contiguous range, it should return a single range.
uint64_t LIEF::dwarf::CompilationUnit::size | ( | ) | const |
Return the size of the compilation unit according to its range of address.
If the compilation is fragmented (i.e. there are some address ranges between the lowest address and the highest that are not owned by the CU), then it returns the sum of all the address ranges owned by this CU.
If the compilation unit is not fragmented, then is basically returns high_address - low_address
.
types_it LIEF::dwarf::CompilationUnit::types | ( | ) | const |
Return an iterator over the different types defined in this compilation unit.
vars_it LIEF::dwarf::CompilationUnit::variables | ( | ) | const |
Return an iterator over all the variables defined in the this compilation unit: