LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
LIEF::ELF::Relocation Class Reference

Class that represents an ELF relocation. More...

#include <Relocation.hpp>

Inheritance diagram for LIEF::ELF::Relocation:
Inheritance graph
[legend]
Collaboration diagram for LIEF::ELF::Relocation:
Collaboration graph
[legend]

Public Types

enum class  PURPOSE { NONE = 0 , PLTGOT = 1 , DYNAMIC = 2 , OBJECT = 3 }
 The purpose of a relocation defines. More...
 
enum class  ENCODING {
  UNKNOWN = 0 , REL , RELA , RELR ,
  ANDROID_SLEB
}
 
enum class  TYPE : uint32_t {
  UNKNOWN = uint32_t(-1) , ELF_RELOC , ELF_RELOC , ELF_RELOC ,
  ELF_RELOC , ELF_RELOC , ELF_RELOC , ELF_RELOC ,
  ELF_RELOC , ELF_RELOC , ELF_RELOC , ELF_RELOC
}
 The different types of the relocation.
 
- 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

 Relocation (uint64_t address, TYPE type, ENCODING enc)
 
 Relocation (ARCH arch)
 
Relocationoperator= (Relocation other)
 
 Relocation (const Relocation &other)
 
void swap (Relocation &other)
 
int64_t addend () const
 Additional value that can be involved in the relocation processing.
 
TYPE type () const
 Type of the relocation.
 
bool is_rela () const
 Check if the relocation uses the explicit addend() field (this is usually the case for 64 bits binaries)
 
bool is_rel () const
 Check if the relocation uses the implicit addend (i.e. not present in the ELF structure)
 
bool is_relatively_encoded () const
 True if the relocation is using the relative encoding.
 
bool is_android_packed () const
 True if the relocation is using the Android packed relocation format.
 
uint32_t info () const
 Relocation info which contains, for instance, the symbol index.
 
uint64_t r_info (Header::CLASS clazz) const
 (re)Compute the raw r_info attribute based on the given ELF class
 
ARCH architecture () const
 Target architecture for this relocation.
 
PURPOSE purpose () const
 
ENCODING encoding () const
 The encoding of the relocation.
 
bool is_relative () const
 True if the semantic of the relocation is <ARCH>_RELATIVE
 
size_t size () const override
 Return the size (in bits) of the value associated with this relocation Return -1 if the size can't be determined.
 
bool has_symbol () const
 True if the current relocation is associated with a symbol.
 
Symbolsymbol ()
 Symbol associated with the relocation (or a nullptr)
 
const Symbolsymbol () const
 
bool has_section () const
 True if the relocation has an associated section.
 
Sectionsection ()
 The section in which the relocation is applied (or a nullptr)
 
const Sectionsection () const
 
Sectionsymbol_table ()
 The associated symbol table (or a nullptr)
 
const Sectionsymbol_table () const
 
void addend (int64_t addend)
 
void type (TYPE type)
 
void purpose (PURPOSE purpose)
 
void info (uint32_t v)
 
void symbol (Symbol *symbol)
 
void section (Section *section)
 
void symbol_table (Section *section)
 
void accept (Visitor &visitor) const override
 
- Public Member Functions inherited from LIEF::Relocation
 Relocation (uint64_t address, uint8_t size)
 Constructor from a relocation's address and size.
 
Relocationoperator= (const Relocation &)
 
 Relocation (const Relocation &)
 
void swap (Relocation &other)
 
virtual uint64_t address () const
 Relocation's address.
 
virtual void address (uint64_t address)
 
virtual void size (size_t size)
 
void accept (Visitor &visitor) const override
 Method so that the visitor can visit us.
 
virtual bool operator< (const Relocation &rhs) const
 Comparaison based on the Relocation's address
 
virtual bool operator<= (const Relocation &rhs) const
 Comparaison based on the Relocation's address
 
virtual bool operator> (const Relocation &rhs) const
 Comparaison based on the Relocation's address
 
virtual bool operator>= (const Relocation &rhs) const
 Comparaison based on the Relocation's address
 
- Public Member Functions inherited from LIEF::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
 

Static Public Member Functions

static TYPE type_from (uint32_t value, ARCH arch)
 
static uint32_t to_value (TYPE type)
 

Static Public Attributes

static constexpr uint64_t R_BIT = 27
 
static constexpr uint64_t R_MASK = (uint64_t(1) << R_BIT) - 1
 
static constexpr uint64_t R_X64 = uint64_t(1) << R_BIT
 
static constexpr uint64_t R_AARCH64 = uint64_t(2) << R_BIT
 
static constexpr uint64_t R_ARM = uint64_t(3) << R_BIT
 
static constexpr uint64_t R_HEXAGON = uint64_t(4) << R_BIT
 
static constexpr uint64_t R_X86 = uint64_t(5) << R_BIT
 
static constexpr uint64_t R_LARCH = uint64_t(6) << R_BIT
 
static constexpr uint64_t R_MIPS = uint64_t(7) << R_BIT
 
static constexpr uint64_t R_PPC = uint64_t(8) << R_BIT
 
static constexpr uint64_t R_PPC64 = uint64_t(9) << R_BIT
 
static constexpr uint64_t R_SPARC = uint64_t(10) << R_BIT
 
static constexpr uint64_t R_SYSZ = uint64_t(11) << R_BIT
 

Detailed Description

Class that represents an ELF relocation.

Member Enumeration Documentation

◆ ENCODING

Enumerator
REL 

The relocation is using the regular Elf_Rel structure.

RELA 

The relocation is using the regular Elf_Rela structure.

RELR 

The relocation is using the relative relocation format.

ANDROID_SLEB 

The relocation is using the packed Android-SLEB128 format.

◆ PURPOSE

enum class LIEF::ELF::Relocation::PURPOSE
strong

The purpose of a relocation defines.

Enumerator
PLTGOT 

The relocation is associated with the PLT/GOT resolution.

DYNAMIC 

The relocation is used for regulard data/code relocation.

OBJECT 

The relocation is used in an object file.

Member Function Documentation

◆ accept()

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

Implements LIEF::Object.

◆ size()

size_t LIEF::ELF::Relocation::size ( ) const
overridevirtual

Return the size (in bits) of the value associated with this relocation Return -1 if the size can't be determined.

Reimplemented from LIEF::Relocation.


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