16#ifndef LIEF_MACHO_DYLD_CHAINED_FIXUPS_H
17#define LIEF_MACHO_DYLD_CHAINED_FIXUPS_H
30class ChainedBindingInfo;
31class ChainedBindingInfoList;
36struct linkedit_data_command;
37struct dyld_chained_fixups_header;
38struct dyld_chained_starts_in_segment;
59 uint16_t page_size = 0;
60 uint64_t segment_offset = 0;
61 uint32_t max_valid_pointer = 0;
66 return page_start.size();
104 std::unique_ptr<LoadCommand>
clone()
const override {
122 data_offset_ = offset;
130 return all_bindings_;
135 return all_bindings_;
140 return chained_starts_in_segment_;
144 return chained_starts_in_segment_;
183 std::ostream&
print(std::ostream& os)
const override;
186 return cmd->
command() == LoadCommand::TYPE::DYLD_CHAINED_FIXUPS;
190 void update_with(
const details::dyld_chained_fixups_header& header);
194 uint32_t data_offset_ = 0;
195 uint32_t data_size_ = 0;
201 uint32_t fixups_version_ = 0;
202 uint32_t starts_offset_ = 0;
203 uint32_t imports_offset_ = 0;
204 uint32_t symbols_offset_ = 0;
205 uint32_t imports_count_ = 0;
206 uint32_t symbols_format_ = 0;
209 chained_starts_in_segments_t chained_starts_in_segment_;
211 std::vector<std::unique_ptr<ChainedBindingInfoList>> internal_bindings_;
212 binding_info_t all_bindings_;
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:55
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:46
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:112
it_const_binding_info bindings() const
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:134
void imports_count(uint32_t cnt)
Definition DyldChainedFixups.hpp:166
void starts_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:154
it_binding_info bindings()
Iterator over the bindings (ChainedBindingInfo) associated with this command.
Definition DyldChainedFixups.hpp:129
it_chained_starts_in_segments_t chained_starts_in_segments()
Iterator over the chained fixup metadata.
Definition DyldChainedFixups.hpp:139
it_const_chained_starts_in_segments_t chained_starts_in_segments() const
Definition DyldChainedFixups.hpp:143
void data_size(uint32_t size)
Definition DyldChainedFixups.hpp:124
uint32_t data_size() const
Size of the LC_DYLD_CHAINED_FIXUPS payload.
Definition DyldChainedFixups.hpp:117
uint32_t symbols_offset() const
Offset of symbol strings in chain data.
Definition DyldChainedFixups.hpp:161
void data_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:121
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:173
std::vector< chained_starts_in_segment > chained_starts_in_segments_t
Internal container for storing chained_starts_in_segment.
Definition DyldChainedFixups.hpp:84
uint32_t fixups_version() const
Chained fixups version. The loader (dyld v852.2) checks that this value is set to 0.
Definition DyldChainedFixups.hpp:149
uint32_t imports_offset() const
Offset of imports table in chain data.
Definition DyldChainedFixups.hpp:157
uint32_t imports_count() const
Number of imported symbol names.
Definition DyldChainedFixups.hpp:165
DYLD_CHAINED_FORMAT imports_format() const
The format of the imports (ChainedBindingInfo)
Definition DyldChainedFixups.hpp:177
void symbols_format(uint32_t fmt)
Definition DyldChainedFixups.hpp:174
void imports_format(DYLD_CHAINED_FORMAT fmt)
Definition DyldChainedFixups.hpp:178
~DyldChainedFixups() override
void accept(Visitor &visitor) const override
std::unique_ptr< LoadCommand > clone() const override
Definition DyldChainedFixups.hpp:104
void imports_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:158
std::ostream & print(std::ostream &os) const override
void fixups_version(uint32_t version)
Definition DyldChainedFixups.hpp:150
void symbols_offset(uint32_t offset)
Definition DyldChainedFixups.hpp:162
std::vector< std::unique_ptr< ChainedBindingInfo > > binding_info_t
Internal container for storing DyldBindingInfo.
Definition DyldChainedFixups.hpp:93
static bool classof(const LoadCommand *cmd)
Definition DyldChainedFixups.hpp:185
uint32_t starts_offset() const
offset of dyld_chained_starts_in_image in chain_data
Definition DyldChainedFixups.hpp:153
DyldChainedFixups(const details::linkedit_data_command &cmd)
Definition LinkEdit.hpp:42
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:48
Definition Visitor.hpp:224
Iterator which returns reference on container's values.
Definition iterators.hpp:48
DYLD_CHAINED_FORMAT
Definition DyldChainedFormat.hpp:22
DYLD_CHAINED_PTR_FORMAT
Definition DyldChainedFormat.hpp:29
LIEF namespace.
Definition Abstract/Binary.hpp:32
tcb::span< ElementType, Extent > span
Definition span.hpp:22
Structure that mirrors the raw dyld_chained_starts_in_segment which aims at providing information abo...
Definition DyldChainedFixups.hpp:56
std::vector< uint16_t > chain_starts
Currently not supported.
Definition DyldChainedFixups.hpp:70
DYLD_CHAINED_PTR_FORMAT pointer_format
How pointers are encoded.
Definition DyldChainedFixups.hpp:62
friend std::ostream & operator<<(std::ostream &os, const chained_starts_in_segment &info)
SegmentCommand & segment
Segment in which the rebase/bind fixups take place.
Definition DyldChainedFixups.hpp:72
std::vector< uint16_t > page_start
Offset in the SegmentCommand of the first element of the chain.
Definition DyldChainedFixups.hpp:69
size_t page_count() const
How many pages are in the page_start array.
Definition DyldChainedFixups.hpp:65
#define LIEF_API
Definition visibility.h:41