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

Class that represents a rebase relocation found in the LC_DYLD_CHAINED_FIXUPS command. More...

#include <RelocationFixup.hpp>

Inheritance diagram for LIEF::MachO::RelocationFixup:
Collaboration diagram for LIEF::MachO::RelocationFixup:

Public Member Functions

 RelocationFixup ()=delete
 RelocationFixup (DYLD_CHAINED_PTR_FORMAT fmt, uint64_t imagebase)
RelocationFixupoperator= (const RelocationFixup &)
 RelocationFixup (const RelocationFixup &)
RelocationFixupoperator= (RelocationFixup &&) noexcept=default
 RelocationFixup (RelocationFixup &&) noexcept=default
 ~RelocationFixup () override
std::unique_ptr< Relocationclone () const override
bool is_pc_relative () const override
 Not relevant for this kind of relocation.
ORIGIN origin () const override
 Origin of the relocation. For this concrete object, it should be Relocation::ORIGIN::CHAINED_FIXUPS.
DYLD_CHAINED_PTR_FORMAT ptr_format () const
uint64_t target () const
 The value that should be set at the address pointed by LIEF::Relocation::address if the imagebase chosen by the loader is LIEF::Binary::imagebase. Otherwise: target() - LIEF::Binary::imagebase() + new_imagebase.
void target (uint64_t target)
void pc_relative (bool) override
 Not relevant for this kind of relocation.
uint32_t offset () const
void offset (uint32_t offset)
uint64_t address () const override
 The address of this relocation is bound to its offset.
void address (uint64_t address) override
 Changing the address means changing the offset.
uint32_t next () const
 Return the (unscaled) next offset in the chain.
void next (uint32_t value)
 Change next offset of the current element.
void accept (Visitor &visitor) const override
std::ostream & print (std::ostream &os) const override
Public Member Functions inherited from LIEF::MachO::Relocation
 Relocation ()=default
 Relocation (uint64_t address, uint8_t type)
Relocationoperator= (const Relocation &other)
 Relocation (const Relocation &other)
void swap (Relocation &other) noexcept
 ~Relocation () override=default
virtual uint8_t type () const
 Type of the relocation according to the Relocation::architecture and/or the Relocation::origin.
Header::CPU_TYPE architecture () const
 Achitecture targeted by this relocation.
bool has_symbol () const
 true if the relocation has a symbol associated with
Symbolsymbol ()
 Symbol associated with the relocation, if any, otherwise a nullptr.
const Symbolsymbol () const
bool has_section () const
 true if the relocation has a section associated with
Sectionsection ()
 Section associated with the relocation, if any, otherwise a nullptr.
const Sectionsection () const
bool has_segment () const
 true if the relocation has a SegmentCommand associated with
SegmentCommandsegment ()
 SegmentCommand associated with the relocation, if any, otherwise a nullptr.
const SegmentCommandsegment () const
template<class T>
const T * cast () const
template<class T>
T * cast ()
virtual void type (uint8_t type)
virtual size_t size () const
 Relocation size in bits.
virtual void size (size_t size)
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
Relocationoperator= (const Relocation &)=default
 Relocation (const Relocation &)=default
void swap (Relocation &other)
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 ()
 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 ()

Static Public Member Functions

static bool classof (const Relocation &r)

Additional Inherited Members

Public Types inherited from LIEF::MachO::Relocation
enum class  ORIGIN { UNKNOWN = 0 , DYLDINFO = 1 , RELOC_TABLE = 2 , CHAINED_FIXUPS = 3 }
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>>>
Static Public Attributes inherited from LIEF::MachO::Relocation
static constexpr auto R_SCATTERED = uint32_t(0x80000000)
static constexpr auto R_ABS = uint32_t(0)

Detailed Description

Class that represents a rebase relocation found in the LC_DYLD_CHAINED_FIXUPS command.

This class extends LIEF::Relocation in which LIEF::Relocation::address is set to the absolute virtual address where the relocation must take place (e.g. 0x10000d270).

On the other hand, RelocationFixup::target contains the value that should be set at LIEF::Relocation::address if the imagebase is LIEF::Binary::imagebase (e.g. 0x1000073a8).

If the Mach-O loader chooses another base address (like 0x7ff100000), it must set 0x10000d270 to 0x7ff1073a8.

Constructor & Destructor Documentation

◆ RelocationFixup() [1/4]

LIEF::MachO::RelocationFixup::RelocationFixup ( )
delete

◆ RelocationFixup() [2/4]

LIEF::MachO::RelocationFixup::RelocationFixup ( DYLD_CHAINED_PTR_FORMAT fmt,
uint64_t imagebase )

◆ RelocationFixup() [3/4]

LIEF::MachO::RelocationFixup::RelocationFixup ( const RelocationFixup & )

