16#ifndef LIEF_MACHO_FUNCTION_VARIANTS_COMMAND_H
17#define LIEF_MACHO_FUNCTION_VARIANTS_COMMAND_H
36struct linkedit_data_command;
37struct runtime_table_entry_t;
67 static constexpr uint32_t
F_BIT = 20;
68 static constexpr uint32_t
F_MASK = (uint32_t(1) <<
F_BIT) - 1;
83 #define FUNCTION_VARIANT_FLAG(name, value, _) name = (value | F_ARM64),
85 #undef FUNCTION_VARIANT_FLAG
87 #define FUNCTION_VARIANT_FLAG(name, value, _) name = (value | F_X86_64),
89 #undef FUNCTION_VARIANT_FLAG
91 #define FUNCTION_VARIANT_FLAG(name, value, _) name = (value | F_SYSTEM_WIDE),
93 #undef FUNCTION_VARIANT_FLAG
95 #define FUNCTION_VARIANT_FLAG(name, value, _) name = (value | F_PER_PROCESS),
97 #undef FUNCTION_VARIANT_FLAG
124 return another_table_;
129 return flag_bit_nums_;
133 const std::vector<FLAGS>&
flags()
const {
147 LIEF_LOCAL void set_flags(std::vector<FLAGS> flags) {
148 flags_ = std::move(flags);
153 std::array<uint8_t, 4> flag_bit_nums_ = {};
154 std::vector<FLAGS> flags_;
229 entries_.push_back(std::move(entry));
242 KIND kind_ = KIND::UNKNOWN;
243 uint32_t offset_ = 0;
261 std::unique_ptr<LoadCommand>
clone()
const override {
276 data_offset_ = offset;
296 return runtime_table_;
300 return runtime_table_;
305 std::ostream&
print(std::ostream& os)
const override;
315 uint32_t data_offset_ = 0;
316 uint32_t data_size_ = 0;
318 std::vector<RuntimeTable> runtime_table_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:78
This class exposes information about a given implementation.
Definition FunctionVariants.hpp:65
RuntimeTableEntry()=default
span< const uint8_t > flag_bit_nums() const
The flagBitNums value as a slice of bytes.
Definition FunctionVariants.hpp:128
static constexpr uint32_t F_SYSTEM_WIDE
Definition FunctionVariants.hpp:71
static constexpr uint32_t F_MASK
Definition FunctionVariants.hpp:68
const std::vector< FLAGS > & flags() const
Return the interpreted flag_bit_nums().
Definition FunctionVariants.hpp:133
std::string to_string() const
static constexpr uint32_t F_PER_PROCESS
Definition FunctionVariants.hpp:70
FLAGS
Flags describing the target platform, environment, or architecture for a given function implementatio...
Definition FunctionVariants.hpp:80
@ UNKNOWN
Definition FunctionVariants.hpp:81
static constexpr uint32_t F_X86_64
Definition FunctionVariants.hpp:73
RuntimeTableEntry & operator=(const RuntimeTableEntry &)=default
static uint8_t get_raw(FLAGS f)
Definition FunctionVariants.hpp:100
bool another_table() const
Indicates whether impl() refers to an entry in another runtime table, rather than a direct function i...
Definition FunctionVariants.hpp:123
friend std::ostream & operator<<(std::ostream &os, const RuntimeTableEntry &entry)
Definition FunctionVariants.hpp:140
static constexpr uint32_t F_ARM64
Definition FunctionVariants.hpp:72
uint32_t impl() const
The relative address of the implementation or an index if another_table() is set.
Definition FunctionVariants.hpp:117
static constexpr uint32_t F_BIT
Definition FunctionVariants.hpp:67
static std::vector< RuntimeTable > parse_payload(SpanStream &stream)
it_const_runtime_table runtime_table() const
Definition FunctionVariants.hpp:299
static result< RuntimeTable > parse_entry(BinaryStream &stream)
FunctionVariants()=default
uint32_t data_offset() const
Offset in the __LINKEDIT SegmentCommand where the payload starts.
Definition FunctionVariants.hpp:266
span< const uint8_t > content() const
Return the data slice in the __LINKEDIT segment referenced by data_offset and data_size;.
Definition FunctionVariants.hpp:285
ref_iterator< runtime_table_t & > it_runtime_table
Iterator that outputs RuntimeTable&.
Definition FunctionVariants.hpp:250
friend class BinaryParser
Definition FunctionVariants.hpp:60
std::unique_ptr< LoadCommand > clone() const override
Definition FunctionVariants.hpp:261
FunctionVariants(const details::linkedit_data_command &cmd)
void data_offset(uint32_t offset)
Definition FunctionVariants.hpp:275
span< uint8_t > content()
Definition FunctionVariants.hpp:289
FunctionVariants & operator=(const FunctionVariants ©)=default
~FunctionVariants() override=default
FunctionVariants(const FunctionVariants ©)=default
void data_size(uint32_t size)
Definition FunctionVariants.hpp:279
it_runtime_table runtime_table()
Iterator over the different RuntimeTable entries located in the content of this __LINKEDIT command.
Definition FunctionVariants.hpp:295
uint32_t data_size() const
Size of the payload.
Definition FunctionVariants.hpp:271
std::vector< RuntimeTable > runtime_table_t
Definition FunctionVariants.hpp:247
friend class LinkEdit
Definition FunctionVariants.hpp:61
std::ostream & print(std::ostream &os) const override
const_ref_iterator< const runtime_table_t & > it_const_runtime_table
Iterator that outputs const RuntimeTable&.
Definition FunctionVariants.hpp:253
static bool classof(const LoadCommand *cmd)
Definition FunctionVariants.hpp:307
Definition LinkEdit.hpp:45
uint32_t size() const
Size of the command (should be greather than sizeof(load_command)).
Definition LoadCommand.hpp:133
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:128
@ FUNCTION_VARIANTS
Definition LoadCommand.hpp:101
Definition SpanStream.hpp:32
Iterator which returns reference on container's values.
Definition iterators.hpp:46
const char * to_string(lief_errors err)
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
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:257
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42