LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
LIEF::ELF::Symbol Class Reference

Class which represents an ELF symbol. More...

#include <Symbol.hpp>

Inheritance diagram for LIEF::ELF::Symbol:
Collaboration diagram for LIEF::ELF::Symbol:

Public Types

enum class  BINDING { LOCAL = 0 , GLOBAL = 1 , WEAK = 2 , GNU_UNIQUE = 10 }
 
enum class  TYPE {
  NOTYPE = 0 , OBJECT = 1 , FUNC = 2 , SECTION = 3 ,
  FILE = 4 , COMMON = 5 , TLS = 6 , GNU_IFUNC = 10
}
 Type of the symbol. This enum matches the STT_xxx values of the ELF specs. More...
 
enum class  VISIBILITY { DEFAULT = 0 , INTERNAL = 1 , HIDDEN = 2 , PROTECTED = 3 }
 Visibility of the symbol. This enum matches the STV_xxx values of the official ELF specs. More...
 
enum  SECTION_INDEX { UNDEF = 0 , ABS = 0xfff1 , COMMON = 0xfff2 }
 Special section indices. 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

 Symbol (std::string name)
 
 Symbol ()=default
 
 ~Symbol () override=default
 
Symboloperator= (Symbol other)
 
 Symbol (const Symbol &other)
 
void swap (Symbol &other)
 
TYPE type () const
 The symbol's type provides a general classification for the associated entity.
 
BINDING binding () const
 The symbol's binding determines the linkage visibility and behavior.
 
uint8_t information () const
 This member specifies the symbol's type and binding attributes.
 
uint8_t other () const
 Alias for visibility()
 
uint16_t section_idx () const
 ELF::Section index associated with the symbol.
 
VISIBILITY visibility () const
 Symbol visibility.
 
Sectionsection ()
 Section associated with the symbol or a nullptr if it does not exist.
 
const Sectionsection () const
 
uint64_t value () const override
 This member has slightly different interpretations:
 
uint64_t size () const override
 Symbol size.
 
uint16_t shndx () const
 
bool has_version () const
 Check if this symbols has a symbol version .
 
SymbolVersionsymbol_version ()
 Return the SymbolVersion associated with this symbol. If there is no symbol version, return a nullptr.
 
const SymbolVersionsymbol_version () const
 
bool is_local () const
 
bool is_global () const
 
bool is_weak () const
 
std::string demangled_name () const
 Symbol's unmangled name. If not available, it returns an empty string.
 
void type (TYPE type)
 
void binding (BINDING binding)
 
void other (uint8_t other)
 
void visibility (VISIBILITY visibility)
 
void information (uint8_t info)
 
void shndx (uint16_t idx)
 
void value (uint64_t value) override
 
void size (uint64_t size) override
 
bool is_exported () const
 Check if the current symbol is exported.
 
void set_exported (bool flag=true)
 Set whether or not the symbol is exported.
 
bool is_imported () const
 Check if the current symbol is imported.
 
void set_imported (bool flag=true)
 Set whether or not the symbol is imported.
 
bool is_static () const
 True if the symbol is a static one.
 
bool is_function () const
 True if the symbol represent a function.
 
bool is_variable () const
 True if the symbol represent a variable.
 
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 () 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.
 
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)
 
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 ()
 

Static Public Member Functions

static BINDING binding_from (uint32_t value, ARCH)
 
static TYPE type_from (uint32_t value, ARCH)
 
static uint8_t to_value (BINDING binding)
 
static uint8_t to_value (TYPE type)
 

Detailed Description

Class which represents an ELF symbol.

Member Enumeration Documentation

◆ BINDING

enum class LIEF::ELF::Symbol::BINDING
strong
Enumerator
LOCAL 

Local symbol.

GLOBAL 

Global symbol.

WEAK 

Weak symbol.

GNU_UNIQUE 

Unique symbol.

◆ SECTION_INDEX

Special section indices.

Enumerator
UNDEF 

Undefined section.

ABS 

Associated symbol is absolute.

COMMON 

Associated symbol is common.

◆ TYPE

enum class LIEF::ELF::Symbol::TYPE
strong

Type of the symbol. This enum matches the STT_xxx values of the ELF specs.

Enumerator
NOTYPE 

Symbol's type is not specified.

OBJECT 

Symbol is a data object (variable, array, etc.)

FUNC 

Symbol is executable code (function, etc.)

SECTION 

Symbol refers to a section.

FILE 

Local, absolute symbol that refers to a file.

COMMON 

An uninitialized common block.

TLS 

Thread local data object.

GNU_IFUNC 

GNU indirect function.

◆ VISIBILITY

enum class LIEF::ELF::Symbol::VISIBILITY
strong

Visibility of the symbol. This enum matches the STV_xxx values of the official ELF specs.

Enumerator
DEFAULT 

Visibility is specified by binding type.

INTERNAL 

Defined by processor supplements.

HIDDEN 

Not visible to other components.

PROTECTED 

Visible in other components but not preemptable.

Constructor & Destructor Documentation

◆ Symbol() [1/3]

LIEF::ELF::Symbol::Symbol ( std::string name)
inline

◆ Symbol() [2/3]

LIEF::ELF::Symbol::Symbol ( )
default

◆ ~Symbol()

LIEF::ELF::Symbol::~Symbol ( )
overridedefault

◆ Symbol() [3/3]

LIEF::ELF::Symbol::Symbol ( const Symbol & other)

Member Function Documentation

◆ accept()

void LIEF::ELF::Symbol::accept ( Visitor & visitor) const
overridevirtual

Implements LIEF::Object.

