LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
LIEF::COFF::Relocation Class Reference

This class represents a COFF relocation. More...

#include <Relocation.hpp>

Inheritance diagram for LIEF::COFF::Relocation:
Collaboration diagram for LIEF::COFF::Relocation:

Public Types

enum class  TYPE : uint32_t {
  UNKNOWN = uint32_t(-1) , I386_ABSOLUTE = I386 + 0x0000 , I386_DIR16 = I386 + 0x0001 , I386_REL16 = I386 + 0x0002 ,
  I386_DIR32 = I386 + 0x0006 , I386_DIR32NB = I386 + 0x0007 , I386_SEG12 = I386 + 0x0009 , I386_SECTION = I386 + 0x000A ,
  I386_SECREL = I386 + 0x000B , I386_TOKEN = I386 + 0x000C , I386_SECREL7 = I386 + 0x000D , I386_REL32 = I386 + 0x0014 ,
  AMD64_ABSOLUTE = X64 + 0x0000 , AMD64_ADDR64 = X64 + 0x0001 , AMD64_ADDR32 = X64 + 0x0002 , AMD64_ADDR32NB = X64 + 0x0003 ,
  AMD64_REL32 = X64 + 0x0004 , AMD64_REL32_1 = X64 + 0x0005 , AMD64_REL32_2 = X64 + 0x0006 , AMD64_REL32_3 = X64 + 0x0007 ,
  AMD64_REL32_4 = X64 + 0x0008 , AMD64_REL32_5 = X64 + 0x0009 , AMD64_SECTION = X64 + 0x000A , AMD64_SECREL = X64 + 0x000B ,
  AMD64_SECREL7 = X64 + 0x000C , AMD64_TOKEN = X64 + 0x000D , AMD64_SREL32 = X64 + 0x000E , AMD64_PAIR = X64 + 0x000F ,
  AMD64_SSPAN32 = X64 + 0x0010 , ARM_ABSOLUTE = ARM + 0x0000 , ARM_ADDR32 = ARM + 0x0001 , ARM_ADDR32NB = ARM + 0x0002 ,
  ARM_BRANCH24 = ARM + 0x0003 , ARM_BRANCH11 = ARM + 0x0004 , ARM_TOKEN = ARM + 0x0005 , ARM_BLX24 = ARM + 0x0008 ,
  ARM_BLX11 = ARM + 0x0009 , ARM_REL32 = ARM + 0x000A , ARM_SECTION = ARM + 0x000E , ARM_SECREL = ARM + 0x000F ,
  ARM_MOV32A = ARM + 0x0010 , ARM_MOV32T = ARM + 0x0011 , ARM_BRANCH20T = ARM + 0x0012 , ARM_BRANCH24T = ARM + 0x0014 ,
  ARM_BLX23T = ARM + 0x0015 , ARM_PAIR = ARM + 0x0016 , ARM64_ABSOLUTE = ARM64 + 0x0000 , ARM64_ADDR32 = ARM64 + 0x0001 ,
  ARM64_ADDR32NB = ARM64 + 0x0002 , ARM64_BRANCH26 = ARM64 + 0x0003 , ARM64_PAGEBASE_REL21 = ARM64 + 0x0004 , ARM64_REL21 = ARM64 + 0x0005 ,
  ARM64_PAGEOFFSET_12A = ARM64 + 0x0006 , ARM64_PAGEOFFSET_12L = ARM64 + 0x0007 , ARM64_SECREL = ARM64 + 0x0008 , ARM64_SECREL_LOW12A = ARM64 + 0x0009 ,
  ARM64_SECREL_HIGH12A = ARM64 + 0x000A , ARM64_SECREL_LOW12L = ARM64 + 0x000B , ARM64_TOKEN = ARM64 + 0x000C , ARM64_SECTION = ARM64 + 0x000D ,
  ARM64_ADDR64 = ARM64 + 0x000E , ARM64_BRANCH19 = ARM64 + 0x000F , ARM64_BRANCH14 = ARM64 + 0x0010 , ARM64_REL32 = ARM64 + 0x0011 ,
  MIPS_ABSOLUTE = MIPS + 0x0000 , MIPS_REFHALF = MIPS + 0x0001 , MIPS_REFWORD = MIPS + 0x0002 , MIPS_JMPADDR = MIPS + 0x0003 ,
  MIPS_REFHI = MIPS + 0x0004 , MIPS_REFLO = MIPS + 0x0005 , MIPS_GPREL = MIPS + 0x0006 , MIPS_LITERAL = MIPS + 0x0007 ,
  MIPS_SECTION = MIPS + 0x000A , MIPS_SECREL = MIPS + 0x000B , MIPS_SECRELLO = MIPS + 0x000C , MIPS_SECRELHI = MIPS + 0x000D ,
  MIPS_JMPADDR16 = MIPS + 0x0010 , MIPS_REFWORDNB = MIPS + 0x0022 , MIPS_PAIR = MIPS + 0x0025
}
 The different relocation types. 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