References RelocationFixup().

◆ RelocationFixup() [4/4]

LIEF::MachO::RelocationFixup::RelocationFixup ( RelocationFixup && )
defaultnoexcept

References RelocationFixup().

◆ ~RelocationFixup()

LIEF::MachO::RelocationFixup::~RelocationFixup ( )
override

References RelocationFixup().

Member Function Documentation

◆ accept()

void LIEF::MachO::RelocationFixup::accept ( Visitor & visitor) const
overridevirtual

Reimplemented from LIEF::MachO::Relocation.

◆ address() [1/2]

uint64_t LIEF::MachO::RelocationFixup::address ( ) const
inlineoverridevirtual

The address of this relocation is bound to its offset.

Reimplemented from LIEF::MachO::Relocation.

Referenced by address().

◆ address() [2/2]

void LIEF::MachO::RelocationFixup::address ( uint64_t address)
inlineoverridevirtual

Changing the address means changing the offset.

Reimplemented from LIEF::MachO::Relocation.

References address().

◆ classof()

bool LIEF::MachO::RelocationFixup::classof ( const Relocation & r)
inlinestatic

◆ clone()

std::unique_ptr< Relocation > LIEF::MachO::RelocationFixup::clone ( ) const
inlineoverridevirtual

◆ is_pc_relative()

bool LIEF::MachO::RelocationFixup::is_pc_relative ( ) const
inlineoverridevirtual

Not relevant for this kind of relocation.

Implements LIEF::MachO::Relocation.

◆ next() [1/2]

uint32_t LIEF::MachO::RelocationFixup::next ( ) const

Return the (unscaled) next offset in the chain.

◆ next() [2/2]

void LIEF::MachO::RelocationFixup::next ( uint32_t value)

Change next offset of the current element.

◆ offset() [1/2]

uint32_t LIEF::MachO::RelocationFixup::offset ( ) const
inline

Referenced by offset().

◆ offset() [2/2]

void LIEF::MachO::RelocationFixup::offset ( uint32_t offset)
inline

References offset().

◆ operator=() [1/2]

RelocationFixup & LIEF::MachO::RelocationFixup::operator= ( const RelocationFixup & )

References RelocationFixup().

◆ operator=() [2/2]

RelocationFixup & LIEF::MachO::RelocationFixup::operator= ( RelocationFixup && )
defaultnoexcept

References RelocationFixup().

◆ origin()

ORIGIN LIEF::MachO::RelocationFixup::origin ( ) const
inlineoverridevirtual

Origin of the relocation. For this concrete object, it should be Relocation::ORIGIN::CHAINED_FIXUPS.

Implements LIEF::MachO::Relocation.

References LIEF::MachO::Relocation::CHAINED_FIXUPS.

◆ pc_relative()

void LIEF::MachO::RelocationFixup::pc_relative ( bool )
inlineoverridevirtual

Not relevant for this kind of relocation.

Implements LIEF::MachO::Relocation.

◆ print()

std::ostream & LIEF::MachO::RelocationFixup::print ( std::ostream & os) const
overridevirtual

Reimplemented from LIEF::MachO::Relocation.

◆ ptr_format()

DYLD_CHAINED_PTR_FORMAT LIEF::MachO::RelocationFixup::ptr_format ( ) const
inline

◆ target() [1/2]

uint64_t LIEF::MachO::RelocationFixup::target ( ) const

The value that should be set at the address pointed by LIEF::Relocation::address if the imagebase chosen by the loader is LIEF::Binary::imagebase. Otherwise: target() - LIEF::Binary::imagebase() + new_imagebase.

Referenced by target().

◆ target() [2/2]

void LIEF::MachO::RelocationFixup::target ( uint64_t target)

References target().

Member Data Documentation

◆ arm64_auth_rebase_

details::dyld_chained_ptr_arm64e_auth_rebase* LIEF::MachO::RelocationFixup::arm64_auth_rebase_

◆ arm64_rebase_

details::dyld_chained_ptr_arm64e_rebase* LIEF::MachO::RelocationFixup::arm64_rebase_ = nullptr

◆ auth_segmented_rebase_

details::dyld_chained_ptr_arm64e_auth_segmented_rebase* LIEF::MachO::RelocationFixup::auth_segmented_rebase_

◆ p32_rebase_

details::dyld_chained_ptr_32_rebase* LIEF::MachO::RelocationFixup::p32_rebase_

◆ p64_rebase_

details::dyld_chained_ptr_64_rebase* LIEF::MachO::RelocationFixup::p64_rebase_

◆ segmented_rebase_

details::dyld_chained_ptr_arm64e_segmented_rebase* LIEF::MachO::RelocationFixup::segmented_rebase_

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