◆ binding() [1/2]

BINDING LIEF::ELF::Symbol::binding ( ) const
inline

The symbol's binding determines the linkage visibility and behavior.

◆ binding() [2/2]

void LIEF::ELF::Symbol::binding ( BINDING binding)
inline

◆ binding_from()

static BINDING LIEF::ELF::Symbol::binding_from ( uint32_t value,
ARCH  )
inlinestatic

◆ demangled_name()

std::string LIEF::ELF::Symbol::demangled_name ( ) const

Symbol's unmangled name. If not available, it returns an empty string.

◆ has_version()

bool LIEF::ELF::Symbol::has_version ( ) const
inline

Check if this symbols has a symbol version .

◆ information() [1/2]

uint8_t LIEF::ELF::Symbol::information ( ) const

This member specifies the symbol's type and binding attributes.

◆ information() [2/2]

void LIEF::ELF::Symbol::information ( uint8_t info)

◆ is_exported()

bool LIEF::ELF::Symbol::is_exported ( ) const

Check if the current symbol is exported.

◆ is_function()

bool LIEF::ELF::Symbol::is_function ( ) const
inline

True if the symbol represent a function.

◆ is_global()

bool LIEF::ELF::Symbol::is_global ( ) const
inline

◆ is_imported()

bool LIEF::ELF::Symbol::is_imported ( ) const

Check if the current symbol is imported.

◆ is_local()

bool LIEF::ELF::Symbol::is_local ( ) const
inline

◆ is_static()

bool LIEF::ELF::Symbol::is_static ( ) const
inline

True if the symbol is a static one.

◆ is_variable()

bool LIEF::ELF::Symbol::is_variable ( ) const
inline

True if the symbol represent a variable.

◆ is_weak()

bool LIEF::ELF::Symbol::is_weak ( ) const
inline

◆ operator=()

Symbol & LIEF::ELF::Symbol::operator= ( Symbol other)

◆ other() [1/2]

uint8_t LIEF::ELF::Symbol::other ( ) const
inline

Alias for visibility()

◆ other() [2/2]

void LIEF::ELF::Symbol::other ( uint8_t other)
inline

◆ section() [1/2]

Section * LIEF::ELF::Symbol::section ( )
inline

Section associated with the symbol or a nullptr if it does not exist.

◆ section() [2/2]

const Section * LIEF::ELF::Symbol::section ( ) const
inline

◆ section_idx()

uint16_t LIEF::ELF::Symbol::section_idx ( ) const
inline

ELF::Section index associated with the symbol.

◆ set_exported()

void LIEF::ELF::Symbol::set_exported ( bool flag = true)

Set whether or not the symbol is exported.

◆ set_imported()

void LIEF::ELF::Symbol::set_imported ( bool flag = true)

Set whether or not the symbol is imported.

◆ shndx() [1/2]

uint16_t LIEF::ELF::Symbol::shndx ( ) const
inline

◆ shndx() [2/2]

void LIEF::ELF::Symbol::shndx ( uint16_t idx)
inline

◆ size() [1/2]

uint64_t LIEF::ELF::Symbol::size ( ) const
inlineoverridevirtual

Symbol size.

Many symbols have associated sizes. For example, a data object's size is the number of bytes contained in the object. This member holds 0 if the symbol has no size or an unknown size.

Reimplemented from LIEF::Symbol.

◆ size() [2/2]

void LIEF::ELF::Symbol::size ( uint64_t size)
inlineoverridevirtual

Reimplemented from LIEF::Symbol.

◆ swap()

void LIEF::ELF::Symbol::swap ( Symbol & other)

◆ symbol_version() [1/2]

SymbolVersion * LIEF::ELF::Symbol::symbol_version ( )
inline

Return the SymbolVersion associated with this symbol. If there is no symbol version, return a nullptr.

◆ symbol_version() [2/2]

const SymbolVersion * LIEF::ELF::Symbol::symbol_version ( ) const
inline

◆ to_value() [1/2]

static uint8_t LIEF::ELF::Symbol::to_value ( BINDING binding)
inlinestatic

◆ to_value() [2/2]

static uint8_t LIEF::ELF::Symbol::to_value ( TYPE type)
inlinestatic

◆ type() [1/2]

TYPE LIEF::ELF::Symbol::type ( ) const
inline

The symbol's type provides a general classification for the associated entity.

◆ type() [2/2]

void LIEF::ELF::Symbol::type ( TYPE type)
inline

◆ type_from()

static TYPE LIEF::ELF::Symbol::type_from ( uint32_t value,
ARCH  )
inlinestatic

◆ value() [1/2]

uint64_t LIEF::ELF::Symbol::value ( ) const
inlineoverridevirtual

This member has slightly different interpretations:

  • In relocatable files, value holds alignment constraints for a symbol for which section index is SHN_COMMON
  • In relocatable files, value holds a section offset for a defined symbol. That is, value is an offset from the beginning of the section associated with this symbol.
  • In executable and shared object files, value holds a virtual address. To make these files's symbols more useful for the dynamic linker, the section offset (file interpretation) gives way to a virtual address (memory interpretation) for which the section number is irrelevant.

Reimplemented from LIEF::Symbol.

◆ value() [2/2]

void LIEF::ELF::Symbol::value ( uint64_t value)
inlineoverridevirtual

Reimplemented from LIEF::Symbol.

◆ visibility() [1/2]

VISIBILITY LIEF::ELF::Symbol::visibility ( ) const
inline

Symbol visibility.

◆ visibility() [2/2]

void LIEF::ELF::Symbol::visibility ( VISIBILITY visibility)
inline

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