uint32_t symbol_idx () const
 Symbol index associated with this relocation.
Symbol * symbol ()
 Symbol associated with the relocation (if any).
const Symbol * symbol () const
TYPE type () const
 Type of the relocation.
Section * section ()
 Section in which the relocation takes place.
const Section * section () const
std::string to_string () const
 ~Relocation () override=default
Public Member Functions inherited from LIEF::Relocation
 Relocation ()=default
 Relocation (uint64_t address, uint8_t size)
 Constructor from a relocation's address and size.
 ~Relocation () override=default
Relocation & operator= (const Relocation &)=default
 Relocation (const Relocation &)=default
void swap (Relocation &other)
virtual uint64_t address () const
 Relocation's address.
virtual size_t size () const
 Relocation size in bits.
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
 Comparison based on the Relocation's address.
virtual bool operator<= (const Relocation &rhs) const
 Comparison based on the Relocation's address.
virtual bool operator> (const Relocation &rhs) const
 Comparison based on the Relocation's address.
virtual bool operator>= (const Relocation &rhs) const
 Comparison based on the Relocation's address.
Public Member Functions inherited from LIEF::Object
 Object ()
 Object (const Object &other)
Object & operator= (const Object &other)
 Object (Object &&other) noexcept=default
Object & operator= (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 ()

Static Public Member Functions

static uint16_t to_value (TYPE rtype)
 Convert a relocation enum type into a 16-bits value.
static TYPE from_value (uint16_t value, Header::MACHINE_TYPES arch)
 Create a relocation type from its raw value and the architecture.
static std::unique_ptr< Relocation > parse (BinaryStream &stream, Header::MACHINE_TYPES arch)
 Create a relocation from the given stream.

Static Public Attributes

static constexpr uint32_t I386 = 1 << 17
static constexpr uint32_t X64 = 1 << 18
static constexpr uint32_t ARM = 1 << 19
static constexpr uint32_t ARM64 = 1 << 20
static constexpr uint32_t MIPS = 1 << 21

Detailed Description

This class represents a COFF relocation.

Member Enumeration Documentation

◆ TYPE

enum class LIEF::COFF::Relocation::TYPE : uint32_t
strong

The different relocation types.

Please note that the original type is encoded on 16 bits but we encode the type on 32-bits by adding a discriminator from the 17th bit

Enumerator
UNKNOWN 
I386_ABSOLUTE 
I386_DIR16 
I386_REL16 
I386_DIR32 
I386_DIR32NB 
I386_SEG12 
I386_SECTION 
I386_SECREL 
I386_TOKEN 
I386_SECREL7 
I386_REL32 
AMD64_ABSOLUTE 
AMD64_ADDR64 
AMD64_ADDR32 
AMD64_ADDR32NB 
AMD64_REL32 
AMD64_REL32_1 
AMD64_REL32_2 
AMD64_REL32_3 
AMD64_REL32_4 
AMD64_REL32_5 
AMD64_SECTION 
AMD64_SECREL 
AMD64_SECREL7 
AMD64_TOKEN 
AMD64_SREL32 
AMD64_PAIR 
AMD64_SSPAN32 
ARM_ABSOLUTE 
ARM_ADDR32 
ARM_ADDR32NB 
ARM_BRANCH24 
ARM_BRANCH11 
ARM_TOKEN 
ARM_BLX24 
ARM_BLX11 
ARM_REL32 
ARM_SECTION 
ARM_SECREL 
ARM_MOV32A 
ARM_MOV32T 
ARM_BRANCH20T 
ARM_BRANCH24T 
ARM_BLX23T 
ARM_PAIR 
ARM64_ABSOLUTE 
ARM64_ADDR32 
ARM64_ADDR32NB 
ARM64_BRANCH26 
ARM64_PAGEBASE_REL21 
ARM64_REL21 
ARM64_PAGEOFFSET_12A 
ARM64_PAGEOFFSET_12L 
ARM64_SECREL 
ARM64_SECREL_LOW12A 
ARM64_SECREL_HIGH12A 
ARM64_SECREL_LOW12L 
ARM64_TOKEN 
ARM64_SECTION 
ARM64_ADDR64 
ARM64_BRANCH19 
ARM64_BRANCH14 
ARM64_REL32 
MIPS_ABSOLUTE 
MIPS_REFHALF 
MIPS_REFWORD 
MIPS_JMPADDR 
MIPS_REFHI 
MIPS_REFLO 
MIPS_GPREL 
MIPS_LITERAL 
MIPS_SECTION 
MIPS_SECREL 
MIPS_SECRELLO 
MIPS_SECRELHI 
MIPS_JMPADDR16 
MIPS_REFWORDNB 
MIPS_PAIR 

Constructor & Destructor Documentation

◆ ~Relocation()

LIEF::COFF::Relocation::~Relocation ( )
overridedefault

References UNKNOWN.

Member Function Documentation

◆ from_value()

TYPE LIEF::COFF::Relocation::from_value ( uint16_t value,
Header::MACHINE_TYPES arch )
inlinestatic

Create a relocation type from its raw value and the architecture.

References ARM, ARM64, I386, MIPS, UNKNOWN, and X64.

◆ parse()

std::unique_ptr< Relocation > LIEF::COFF::Relocation::parse ( BinaryStream & stream,
Header::MACHINE_TYPES arch )
static

Create a relocation from the given stream.

◆ section() [1/2]

Section * LIEF::COFF::Relocation::section ( )
inline

Section in which the relocation takes place.

◆ section() [2/2]

const Section * LIEF::COFF::Relocation::section ( ) const
inline

◆ symbol() [1/2]

Symbol * LIEF::COFF::Relocation::symbol ( )
inline

Symbol associated with the relocation (if any).

◆ symbol() [2/2]

const Symbol * LIEF::COFF::Relocation::symbol ( ) const
inline

◆ symbol_idx()

uint32_t LIEF::COFF::Relocation::symbol_idx ( ) const
inline

Symbol index associated with this relocation.

◆ to_string()

std::string LIEF::COFF::Relocation::to_string ( ) const

◆ to_value()

uint16_t LIEF::COFF::Relocation::to_value ( TYPE rtype)
inlinestatic

Convert a relocation enum type into a 16-bits value.

◆ type()

TYPE LIEF::COFF::Relocation::type ( ) const
inline

Type of the relocation.

Member Data Documentation

◆ ARM

uint32_t LIEF::COFF::Relocation::ARM = 1 << 19
staticconstexpr

Referenced by from_value().

◆ ARM64

uint32_t LIEF::COFF::Relocation::ARM64 = 1 << 20
staticconstexpr

Referenced by from_value().

◆ I386

uint32_t LIEF::COFF::Relocation::I386 = 1 << 17
staticconstexpr

Referenced by from_value().

◆ MIPS

uint32_t LIEF::COFF::Relocation::MIPS = 1 << 21
staticconstexpr

Referenced by from_value().

◆ X64

uint32_t LIEF::COFF::Relocation::X64 = 1 << 18
staticconstexpr

Referenced by from_value().


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