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

Class which represents a library dependency. More...

#include <DylibCommand.hpp>

Inheritance diagram for LIEF::MachO::DylibCommand:
Collaboration diagram for LIEF::MachO::DylibCommand:

Public Types

using version_t = std::array<uint16_t, 3>
 
- Public Types inherited from LIEF::MachO::LoadCommand
enum class  TYPE : uint64_t {
  UNKNOWN = 0 , SEGMENT = 0x00000001u , SYMTAB = 0x00000002u , SYMSEG = 0x00000003u ,
  THREAD = 0x00000004u , UNIXTHREAD = 0x00000005u , LOADFVMLIB = 0x00000006u , IDFVMLIB = 0x00000007u ,
  IDENT = 0x00000008u , FVMFILE = 0x00000009u , PREPAGE = 0x0000000Au , DYSYMTAB = 0x0000000Bu ,
  LOAD_DYLIB = 0x0000000Cu , ID_DYLIB = 0x0000000Du , LOAD_DYLINKER = 0x0000000Eu , ID_DYLINKER = 0x0000000Fu ,
  PREBOUND_DYLIB = 0x00000010u , ROUTINES = 0x00000011u , SUB_FRAMEWORK = 0x00000012u , SUB_UMBRELLA = 0x00000013u ,
  SUB_CLIENT = 0x00000014u , SUB_LIBRARY = 0x00000015u , TWOLEVEL_HINTS = 0x00000016u , PREBIND_CKSUM = 0x00000017u ,
  LOAD_WEAK_DYLIB = 0x80000018u , SEGMENT_64 = 0x00000019u , ROUTINES_64 = 0x0000001Au , UUID = 0x0000001Bu ,
  RPATH = 0x8000001Cu , CODE_SIGNATURE = 0x0000001Du , SEGMENT_SPLIT_INFO = 0x0000001Eu , REEXPORT_DYLIB = 0x8000001Fu ,
  LAZY_LOAD_DYLIB = 0x00000020u , ENCRYPTION_INFO = 0x00000021u , DYLD_INFO = 0x00000022u , DYLD_INFO_ONLY = 0x80000022u ,
  LOAD_UPWARD_DYLIB = 0x80000023u , VERSION_MIN_MACOSX = 0x00000024u , VERSION_MIN_IPHONEOS = 0x00000025u , FUNCTION_STARTS = 0x00000026u ,
  DYLD_ENVIRONMENT = 0x00000027u , MAIN = 0x80000028u , DATA_IN_CODE = 0x00000029u , SOURCE_VERSION = 0x0000002Au ,
  DYLIB_CODE_SIGN_DRS = 0x0000002Bu , ENCRYPTION_INFO_64 = 0x0000002Cu , LINKER_OPTION = 0x0000002Du , LINKER_OPTIMIZATION_HINT = 0x0000002Eu ,
  VERSION_MIN_TVOS = 0x0000002Fu , VERSION_MIN_WATCHOS = 0x00000030u , NOTE = 0x00000031u , BUILD_VERSION = 0x00000032u ,
  DYLD_EXPORTS_TRIE = 0x80000033u , DYLD_CHAINED_FIXUPS = 0x80000034u , FILESET_ENTRY = 0x80000035u , ATOM_INFO = 0x00000036u ,
  LIEF_UNKNOWN = 0xffee0001u
}
 
using raw_t = std::vector<uint8_t>
 
- 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

 DylibCommand ()=default
 
 DylibCommand (const details::dylib_command &cmd)
 
DylibCommandoperator= (const DylibCommand &copy)=default
 
 DylibCommand (const DylibCommand &copy)=default
 
 ~DylibCommand () override=default
 
std::unique_ptr< LoadCommandclone () const override
 
const std::string & name () const
 Library name.
 
uint32_t name_offset () const
 Original string offset of the name.
 
uint32_t timestamp () const
 Date and Time when the shared library was built.
 
version_t current_version () const
 Current version of the shared library.
 
version_t compatibility_version () const
 Compatibility version of the shared library.
 
void name (std::string name)
 
void timestamp (uint32_t timestamp)
 
void current_version (version_t version)
 
void compatibility_version (version_t version)
 
std::ostream & print (std::ostream &os) const override
 
void accept (Visitor &visitor) const override
 
- Public Member Functions inherited from LIEF::MachO::LoadCommand
 LoadCommand ()=default
 
 LoadCommand (const details::load_command &command)
 
 LoadCommand (LoadCommand::TYPE type, uint32_t size)
 
LoadCommandoperator= (const LoadCommand &copy)=default
 
 LoadCommand (const LoadCommand &copy)=default
 
void swap (LoadCommand &other) noexcept
 
 ~LoadCommand () override=default
 
LoadCommand::TYPE command () const
 Command type.
 
uint32_t size () const
 Size of the command (should be greather than sizeof(load_command))
 
span< const uint8_t > data () const
 Raw command.
 
uint64_t command_offset () const
 Offset of the command within the Load Command Table
 
void data (raw_t data)
 
void command (LoadCommand::TYPE command)
 
void size (uint32_t size)
 
void command_offset (uint64_t offset)
 
void accept (Visitor &visitor) const override
 
