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

Class that represents the Mach-O header. More...

#include <Header.hpp>

Inheritance diagram for LIEF::MachO::Header:
Collaboration diagram for LIEF::MachO::Header:

Public Types

enum class  FILE_TYPE : uint32_t {
  UNKNOWN = 0 , OBJECT = 0x1u , EXECUTE = 0x2u , FVMLIB = 0x3u ,
  CORE = 0x4u , PRELOAD = 0x5u , DYLIB = 0x6u , DYLINKER = 0x7u ,
  BUNDLE = 0x8u , DYLIB_STUB = 0x9u , DSYM = 0xAu , KEXT_BUNDLE = 0xBu
}
 
enum class  FLAGS : uint32_t {
  NOUNDEFS = 0x00000001u , INCRLINK = 0x00000002u , DYLDLINK = 0x00000004u , BINDATLOAD = 0x00000008u ,
  PREBOUND = 0x00000010u , SPLIT_SEGS = 0x00000020u , LAZY_INIT = 0x00000040u , TWOLEVEL = 0x00000080u ,
  FORCE_FLAT = 0x00000100u , NOMULTIDEFS = 0x00000200u , NOFIXPREBINDING = 0x00000400u , PREBINDABLE = 0x00000800u ,
  ALLMODSBOUND = 0x00001000u , SUBSECTIONS_VIA_SYMBOLS = 0x00002000u , CANONICAL = 0x00004000u , WEAK_DEFINES = 0x00008000u ,
  BINDS_TO_WEAK = 0x00010000u , ALLOW_STACK_EXECUTION = 0x00020000u , ROOT_SAFE = 0x00040000u , SETUID_SAFE = 0x00080000u ,
  NO_REEXPORTED_DYLIBS = 0x00100000u , PIE = 0x00200000u , DEAD_STRIPPABLE_DYLIB = 0x00400000u , HAS_TLV_DESCRIPTORS = 0x00800000u ,
  NO_HEAP_EXECUTION = 0x01000000u , APP_EXTENSION_SAFE = 0x02000000u
}
 
enum class  CPU_TYPE : int32_t {
  ANY = -1 , X86 = 7 , X86_64 = 7 | ABI64 , MIPS = 8 ,
  MC98000 = 10 , ARM = 12 , ARM64 = 12 | ABI64 , SPARC = 14 ,
  POWERPC = 18 , POWERPC64 = 18 | ABI64
}
 
- 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

 Header ()=default
 
Headeroperator= (const Header &copy)=default
 
 Header (const Header &copy)=default
 
 ~Header () override=default
 
MACHO_TYPES magic () const
 The Mach-O magic bytes. These bytes determine whether it is a 32 bits Mach-O, a 64 bits Mach-O files etc.
 
CPU_TYPE cpu_type () const
 The CPU architecture targeted by this binary.
 
uint32_t cpu_subtype () const
 Return the CPU subtype supported by the Mach-O binary. For ARM architectures, this value could represent the minimum version for which the Mach-O binary has been compiled for.
 
FILE_TYPE file_type () const
 Return the type of the Mach-O file (executable, object, shared library, ...)
 
std::vector< FLAGSflags_list () const
 Return the FLAGS as a list.
 
bool has (FLAGS flag) const
 Check if the given HEADER_FLAGS is present in the header's flags.
 
uint32_t nb_cmds () const
 Number of LoadCommand present in the Mach-O binary.
 
uint32_t sizeof_cmds () const
 The size of all the LoadCommand.
 
uint32_t flags () const
 Header flags (cf. HEADER_FLAGS)
 
uint32_t reserved () const
 According to the official documentation, a reserved value.
 
void add (FLAGS flag)
 
OBJECT_TYPES abstract_object_type () const
 LIEF abstract object type.
 
std::pair< ARCHITECTURES, std::set< MODES > > abstract_architecture () const
 
ENDIANNESS abstract_endianness () const
 LIEF abstract endiannes.
 
void magic (MACHO_TYPES magic)
 
void cpu_type (CPU_TYPE type)
 
void cpu_subtype (uint32_t cpusubtype)
 
void file_type (FILE_TYPE filetype)
 
void nb_cmds (uint32_t ncmds)
 
void sizeof_cmds (uint32_t sizeofcmds)
 
void flags (uint32_t flags)
 
void remove (FLAGS flag)
 
void reserved (uint32_t reserved)
 
Headeroperator+= (FLAGS c)
 
Headeroperator-= (FLAGS c)
 
void accept (Visitor &visitor) const override
 
- 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 Attributes

static constexpr int ABI64 = 0x01000000
 
static constexpr uint32_t CPU_SUBTYPE_MASK = 0xff000000
 
static constexpr uint32_t CPU_SUBTYPE_LIB64 = 0x80000000
 

Detailed Description

Class that represents the Mach-O header.

Member Enumeration Documentation

◆ CPU_TYPE

enum class LIEF::MachO::Header::CPU_TYPE : int32_t
strong
Enumerator
ANY 
X86 
X86_64 
MIPS 
MC98000 
ARM 
ARM64 
SPARC 
POWERPC 
POWERPC64 

◆ FILE_TYPE

enum class LIEF::MachO::Header::FILE_TYPE : uint32_t
strong
Enumerator
UNKNOWN 
OBJECT 
EXECUTE 
FVMLIB 
CORE 
PRELOAD 
DYLIB 
DYLINKER 
BUNDLE 
DYLIB_STUB 
DSYM 
KEXT_BUNDLE 

