LIEF: Library to Instrument Executable Formats Version 0.16.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_MACHO_DYLD_CHAINED_FIXUPS_H
17#define LIEF_MACHO_DYLD_CHAINED_FIXUPS_H
33class ChainedBindingInfoList;
39struct linkedit_data_command;
40struct dyld_chained_fixups_header;
41struct dyld_chained_starts_in_segment;
50 friend class BinaryParser;
52 friend class LinkEdit;
53 friend class BindingInfoIterator;
55 friend class DyldChainedFixupsCreator;
57 public:
struct chained_starts_in_segment {
65 uint16_t page_size = 0;
66 uint64_t segment_offset = 0;
67 uint32_t max_valid_pointer = 0;
72 return page_start.size();
75 std::vector<uint16_t> page_start;
76 std::vector<uint16_t> chain_starts;
78 SegmentCommand& segment;
80 LIEF_API friend std::ostream&
operator<<(std::ostream& os,
const chained_starts_in_segment& info);
83 friend class BinaryParser;
84 friend class DyldChainedFixupsCreator;
85 chained_starts_in_segment(uint32_t offset, SegmentCommand& segment) :
89 chained_starts_in_segment(uint32_t offset,
const details::dyld_chained_starts_in_segment& info,
90 SegmentCommand& segment);
92 using chained_starts_in_segments_t = std::vector<chained_starts_in_segment>;
95 using it_chained_starts_in_segments_t = ref_iterator<chained_starts_in_segments_t&>;
98 using it_const_chained_starts_in_segments_t = const_ref_iterator<const chained_starts_in_segments_t&>;
101 using binding_info_t = std::vector<std::unique_ptr<ChainedBindingInfo>>;
104 using it_binding_info = ref_iterator<binding_info_t&, ChainedBindingInfo*>;
107 using it_const_binding_info = const_ref_iterator<const binding_info_t&, ChainedBindingInfo*>;
114 std::unique_ptr<LoadCommand>
clone()
const override {
115 return std::unique_ptr<DyldChainedFixups>(
new DyldChainedFixups(*
this));
132 data_offset_ = offset;
137 span<const uint8_t>
payload()
const {
145 return all_bindings_;
147 it_const_binding_info
bindings()
const {
150 return all_bindings_;
155 return chained_starts_in_segment_;
159 return chained_starts_in_segment_;
196 void accept(Visitor& visitor)
const override;
198 std::ostream&
print(std::ostream& os)
const override;
201 return cmd->
command() == LoadCommand::TYPE::DYLD_CHAINED_FIXUPS;
205 LIEF_LOCAL void update_with(
const details::dyld_chained_fixups_header& header);
206 LIEF_LOCAL DyldChainedFixups& operator=(
const DyldChainedFixups& other);
207 LIEF_LOCAL DyldChainedFixups(
const DyldChainedFixups& other);
209 uint32_t data_offset_ = 0;
210 uint32_t data_size_ = 0;
214 span<uint8_t> content_;
216 uint32_t fixups_version_ = 0;
217 uint32_t starts_offset_ = 0;
218 uint32_t imports_offset_ = 0;
219 uint32_t symbols_offset_ = 0;
220 uint32_t imports_count_ = 0;
221 uint32_t symbols_format_ = 0;
224 chained_starts_in_segments_t chained_starts_in_segment_;
226 std::vector<std::unique_ptr<ChainedBindingInfoList>> internal_bindings_;
227 binding_info_t all_bindings_;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
Class which represents a MachO binary.
Definition MachO/Binary.hpp:85
Definition BindingInfoIterator.hpp:36
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:57
This class represents a symbol binding operation associated with the LC_DYLD_CHAINED_FIXUPS command.
Definition ChainedBindingInfo.hpp:48
Definition DyldChainedFixupsCreator.hpp:41
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:49
uint32_t data_offset() const
Offset of the LC_DYLD_CHAINED_FIXUPS chained payload. This offset should point in the __LINKEDIT segm...
Definition DyldChainedFixups.hpp:122
it_const_binding_info bindings() const
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:149
void imports_count(uint32_t cnt)
Definition DyldChainedFixups.hpp:181
void starts_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:169
it_binding_info bindings()
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:144
it_chained_starts_in_segments_t chained_starts_in_segments()
Iterator over the chained fixup metadata.
Definition DyldChainedFixups.hpp:154
it_const_chained_starts_in_segments_t chained_starts_in_segments() const
Definition DyldChainedFixups.hpp:158
void data_size(uint32_t size)
Definition DyldChainedFixups.hpp:134
uint32_t data_size() const
Size of the LC_DYLD_CHAINED_FIXUPS payload.
Definition DyldChainedFixups.hpp:127
uint32_t symbols_offset() const
Offset of symbol strings in chain data.
Definition DyldChainedFixups.hpp:176
void data_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:131
uint32_t symbols_format() const
The compression algorithm (if any) used to store the symbols 0 means uncompressed while 1 means zlib ...
Definition DyldChainedFixups.hpp:188
span< const uint8_t > payload() const
Return the raw content of the command.
Definition DyldChainedFixups.hpp:139
uint32_t fixups_version() const
Chained fixups version. The loader (dyld v852.2) checks that this value is set to 0.
Definition DyldChainedFixups.hpp:164
uint32_t imports_offset() const
Offset of imports table in chain data.
Definition DyldChainedFixups.hpp:172
uint32_t imports_count() const
Number of imported symbol names.
Definition DyldChainedFixups.hpp:180
DYLD_CHAINED_FORMAT imports_format() const
The format of the imports (ChainedBindingInfo)
Definition DyldChainedFixups.hpp:192
void symbols_format(uint32_t fmt)
Definition DyldChainedFixups.hpp:189
void imports_format(DYLD_CHAINED_FORMAT fmt)
Definition DyldChainedFixups.hpp:193
~DyldChainedFixups() override
void accept(Visitor &visitor) const override
std::unique_ptr< LoadCommand > clone() const override
Definition DyldChainedFixups.hpp:114
void imports_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:173
std::ostream & print(std::ostream &os) const override
void fixups_version(uint32_t version)
Definition DyldChainedFixups.hpp:165
void symbols_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:177
static bool classof(const LoadCommand *cmd)
Definition DyldChainedFixups.hpp:200
uint32_t starts_offset() const
offset of dyld_chained_starts_in_image in chain_data
Definition DyldChainedFixups.hpp:168
DyldChainedFixups(const details::linkedit_data_command &cmd)
Definition LinkEdit.hpp:42
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:124
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:50
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
DYLD_CHAINED_FORMAT
Definition DyldChainedFormat.hpp:22
DYLD_CHAINED_PTR_FORMAT
Definition DyldChainedFormat.hpp:29
LIEF namespace.
Definition Abstract/Binary.hpp:36
friend std::ostream & operator<<(std::ostream &os, const chained_starts_in_segment &info)
size_t page_count() const
How many pages are in the page_start array.
Definition DyldChainedFixups.hpp:71
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42