LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
LIEF::Function Class Reference

Class that represents a function in the binary. More...

#include <Function.hpp>

Inheritance diagram for LIEF::Function:
Collaboration diagram for LIEF::Function:

Public Types

enum class  FLAGS : uint32_t {
  NONE = 0 , CONSTRUCTOR = 1 << 0 , DESTRUCTOR = 1 << 1 , DEBUG_INFO = 1 << 2 ,
  EXPORTED = 1 << 3 , IMPORTED = 1 << 4
}
 Flags used to characterize the semantics of the function. More...
Public Types inherited from LIEF::Object
template<class T>
using output_t = add_pointer_t<decay_t<T>>
template<class T>
using output_const_t = add_pointer_t<add_const_t<decay_t<T>>>

Public Member Functions

 Function ()=default
 Function (const std::string &name)
 Function (uint64_t address)
 Function (const std::string &name, uint64_t address)
 Function (const std::string &name, uint64_t address, FLAGS flags)
 Function (const Function &)=default
Functionoperator= (const Function &)=default
 ~Function () override=default
std::vector< FLAGSflags_list () const
 List of FLAGS.
FLAGS flags () const
Functionadd (FLAGS f)
 Add a flag to the current function.
bool has (FLAGS f) const
 Check if the function has the given flag.
uint64_t address () const
 Address of the current function. For functions that are set with the FLAGS::IMPORTED flag, this value is likely 0.
void address (uint64_t address)
void accept (Visitor &visitor) const override
Public Member Functions inherited from LIEF::Symbol
 Symbol ()=default
 Symbol (std::string name)
 Symbol (std::string name, uint64_t value)
 Symbol (std::string name, uint64_t value, uint64_t size)
 Symbol (const Symbol &)=default
Symboloperator= (const Symbol &)=default
 Symbol (Symbol &&)=default
Symboloperator= (Symbol &&)=default
 ~Symbol () override=default
void swap (Symbol &other) noexcept
virtual const std::string & name () const
 Return the symbol's name.
virtual std::string & name ()
virtual void name (std::string name)
 Set symbol name.
virtual uint64_t value () const
virtual void value (uint64_t value)
virtual uint64_t size () const
 This size of the symbol (when applicable).
virtual void size (uint64_t value)
void accept (Visitor &visitor) const override
 Method so that the visitor can visit us.
Public Member Functions inherited from LIEF::Object
 Object ()
 Object (const Object &other)
Objectoperator= (const Object &other)
 Object (Object &&other) noexcept=default
Objectoperator= (Object &&other) noexcept=default
template<class T>
output_t< T > as ()
template<class T>
output_const_t< T > as () const
virtual bool operator== (const Object &other) const
virtual bool operator!= (const Object &other) const
virtual ~Object ()

Detailed Description

Class that represents a function in the binary.

Member Enumeration Documentation

◆ FLAGS

enum class LIEF::Function::FLAGS : uint32_t
strong

Flags used to characterize the semantics of the function.

Enumerator
NONE 
CONSTRUCTOR 

The function acts as a constructor.

Usually this flag is associated with functions that are located in the .init_array, __mod_init_func or .tls sections

DESTRUCTOR 

The function acts as a destructor.

Usually this flag is associated with functions that are located in the .fini_array or __mod_term_func sections

DEBUG_INFO 

The function is associated with Debug information.

EXPORTED 

The function is exported by the binary and the address() method returns its virtual address in the binary.

IMPORTED 

The function is imported by the binary and the address() should return 0.

Constructor & Destructor Documentation

◆ Function() [1/6]

LIEF::Function::Function ( )
default

◆ Function() [2/6]

LIEF::Function::Function ( const std::string & name)
inline

◆ Function() [3/6]

LIEF::Function::Function ( uint64_t address)
inline

References address(), and Function().

◆ Function() [4/6]

LIEF::Function::Function ( const std::string & name,
uint64_t address )
inline

◆ Function() [5/6]

LIEF::Function::Function ( const std::string & name,
uint64_t address,
FLAGS flags )
inline

◆ Function() [6/6]

LIEF::Function::Function ( const Function & )
default

References Function().

◆ ~Function()

LIEF::Function::~Function ( )
overridedefault

Member Function Documentation

◆ accept()

void LIEF::Function::accept ( Visitor & visitor) const
overridevirtual

Implements LIEF::Object.

◆ add()

Function & LIEF::Function::add ( FLAGS f)
inline

Add a flag to the current function.

References Function().

◆ address() [1/2]

uint64_t LIEF::Function::address ( ) const
inline

Address of the current function. For functions that are set with the FLAGS::IMPORTED flag, this value is likely 0.

Referenced by address(), Function(), Function(), and Function().

◆ address() [2/2]

void LIEF::Function::address ( uint64_t address)
inline

References address().

◆ flags()

FLAGS LIEF::Function::flags ( ) const
inline

Referenced by Function().

◆ flags_list()

std::vector< FLAGS > LIEF::Function::flags_list ( ) const

List of FLAGS.

◆ has()

bool LIEF::Function::has ( FLAGS f) const
inline

Check if the function has the given flag.

◆ operator=()

Function & LIEF::Function::operator= ( const Function & )
default

References Function().


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