◆ FLAGS

enum class LIEF::MachO::Header::FLAGS : uint32_t
strong
Enumerator
NOUNDEFS 
INCRLINK 
DYLDLINK 
BINDATLOAD 
PREBOUND 
SPLIT_SEGS 
LAZY_INIT 
TWOLEVEL 
FORCE_FLAT 
NOMULTIDEFS 
NOFIXPREBINDING 
PREBINDABLE 
ALLMODSBOUND 
SUBSECTIONS_VIA_SYMBOLS 
CANONICAL 
WEAK_DEFINES 
BINDS_TO_WEAK 
ALLOW_STACK_EXECUTION 
ROOT_SAFE 
SETUID_SAFE 
NO_REEXPORTED_DYLIBS 
PIE 
DEAD_STRIPPABLE_DYLIB 
HAS_TLV_DESCRIPTORS 
NO_HEAP_EXECUTION 
APP_EXTENSION_SAFE 

Constructor & Destructor Documentation

◆ Header() [1/2]

LIEF::MachO::Header::Header ( )
default

◆ Header() [2/2]

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

◆ ~Header()

LIEF::MachO::Header::~Header ( )
overridedefault

Member Function Documentation

◆ abstract_architecture()

std::pair< ARCHITECTURES, std::set< MODES > > LIEF::MachO::Header::abstract_architecture ( ) const

◆ abstract_endianness()

ENDIANNESS LIEF::MachO::Header::abstract_endianness ( ) const

LIEF abstract endiannes.

◆ abstract_object_type()

OBJECT_TYPES LIEF::MachO::Header::abstract_object_type ( ) const

LIEF abstract object type.

◆ accept()

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

Implements LIEF::Object.

◆ add()

void LIEF::MachO::Header::add ( FLAGS flag)

◆ cpu_subtype() [1/2]

uint32_t LIEF::MachO::Header::cpu_subtype ( ) const
inline

Return the CPU subtype supported by the Mach-O binary. For ARM architectures, this value could represent the minimum version for which the Mach-O binary has been compiled for.

◆ cpu_subtype() [2/2]

void LIEF::MachO::Header::cpu_subtype ( uint32_t cpusubtype)
inline

◆ cpu_type() [1/2]

CPU_TYPE LIEF::MachO::Header::cpu_type ( ) const
inline

The CPU architecture targeted by this binary.

◆ cpu_type() [2/2]

void LIEF::MachO::Header::cpu_type ( CPU_TYPE type)
inline

◆ file_type() [1/2]

FILE_TYPE LIEF::MachO::Header::file_type ( ) const
inline

Return the type of the Mach-O file (executable, object, shared library, ...)

◆ file_type() [2/2]

void LIEF::MachO::Header::file_type ( FILE_TYPE filetype)
inline

◆ flags() [1/2]

uint32_t LIEF::MachO::Header::flags ( ) const
inline

Header flags (cf. HEADER_FLAGS)

See also
flags_list

◆ flags() [2/2]

void LIEF::MachO::Header::flags ( uint32_t flags)
inline

◆ flags_list()

std::vector< FLAGS > LIEF::MachO::Header::flags_list ( ) const

Return the FLAGS as a list.

◆ has()

bool LIEF::MachO::Header::has ( FLAGS flag) const

Check if the given HEADER_FLAGS is present in the header's flags.

◆ magic() [1/2]

MACHO_TYPES LIEF::MachO::Header::magic ( ) const
inline

The Mach-O magic bytes. These bytes determine whether it is a 32 bits Mach-O, a 64 bits Mach-O files etc.

◆ magic() [2/2]

void LIEF::MachO::Header::magic ( MACHO_TYPES magic)
inline

◆ nb_cmds() [1/2]

uint32_t LIEF::MachO::Header::nb_cmds ( ) const
inline

Number of LoadCommand present in the Mach-O binary.

◆ nb_cmds() [2/2]

void LIEF::MachO::Header::nb_cmds ( uint32_t ncmds)
inline

◆ operator+=()

Header & LIEF::MachO::Header::operator+= ( FLAGS c)
inline

◆ operator-=()

Header & LIEF::MachO::Header::operator-= ( FLAGS c)
inline

◆ operator=()

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

◆ remove()

void LIEF::MachO::Header::remove ( FLAGS flag)

◆ reserved() [1/2]

uint32_t LIEF::MachO::Header::reserved ( ) const
inline

According to the official documentation, a reserved value.

◆ reserved() [2/2]

void LIEF::MachO::Header::reserved ( uint32_t reserved)
inline

◆ sizeof_cmds() [1/2]

uint32_t LIEF::MachO::Header::sizeof_cmds ( ) const
inline

The size of all the LoadCommand.

◆ sizeof_cmds() [2/2]

void LIEF::MachO::Header::sizeof_cmds ( uint32_t sizeofcmds)
inline

Member Data Documentation

◆ ABI64

int LIEF::MachO::Header::ABI64 = 0x01000000
staticconstexpr

◆ CPU_SUBTYPE_LIB64

uint32_t LIEF::MachO::Header::CPU_SUBTYPE_LIB64 = 0x80000000
staticconstexpr

◆ CPU_SUBTYPE_MASK

uint32_t LIEF::MachO::Header::CPU_SUBTYPE_MASK = 0xff000000
staticconstexpr

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