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_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 return chained_starts_in_segment(0, segment);
87 friend class BinaryParser;
88 friend class DyldChainedFixupsCreator;
89 chained_starts_in_segment(uint32_t offset, SegmentCommand& segment) :
93 chained_starts_in_segment(uint32_t offset,
const details::dyld_chained_starts_in_segment& info,
94 SegmentCommand& segment);
96 using chained_starts_in_segments_t = std::vector<chained_starts_in_segment>;
99 using it_chained_starts_in_segments_t = ref_iterator<chained_starts_in_segments_t&>;
102 using it_const_chained_starts_in_segments_t = const_ref_iterator<const chained_starts_in_segments_t&>;
105 using binding_info_t = std::vector<std::unique_ptr<ChainedBindingInfo>>;
108 using it_binding_info = ref_iterator<binding_info_t&, ChainedBindingInfo*>;
111 using it_const_binding_info = const_ref_iterator<const binding_info_t&, ChainedBindingInfo*>;
118 std::unique_ptr<LoadCommand>
clone()
const override {
119 return std::unique_ptr<DyldChainedFixups>(
new DyldChainedFixups(*
this));
136 data_offset_ = offset;
141 span<const uint8_t>
payload()
const {
149 return all_bindings_;
151 it_const_binding_info
bindings()
const {
154 return all_bindings_;
159 return chained_starts_in_segment_;
163 return chained_starts_in_segment_;
199 chained_starts_in_segment&
add(chained_starts_in_segment start_info) {
200 chained_starts_in_segment_.push_back(std::move(start_info));
201 return chained_starts_in_segment_.back();
204 void accept(Visitor& visitor)
const override;
206 std::ostream&
print(std::ostream& os)
const override;
209 return cmd->
command() == LoadCommand::TYPE::DYLD_CHAINED_FIXUPS;
213 LIEF_LOCAL void update_with(
const details::dyld_chained_fixups_header& header);
214 LIEF_LOCAL DyldChainedFixups& operator=(
const DyldChainedFixups& other);
215 LIEF_LOCAL DyldChainedFixups(
const DyldChainedFixups& other);
217 uint32_t data_offset_ = 0;
218 uint32_t data_size_ = 0;
222 span<uint8_t> content_;
224 uint32_t fixups_version_ = 0;
225 uint32_t starts_offset_ = 0;
226 uint32_t imports_offset_ = 0;
227 uint32_t symbols_offset_ = 0;
228 uint32_t imports_count_ = 0;
229 uint32_t symbols_format_ = 0;
232 chained_starts_in_segments_t chained_starts_in_segment_;
234 std::vector<std::unique_ptr<ChainedBindingInfoList>> internal_bindings_;
235 binding_info_t all_bindings_;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:75
Class which represents a MachO binary.
Definition MachO/Binary.hpp:86
Definition BindingInfoIterator.hpp:36
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_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:126
it_const_binding_info bindings() const
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:153
void imports_count(uint32_t cnt)
Definition DyldChainedFixups.hpp:185
void starts_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:173
it_binding_info bindings()
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:148
it_chained_starts_in_segments_t chained_starts_in_segments()
Iterator over the chained fixup metadata.
Definition DyldChainedFixups.hpp:158
it_const_chained_starts_in_segments_t chained_starts_in_segments() const
Definition DyldChainedFixups.hpp:162
void data_size(uint32_t size)
Definition DyldChainedFixups.hpp:138
uint32_t data_size() const
Size of the LC_DYLD_CHAINED_FIXUPS payload.
Definition DyldChainedFixups.hpp:131
uint32_t symbols_offset() const
Offset of symbol strings in chain data.
Definition DyldChainedFixups.hpp:180
chained_starts_in_segment & add(chained_starts_in_segment start_info)
Definition DyldChainedFixups.hpp:199
void data_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:135
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:192
span< const uint8_t > payload() const
Return the raw content of the command.
Definition DyldChainedFixups.hpp:143
uint32_t fixups_version() const
Chained fixups version. The loader (dyld v852.2) checks that this value is set to 0.
Definition DyldChainedFixups.hpp:168
uint32_t imports_offset() const
Offset of imports table in chain data.
Definition DyldChainedFixups.hpp:176
uint32_t imports_count() const
Number of imported symbol names.
Definition DyldChainedFixups.hpp:184
DYLD_CHAINED_FORMAT imports_format() const
The format of the imports (ChainedBindingInfo)
Definition DyldChainedFixups.hpp:196
void symbols_format(uint32_t fmt)
Definition DyldChainedFixups.hpp:193
void imports_format(DYLD_CHAINED_FORMAT fmt)
Definition DyldChainedFixups.hpp:197
~DyldChainedFixups() override
void accept(Visitor &visitor) const override
std::unique_ptr< LoadCommand > clone() const override
Definition DyldChainedFixups.hpp:118
void imports_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:177
std::ostream & print(std::ostream &os) const override
void fixups_version(uint32_t version)
Definition DyldChainedFixups.hpp:169
void symbols_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:181
static bool classof(const LoadCommand *cmd)
Definition DyldChainedFixups.hpp:208
uint32_t starts_offset() const
offset of dyld_chained_starts_in_image in chain_data
Definition DyldChainedFixups.hpp:172
DyldChainedFixups(const details::linkedit_data_command &cmd)
Definition LinkEdit.hpp:43
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:125
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)
static chained_starts_in_segment create_empty_chained(SegmentCommand &segment)
Definition DyldChainedFixups.hpp:82
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