16#ifndef LIEF_MACHO_LAZY_LOAD_DYLIB_INFO_COMMAND_H
17#define LIEF_MACHO_LAZY_LOAD_DYLIB_INFO_COMMAND_H
41struct linkedit_data_command;
65 symbol_(std::move(
symbol)),
104 const Fixup& fixup) {
110 uint64_t address_ = 0;
111 uint32_t ordinal_ = 0;
113 bool is_auth_ =
false;
131 std::unique_ptr<LoadCommand>
clone()
const override {
146 data_offset_ = offset;
170 load_path_ = std::move(value);
177 return flag_image_offset_;
181 flag_image_offset_ = value;
214 return pointer_format_;
218 pointer_format_ = value;
224 return chain_start_image_offset_;
228 chain_start_image_offset_ = value;
239 symbols_ = std::move(value);
245 symbols_.push_back(std::move(value));
266 std::ostream&
print(std::ostream& os)
const override;
283 uint32_t data_offset_ = 0;
284 uint32_t data_size_ = 0;
287 std::string load_path_;
288 uint32_t flag_image_offset_ = 0;
290 uint16_t pointer_format_ = 0;
291 uint32_t chain_start_image_offset_ = 0;
292 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:79
Class which represents a MachO binary.
Definition MachO/Binary.hpp:91
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:64
uint64_t address() const
Virtual address of the slot bound by this fixup.
Definition LazyLoadDylibInfo.hpp:77
bool is_auth() const
Whether the bound pointer is authenticated (arm64e PAC).
Definition LazyLoadDylibInfo.hpp:97
uint32_t ordinal() const
Index of the bound symbol in the symbols table of LazyLoadDylibInfo.
Definition LazyLoadDylibInfo.hpp:86
Fixup(const Fixup &)=default
Fixup & operator=(const Fixup &)=default
Fixup(Fixup &&) noexcept=default
friend class Binary
Definition LazyLoadDylibInfo.hpp:58
const std::string & symbol() const
Name of the bound symbol, resolved from ordinal() (empty if the ordinal is out of the symbols() range...
Definition LazyLoadDylibInfo.hpp:92
friend std::ostream & operator<<(std::ostream &os, const Fixup &fixup)
Definition LazyLoadDylibInfo.hpp:103
void address(uint64_t value)
Definition LazyLoadDylibInfo.hpp:81
Fixup(uint64_t address, uint32_t ordinal, std::string symbol, bool is_auth)
Definition LazyLoadDylibInfo.hpp:62
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:176
static constexpr auto MAYBE_MISSING_FLAG
Definition LazyLoadDylibInfo.hpp:115
const std::vector< std::string > & symbols() const
List of the symbol names to bind lazily for this dylib.
Definition LazyLoadDylibInfo.hpp:233
void data_offset(uint32_t offset)
Definition LazyLoadDylibInfo.hpp:145
LazyLoadDylibInfo(const details::linkedit_data_command &cmd)
span< uint8_t > content()
Definition LazyLoadDylibInfo.hpp:159
LazyLoadDylibInfo & flag_image_offset(uint32_t value)
Definition LazyLoadDylibInfo.hpp:180
uint16_t flags() const
Raw flags associated with this command.
Definition LazyLoadDylibInfo.hpp:186
LazyLoadDylibInfo & operator=(const LazyLoadDylibInfo ©)=default
LazyLoadDylibInfo(const LazyLoadDylibInfo ©)=default
friend class BinaryParser
Definition LazyLoadDylibInfo.hpp:50
uint32_t data_offset() const
Offset in the __LINKEDIT segment where the payload starts.
Definition LazyLoadDylibInfo.hpp:136
it_fixups fixups()
Iterator over the lazy-binding Fixup entries.
Definition LazyLoadDylibInfo.hpp:256
span< const uint8_t > content() const
Return the data slice in the __LINKEDIT segment referenced by data_offset and data_size.
Definition LazyLoadDylibInfo.hpp:155
static bool classof(const LoadCommand *cmd)
Definition LazyLoadDylibInfo.hpp:268
it_const_fixups fixups() const
Definition LazyLoadDylibInfo.hpp:260
bool may_be_missing() const
Whether the dylib is allowed to be missing at runtime (i.e. "weaklinked").
Definition LazyLoadDylibInfo.hpp:197
LazyLoadDylibInfo & flags(uint16_t value)
Definition LazyLoadDylibInfo.hpp:190
friend class Builder
Definition LazyLoadDylibInfo.hpp:51
ref_iterator< fixups_t & > it_fixups
Iterator that outputs Fixup&.
Definition LazyLoadDylibInfo.hpp:120
LazyLoadDylibInfo & add_symbol(std::string value)
Append a symbol name to the list of symbols to bind lazily.
Definition LazyLoadDylibInfo.hpp:244
std::unique_ptr< LoadCommand > clone() const override
Definition LazyLoadDylibInfo.hpp:131
~LazyLoadDylibInfo() override=default
std::ostream & print(std::ostream &os) const override
friend class LinkEdit
Definition LazyLoadDylibInfo.hpp:52
LazyLoadDylibInfo & pointer_format(uint16_t value)
Definition LazyLoadDylibInfo.hpp:217
LazyLoadDylibInfo & chain_start_image_offset(uint32_t value)
Definition LazyLoadDylibInfo.hpp:227
LazyLoadDylibInfo & symbols(std::vector< std::string > value)
Replace the list of the symbol names to bind lazily for this dylib.
Definition LazyLoadDylibInfo.hpp:238
std::vector< Fixup > fixups_t
Definition LazyLoadDylibInfo.hpp:117
void data_size(uint32_t size)
Definition LazyLoadDylibInfo.hpp:149
uint16_t pointer_format() const
Chained-fixups pointer format used by the binding chain (e.g. DYLD_CHAINED_PTR_ARM64E_USERLAND).
Definition LazyLoadDylibInfo.hpp:213
const std::string & load_path() const
Load path of the dylib to bind lazily.
Definition LazyLoadDylibInfo.hpp:164
LazyLoadDylibInfo & clear_symbols()
Remove all the symbol names to bind lazily.
Definition LazyLoadDylibInfo.hpp:250
uint32_t data_size() const
Size of the payload.
Definition LazyLoadDylibInfo.hpp:141
LazyLoadDylibInfo & load_path(std::string value)
Change the load path of the dylib to bind lazily.
Definition LazyLoadDylibInfo.hpp:169
const_ref_iterator< const fixups_t & > it_const_fixups
Iterator that outputs const Fixup&.
Definition LazyLoadDylibInfo.hpp:123
LazyLoadDylibInfo & may_be_missing(bool value)
Set or clear the "may be missing" (weak linked) bit of flags().
Definition LazyLoadDylibInfo.hpp:202
uint32_t chain_start_image_offset() const
Image offset of the fixup chain start used to bind the dylib's symbols.
Definition LazyLoadDylibInfo.hpp:223
Definition LinkEdit.hpp:47
uint32_t size() const
Size of the command (should be greater than sizeof(load_command)).
Definition LoadCommand.hpp:135
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:130
@ LAZY_LOAD_DYLIB_INFO
Definition LoadCommand.hpp:106
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:52
Definition SpanStream.hpp:32
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:47
Definition iostream.hpp:32
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition endianness_support.hpp:60
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
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:320
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46