template<class T >
const T * cast () const
 
template<class T >
T * cast ()
 
- 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 version_t int2version (uint32_t version)
 Helper to convert an integer into a version array.
 
static uint32_t version2int (version_t version)
 Helper to convert a version array into an integer.
 
static DylibCommand weak_dylib (const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_LOAD_WEAK_DYLIB library.
 
static DylibCommand id_dylib (const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_ID_DYLIB library.
 
static DylibCommand load_dylib (const std::string &name, uint32_t timestamp=2, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_LOAD_DYLIB library.
 
static DylibCommand reexport_dylib (const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_REEXPORT_DYLIB library.
 
static DylibCommand load_upward_dylib (const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_LOAD_UPWARD_DYLIB library.
 
static DylibCommand lazy_load_dylib (const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
 Factory function to generate a LC_LAZY_LOAD_DYLIB library.
 
static bool classof (const LoadCommand *cmd)
 
- Static Public Member Functions inherited from LIEF::MachO::LoadCommand
static bool is_linkedit_data (const LoadCommand &cmd)
 

Detailed Description

Class which represents a library dependency.

Member Typedef Documentation

◆ version_t

using LIEF::MachO::DylibCommand::version_t = std::array<uint16_t, 3>

Constructor & Destructor Documentation

◆ DylibCommand() [1/3]

LIEF::MachO::DylibCommand::DylibCommand ( )
default

◆ DylibCommand() [2/3]

LIEF::MachO::DylibCommand::DylibCommand ( const details::dylib_command & cmd)

◆ DylibCommand() [3/3]

LIEF::MachO::DylibCommand::DylibCommand ( const DylibCommand & copy)
default

◆ ~DylibCommand()

LIEF::MachO::DylibCommand::~DylibCommand ( )
overridedefault

Member Function Documentation

◆ accept()

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

Implements LIEF::Object.

◆ classof()

static bool LIEF::MachO::DylibCommand::classof ( const LoadCommand * cmd)
inlinestatic

◆ clone()

std::unique_ptr< LoadCommand > LIEF::MachO::DylibCommand::clone ( ) const
inlineoverridevirtual

Reimplemented from LIEF::MachO::LoadCommand.

◆ compatibility_version() [1/2]

version_t LIEF::MachO::DylibCommand::compatibility_version ( ) const
inline

Compatibility version of the shared library.

◆ compatibility_version() [2/2]

void LIEF::MachO::DylibCommand::compatibility_version ( version_t version)
inline

◆ current_version() [1/2]

version_t LIEF::MachO::DylibCommand::current_version ( ) const
inline

Current version of the shared library.

◆ current_version() [2/2]

void LIEF::MachO::DylibCommand::current_version ( version_t version)
inline

◆ id_dylib()

static DylibCommand LIEF::MachO::DylibCommand::id_dylib ( const std::string & name,
uint32_t timestamp = 0,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_ID_DYLIB library.

◆ int2version()

static version_t LIEF::MachO::DylibCommand::int2version ( uint32_t version)
inlinestatic

Helper to convert an integer into a version array.

◆ lazy_load_dylib()

static DylibCommand LIEF::MachO::DylibCommand::lazy_load_dylib ( const std::string & name,
uint32_t timestamp = 0,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_LAZY_LOAD_DYLIB library.

◆ load_dylib()

static DylibCommand LIEF::MachO::DylibCommand::load_dylib ( const std::string & name,
uint32_t timestamp = 2,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_LOAD_DYLIB library.

◆ load_upward_dylib()

static DylibCommand LIEF::MachO::DylibCommand::load_upward_dylib ( const std::string & name,
uint32_t timestamp = 0,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_LOAD_UPWARD_DYLIB library.

◆ name() [1/2]

const std::string & LIEF::MachO::DylibCommand::name ( ) const
inline

Library name.

◆ name() [2/2]

void LIEF::MachO::DylibCommand::name ( std::string name)
inline

◆ name_offset()

uint32_t LIEF::MachO::DylibCommand::name_offset ( ) const
inline

Original string offset of the name.

◆ operator=()

DylibCommand & LIEF::MachO::DylibCommand::operator= ( const DylibCommand & copy)
default

◆ print()

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

Reimplemented from LIEF::MachO::LoadCommand.

◆ reexport_dylib()

static DylibCommand LIEF::MachO::DylibCommand::reexport_dylib ( const std::string & name,
uint32_t timestamp = 0,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_REEXPORT_DYLIB library.

◆ timestamp() [1/2]

uint32_t LIEF::MachO::DylibCommand::timestamp ( ) const
inline

Date and Time when the shared library was built.

◆ timestamp() [2/2]

void LIEF::MachO::DylibCommand::timestamp ( uint32_t timestamp)
inline

◆ version2int()

static uint32_t LIEF::MachO::DylibCommand::version2int ( version_t version)
inlinestatic

Helper to convert a version array into an integer.

◆ weak_dylib()

static DylibCommand LIEF::MachO::DylibCommand::weak_dylib ( const std::string & name,
uint32_t timestamp = 0,
uint32_t current_version = 0,
uint32_t compat_version = 0 )
static

Factory function to generate a LC_LOAD_WEAK_DYLIB library.


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