16#ifndef LIEF_MACHO_LOAD_COMMAND_H
17#define LIEF_MACHO_LOAD_COMMAND_H
42 using raw_t = std::vector<uint8_t>;
44 enum class TYPE: uint64_t {
121 virtual std::unique_ptr<LoadCommand>
clone()
const {
122 return std::unique_ptr<LoadCommand>(
new LoadCommand(*
this));
139 return original_data_;
144 return command_offset_;
148 original_data_ = std::move(
data);
160 command_offset_ = offset;
163 virtual std::ostream&
print(std::ostream& os)
const;
171 static_assert(std::is_base_of<LoadCommand, T>::value,
172 "Require LoadCommand inheritance");
173 if (T::classof(
this)) {
174 return static_cast<const T*
>(
this);
181 return const_cast<T*
>(
static_cast<const LoadCommand*
>(
this)->cast<T>());
187 return cmd.
print(os);
191 raw_t original_data_;
194 uint64_t command_offset_ = 0;
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:78
Class which represents a MachO binary.
Definition MachO/Binary.hpp:88
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:63
void command_offset(uint64_t offset)
Definition LoadCommand.hpp:159
void accept(Visitor &visitor) const override
virtual std::ostream & print(std::ostream &os) const
void data(raw_t data)
Definition LoadCommand.hpp:147
LoadCommand(const details::load_command &command)
friend std::ostream & operator<<(std::ostream &os, const LoadCommand &cmd)
Definition LoadCommand.hpp:186
uint32_t size() const
Size of the command (should be greather than sizeof(load_command)).
Definition LoadCommand.hpp:133
friend class BinaryParser
Definition LoadCommand.hpp:39
virtual std::unique_ptr< LoadCommand > clone() const
Definition LoadCommand.hpp:121
static bool is_linkedit_data(const LoadCommand &cmd)
void size(uint32_t size)
Definition LoadCommand.hpp:155
friend class Builder
Definition LoadCommand.hpp:38
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:128
span< const uint8_t > data() const
Raw command.
Definition LoadCommand.hpp:138
void command(LoadCommand::TYPE command)
Definition LoadCommand.hpp:151
void swap(LoadCommand &other) noexcept
friend class Binary
Definition LoadCommand.hpp:40
uint64_t command_offset() const
Offset of the command within the Load Command Table.
Definition LoadCommand.hpp:143
LoadCommand & operator=(const LoadCommand ©)=default
~LoadCommand() override=default
const T * cast() const
Definition LoadCommand.hpp:170
TYPE
Definition LoadCommand.hpp:44
@ ID_DYLINKER
Definition LoadCommand.hpp:60
@ DYSYMTAB
Definition LoadCommand.hpp:56
@ PREBOUND_DYLIB
Definition LoadCommand.hpp:61
@ LOAD_DYLINKER
Definition LoadCommand.hpp:59
@ SYMTAB
Definition LoadCommand.hpp:47
@ ROUTINES
Definition LoadCommand.hpp:62
@ NOTE
Definition LoadCommand.hpp:95
@ LOADFVMLIB
Definition LoadCommand.hpp:51
@ DYLD_INFO
Definition LoadCommand.hpp:79
@ TWOLEVEL_HINTS
Definition LoadCommand.hpp:67
@ MAIN
Definition LoadCommand.hpp:86
@ LOAD_WEAK_DYLIB
Definition LoadCommand.hpp:69
@ SEGMENT_64
Definition LoadCommand.hpp:70
@ SOURCE_VERSION
Definition LoadCommand.hpp:88
@ DYLD_INFO_ONLY
Definition LoadCommand.hpp:80
@ FUNCTION_STARTS
Definition LoadCommand.hpp:84
@ DYLD_EXPORTS_TRIE
Definition LoadCommand.hpp:97
@ ATOM_INFO
Definition LoadCommand.hpp:100
@ ENCRYPTION_INFO
Definition LoadCommand.hpp:78
@ ENCRYPTION_INFO_64
Definition LoadCommand.hpp:90
@ VERSION_MIN_TVOS
Definition LoadCommand.hpp:93
@ DYLD_CHAINED_FIXUPS
Definition LoadCommand.hpp:98
@ SEGMENT
Definition LoadCommand.hpp:46
@ THREAD
Definition LoadCommand.hpp:49
@ UUID
Definition LoadCommand.hpp:72
@ SUB_CLIENT
Definition LoadCommand.hpp:65
@ DYLIB_CODE_SIGN_DRS
Definition LoadCommand.hpp:89
@ SYMSEG
Definition LoadCommand.hpp:48
@ UNKNOWN
Definition LoadCommand.hpp:45
@ LIEF_UNKNOWN
Definition LoadCommand.hpp:105
@ IDFVMLIB
Definition LoadCommand.hpp:52
@ LOAD_DYLIB
Definition LoadCommand.hpp:57
@ CODE_SIGNATURE
Definition LoadCommand.hpp:74
@ LINKER_OPTION
Definition LoadCommand.hpp:91
@ SEGMENT_SPLIT_INFO
Definition LoadCommand.hpp:75
@ VERSION_MIN_WATCHOS
Definition LoadCommand.hpp:94
@ DYLD_ENVIRONMENT
Definition LoadCommand.hpp:85
@ ID_DYLIB
Definition LoadCommand.hpp:58
@ FUNCTION_VARIANTS
Definition LoadCommand.hpp:101
@ UNIXTHREAD
Definition LoadCommand.hpp:50
@ PREBIND_CKSUM
Definition LoadCommand.hpp:68
@ SUB_UMBRELLA
Definition LoadCommand.hpp:64
@ FILESET_ENTRY
Definition LoadCommand.hpp:99
@ SUB_LIBRARY
Definition LoadCommand.hpp:66
@ DATA_IN_CODE
Definition LoadCommand.hpp:87
@ LOAD_UPWARD_DYLIB
Definition LoadCommand.hpp:81
@ SUB_FRAMEWORK
Definition LoadCommand.hpp:63
@ VERSION_MIN_MACOSX
Definition LoadCommand.hpp:82
@ TARGET_TRIPLE
Definition LoadCommand.hpp:103
@ VERSION_MIN_IPHONEOS
Definition LoadCommand.hpp:83
@ REEXPORT_DYLIB
Definition LoadCommand.hpp:76
@ LINKER_OPTIMIZATION_HINT
Definition LoadCommand.hpp:92
@ FVMFILE
Definition LoadCommand.hpp:54
@ RPATH
Definition LoadCommand.hpp:73
@ PREPAGE
Definition LoadCommand.hpp:55
@ FUNCTION_VARIANT_FIXUPS
Definition LoadCommand.hpp:102
@ IDENT
Definition LoadCommand.hpp:53
@ BUILD_VERSION
Definition LoadCommand.hpp:96
@ ROUTINES_64
Definition LoadCommand.hpp:71
@ LAZY_LOAD_DYLIB
Definition LoadCommand.hpp:77
T * cast()
Definition LoadCommand.hpp:180
LoadCommand(const LoadCommand ©)=default
LoadCommand(LoadCommand::TYPE type, uint32_t size)
Definition LoadCommand.hpp:111
std::vector< uint8_t > raw_t
Definition LoadCommand.hpp:42
Definition Visitor.hpp:210
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:41