15#ifndef LIEF_MACHO_LAZY_LOAD_DYLIB_INFO_COMMAND_H
16#define LIEF_MACHO_LAZY_LOAD_DYLIB_INFO_COMMAND_H
42struct linkedit_data_command;
66 symbol_(std::move(
symbol)),
105 const Fixup& fixup) {
111 uint64_t address_ = 0;
112 uint32_t ordinal_ = 0;
114 bool is_auth_ =
false;
132 std::unique_ptr<LoadCommand>
clone()
const override {
133 return std::make_unique<LazyLoadDylibInfo>(*
this);
147 data_offset_ = offset;
171 load_path_ = std::move(value);
178 return flag_image_offset_;
182 flag_image_offset_ = value;
215 return pointer_format_;
219 pointer_format_ = value;
225 return chain_start_image_offset_;
229 chain_start_image_offset_ = value;
240 symbols_ = std::move(value);
246 symbols_.push_back(std::move(value));
267 std::ostream&
print(std::ostream& os)
const override;
284 uint32_t data_offset_ = 0;
285 uint32_t data_size_ = 0;
288 std::string load_path_;
289 uint32_t flag_image_offset_ = 0;
291 uint16_t pointer_format_ = 0;
292 uint32_t chain_start_image_offset_ = 0;
293 std::vector<std::string> symbols_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
Class used to parse a single binary (i.e. non-FAT).
Definition BinaryParser.hpp:80
Class which represents a MachO binary.
Definition MachO/Binary.hpp:93
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:63
uint64_t address() const
Virtual address of the slot bound by this fixup.
Definition LazyLoadDylibInfo.hpp:78
bool is_auth() const
Whether the bound pointer is authenticated (arm64e PAC).
Definition LazyLoadDylibInfo.hpp:98
uint32_t ordinal() const
Index of the bound symbol in the symbols table of LazyLoadDylibInfo.
Definition LazyLoadDylibInfo.hpp:87
Fixup(const Fixup &)=default
Fixup & operator=(const Fixup &)=default
Fixup(Fixup &&) noexcept=default
std::string_view symbol() const
Name of the bound symbol, resolved from ordinal() (empty if the ordinal is out of the symbols() range...
Definition LazyLoadDylibInfo.hpp:93
friend class Binary
Definition LazyLoadDylibInfo.hpp:59
friend std::ostream & operator<<(std::ostream &os, const Fixup &fixup)
Definition LazyLoadDylibInfo.hpp:104
void address(uint64_t value)
Definition LazyLoadDylibInfo.hpp:82
Fixup(uint64_t address, uint32_t ordinal, std::string symbol, bool is_auth)
Definition LazyLoadDylibInfo.hpp:63
std::string to_string() const
uint32_t flag_image_offset() const
Image offset of the global flag that is set once the dylib has been loaded by dyld.
Definition LazyLoadDylibInfo.hpp:177
static constexpr auto MAYBE_MISSING_FLAG
Definition LazyLoadDylibInfo.hpp:116
const std::vector< std::string > & symbols() const
List of the symbol names to bind lazily for this dylib.
Definition LazyLoadDylibInfo.hpp:234
void data_offset(uint32_t offset)
Definition LazyLoadDylibInfo.hpp:146
LazyLoadDylibInfo(const details::linkedit_data_command &cmd)
span< uint8_t > content()
Definition LazyLoadDylibInfo.hpp:160
LazyLoadDylibInfo & flag_image_offset(uint32_t value)
Definition LazyLoadDylibInfo.hpp:181
uint16_t flags() const
Raw flags associated with this command.
Definition LazyLoadDylibInfo.hpp:187
LazyLoadDylibInfo & operator=(const LazyLoadDylibInfo ©)=default
LazyLoadDylibInfo(const LazyLoadDylibInfo ©)=default
friend class BinaryParser
Definition LazyLoadDylibInfo.hpp:51
uint32_t data_offset() const
Offset in the __LINKEDIT segment where the payload starts.
Definition LazyLoadDylibInfo.hpp:137
it_fixups fixups()
Iterator over the lazy-binding Fixup entries.
Definition LazyLoadDylibInfo.hpp:257
span< const uint8_t > content() const
Return the data slice in the __LINKEDIT segment referenced by data_offset and data_size.
Definition LazyLoadDylibInfo.hpp:156
static bool classof(const LoadCommand *cmd)
Definition LazyLoadDylibInfo.hpp:269
it_const_fixups fixups() const
Definition LazyLoadDylibInfo.hpp:261
bool may_be_missing() const
Whether the dylib is allowed to be missing at runtime (i.e. "weaklinked").
Definition LazyLoadDylibInfo.hpp:198
LazyLoadDylibInfo & flags(uint16_t value)
Definition LazyLoadDylibInfo.hpp:191
friend class Builder
Definition LazyLoadDylibInfo.hpp:52
ref_iterator< fixups_t & > it_fixups
Iterator that outputs Fixup&.
Definition LazyLoadDylibInfo.hpp:121
LazyLoadDylibInfo & add_symbol(std::string value)
Append a symbol name to the list of symbols to bind lazily.
Definition LazyLoadDylibInfo.hpp:245
std::unique_ptr< LoadCommand > clone() const override
Definition LazyLoadDylibInfo.hpp:132
~LazyLoadDylibInfo() override=default
std::ostream & print(std::ostream &os) const override
friend class LinkEdit
Definition LazyLoadDylibInfo.hpp:53
LazyLoadDylibInfo & pointer_format(uint16_t value)
Definition LazyLoadDylibInfo.hpp:218
LazyLoadDylibInfo & chain_start_image_offset(uint32_t value)
Definition LazyLoadDylibInfo.hpp:228
LazyLoadDylibInfo & symbols(std::vector< std::string > value)
Replace the list of the symbol names to bind lazily for this dylib.
Definition LazyLoadDylibInfo.hpp:239
std::vector< Fixup > fixups_t
Definition LazyLoadDylibInfo.hpp:118
void data_size(uint32_t size)
Definition LazyLoadDylibInfo.hpp:150
uint16_t pointer_format() const
Chained-fixups pointer format used by the binding chain (e.g. DYLD_CHAINED_PTR_ARM64E_USERLAND).
Definition LazyLoadDylibInfo.hpp:214
LazyLoadDylibInfo & clear_symbols()
Remove all the symbol names to bind lazily.
Definition LazyLoadDylibInfo.hpp:251
uint32_t data_size() const
Size of the payload.
Definition LazyLoadDylibInfo.hpp:142
std::string_view load_path() const
Load path of the dylib to bind lazily.
Definition LazyLoadDylibInfo.hpp:165
LazyLoadDylibInfo & load_path(std::string value)
Change the load path of the dylib to bind lazily.
Definition LazyLoadDylibInfo.hpp:170
const_ref_iterator< const fixups_t & > it_const_fixups
Iterator that outputs const Fixup&.
Definition LazyLoadDylibInfo.hpp:124
LazyLoadDylibInfo & may_be_missing(bool value)
Set or clear the "may be missing" (weak linked) bit of flags().
Definition LazyLoadDylibInfo.hpp:203
uint32_t chain_start_image_offset() const
Image offset of the fixup chain start used to bind the dylib's symbols.
Definition LazyLoadDylibInfo.hpp:224
Definition LinkEdit.hpp:46
uint32_t size() const
Size of the command (should be greater than sizeof(load_command)).
Definition LoadCommand.hpp:136
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:131
@ LAZY_LOAD_DYLIB_INFO
Definition LoadCommand.hpp:106
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:53
Definition SpanStream.hpp:31
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:118
Iterator which returns reference on container's values.
Definition iterators.hpp:120
Definition iostream.hpp:33
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:62
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:35
LIEF namespace.
Definition Abstract/Binary.hpp:41
tcb::span< ElementType, Extent > span
Definition span.hpp:22
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:385
#define LIEF_API
Definition visibility.h:44
#define LIEF_LOCAL
Definition visibility.h:45