16#ifndef LIEF_MACHO_DYLD_INFO_COMMAND_H
17#define LIEF_MACHO_DYLD_INFO_COMMAND_H
24#include "LIEF/visibility.h"
25#include "LIEF/types.hpp"
26#include "LIEF/span.hpp"
28#include "LIEF/MachO/LoadCommand.hpp"
29#include "LIEF/MachO/type_traits.hpp"
30#include "LIEF/iterators.hpp"
46struct dyld_info_command;
59 using info_t = std::pair<uint32_t, uint32_t>;
80 enum class BINDING_ENCODING_VERSION {
87 DyldInfo(
const details::dyld_info_command& dyld_info_cmd);
115 span<uint8_t> rebase_opcodes();
142 span<uint8_t> bind_opcodes();
171 span<uint8_t> weak_bind_opcodes();
197 span<uint8_t> lazy_bind_opcodes();
243 span<uint8_t> export_trie();
251 void rebase(
const info_t& info);
252 void bind(
const info_t& info);
253 void weak_bind(
const info_t& info);
254 void lazy_bind(
const info_t& info);
255 void export_info(
const info_t& info);
257 void set_rebase_offset(uint32_t offset);
258 void set_rebase_size(uint32_t size);
260 void set_bind_offset(uint32_t offset);
261 void set_bind_size(uint32_t size);
263 void set_weak_bind_offset(uint32_t offset);
264 void set_weak_bind_size(uint32_t size);
266 void set_lazy_bind_offset(uint32_t offset);
267 void set_lazy_bind_size(uint32_t size);
269 void set_export_offset(uint32_t offset);
270 void set_export_size(uint32_t size);
272 void add(std::unique_ptr<ExportInfo> info);
275 void accept(
Visitor& visitor)
const override;
277 std::ostream& print(std::ostream& os)
const override;
284 void show_bindings(std::ostream& os, span<const uint8_t> buffer,
bool is_lazy =
false)
const;
286 void show_trie(std::ostream& output, std::string output_prefix,
BinaryStream& stream, uint64_t start, uint64_t end,
const std::string& prefix)
const;
290 LIEF_LOCAL
DyldInfo& update_standard_bindings_v2(
const bind_container_t& bindings,
301 span<uint8_t> rebase_opcodes_;
304 span<uint8_t> bind_opcodes_;
307 span<uint8_t> weak_bind_opcodes_;
310 span<uint8_t> lazy_bind_opcodes_;
313 span<uint8_t> export_trie_;
318 BINDING_ENCODING_VERSION binding_encoding_version_ = BINDING_ENCODING_VERSION::UNKNOWN;
320 Binary* binary_ =
nullptr;
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:73
Class which represents a MachO binary.
Definition MachO/Binary.hpp:74
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:58
This class represents a symbol binding operation associated with the LC_DYLD_INFO bytecode.
Definition DyldBindingInfo.hpp:35
Class that represents the LC_DYLD_INFO and LC_DYLD_INFO_ONLY commands.
Definition DyldInfo.hpp:50
span< const uint8_t > bind_opcodes() const
Return Binding's opcodes as raw data.
std::string show_lazy_bind_opcodes() const
Return the lazy opcodes in a humman-readable way.
std::vector< std::unique_ptr< DyldBindingInfo > > binding_info_t
Internal container for storing DyldBindingInfo.
Definition DyldInfo.hpp:62
span< const uint8_t > rebase_opcodes() const
Return Rebase's opcodes as raw data.
void lazy_bind_opcodes(buffer_t raw)
Set new opcodes.
const info_t & export_info() const
Export information
std::string show_export_trie() const
Return the export trie in a humman-readable way.
const info_t & bind() const
Bind information
const info_t & rebase() const
Rebase information
std::vector< std::unique_ptr< ExportInfo > > export_info_t
Internal container for storing ExportInfo.
Definition DyldInfo.hpp:71
void rebase_opcodes(buffer_t raw)
Set new opcodes.
const info_t & weak_bind() const
Weak Bind information
it_binding_info bindings()
Iterator over BindingInfo entries.
void weak_bind_opcodes(buffer_t raw)
Set new opcodes.
it_export_info exports()
Iterator over ExportInfo entries.
void bind_opcodes(buffer_t raw)
Set new opcodes.
std::pair< uint32_t, uint32_t > info_t
Tuple of offset and size
Definition DyldInfo.hpp:59
std::string show_bind_opcodes() const
Return the bind opcodes in a humman-readable way.
std::string show_rebases_opcodes() const
Return the rebase opcodes in a humman-readable way.
void export_trie(buffer_t raw)
Set new trie.
span< const uint8_t > lazy_bind_opcodes() const
Return Lazy Binding's opcodes as raw data.
const info_t & lazy_bind() const
Lazy Bind information
span< const uint8_t > export_trie() const
Return Export's trie as raw data.
span< const uint8_t > weak_bind_opcodes() const
Return Weak Binding's opcodes as raw data.
std::string show_weak_bind_opcodes() const
Return the bind opcodes in a humman-readable way.
Definition LinkEdit.hpp:48
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:39
Definition Visitor.hpp:219
Iterator which returns reference on container's values.
Definition iterators.hpp:48
Definition iostream.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:32