LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_MACHO_DYLIB_COMMAND_H
17#define LIEF_MACHO_DYLIB_COMMAND_H
36 using version_t = std::array<uint16_t, 3>;
38 public:
static version_t
int2version(uint32_t version) {
42 static_cast<uint16_t
>(version >> 16),
43 static_cast<uint16_t
>((version >> 8) & 0xFF),
44 static_cast<uint16_t
>(version & 0xFF),
50 return (version[2]) | (version[1] << 8) | (version[0] << 16);
52 static DylibCommand
weak_dylib(
const std::string& name,
55 uint32_t timestamp = 0,
56 uint32_t current_version = 0,
57 uint32_t compat_version = 0);
58 static DylibCommand
id_dylib(
const std::string& name,
61 uint32_t timestamp = 0,
62 uint32_t current_version = 0,
63 uint32_t compat_version = 0);
64 static DylibCommand
load_dylib(
const std::string& name,
67 uint32_t timestamp = 2,
68 uint32_t current_version = 0,
69 uint32_t compat_version = 0);
73 uint32_t timestamp = 0,
74 uint32_t current_version = 0,
75 uint32_t compat_version = 0);
79 uint32_t timestamp = 0,
80 uint32_t current_version = 0,
81 uint32_t compat_version = 0);
85 uint32_t timestamp = 0,
86 uint32_t current_version = 0,
87 uint32_t compat_version = 0);
93 DylibCommand&
operator=(
const DylibCommand& copy) =
default;
98 std::unique_ptr<LoadCommand>
clone()
const override {
99 return std::unique_ptr<DylibCommand>(
new DylibCommand(*
this));
101 const std::string&
name()
const {
119 return int2version(current_version_);
124 return int2version(compatibility_version_);
128 name_ = std::move(name);
131 timestamp_ = timestamp;
134 current_version_ = version2int(version);
137 compatibility_version_ = version2int(version);
140 std::ostream&
print(std::ostream& os)
const override;
142 void accept(Visitor& visitor)
const override;
145 const LoadCommand::TYPE type = cmd->
command();
146 return type == LoadCommand::TYPE::LOAD_WEAK_DYLIB ||
147 type == LoadCommand::TYPE::ID_DYLIB ||
148 type == LoadCommand::TYPE::LOAD_DYLIB ||
149 type == LoadCommand::TYPE::LOAD_UPWARD_DYLIB ||
150 type == LoadCommand::TYPE::REEXPORT_DYLIB ||
151 type == LoadCommand::TYPE::LOAD_UPWARD_DYLIB ||
152 type == LoadCommand::TYPE::LAZY_LOAD_DYLIB;
157 LoadCommand::TYPE type,
const std::string& name, uint32_t timestamp,
158 uint32_t current_version, uint32_t compat_version);
161 uint32_t name_offset_ = 0;
162 uint32_t timestamp_ = 0;
163 uint32_t current_version_ = 0;
164 uint32_t compatibility_version_ = 0;
Class which represents a library dependency.
Definition DylibCommand.hpp:34
static DylibCommand reexport_dylib(const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_REEXPORT_DYLIB library.
void current_version(version_t version)
Definition DylibCommand.hpp:133
void timestamp(uint32_t timestamp)
Definition DylibCommand.hpp:130
uint32_t timestamp() const
Date and Time when the shared library was built.
Definition DylibCommand.hpp:113
std::ostream & print(std::ostream &os) const override
static uint32_t version2int(version_t version)
Helper to convert a version array into an integer.
Definition DylibCommand.hpp:49
static version_t int2version(uint32_t version)
Helper to convert an integer into a version array.
Definition DylibCommand.hpp:40
static DylibCommand lazy_load_dylib(const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_LAZY_LOAD_DYLIB library.
static bool classof(const LoadCommand *cmd)
Definition DylibCommand.hpp:144
DylibCommand(const DylibCommand ©)=default
void accept(Visitor &visitor) const override
std::unique_ptr< LoadCommand > clone() const override
Definition DylibCommand.hpp:98
version_t compatibility_version() const
Compatibility version of the shared library.
Definition DylibCommand.hpp:123
version_t current_version() const
Current version of the shared library.
Definition DylibCommand.hpp:118
static DylibCommand weak_dylib(const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_LOAD_WEAK_DYLIB library.
DylibCommand(const details::dylib_command &cmd)
DylibCommand & operator=(const DylibCommand ©)=default
void compatibility_version(version_t version)
Definition DylibCommand.hpp:136
static DylibCommand id_dylib(const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_ID_DYLIB library.
static DylibCommand load_dylib(const std::string &name, uint32_t timestamp=2, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_LOAD_DYLIB library.
void name(std::string name)
Definition DylibCommand.hpp:127
uint32_t name_offset() const
Original string offset of the name.
Definition DylibCommand.hpp:108
~DylibCommand() override=default
static DylibCommand load_upward_dylib(const std::string &name, uint32_t timestamp=0, uint32_t current_version=0, uint32_t compat_version=0)
Factory function to generate a LC_LOAD_UPWARD_DYLIB library.
const std::string & name() const
Library name.
Definition DylibCommand.hpp:103
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:125
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42