79 constexpr static size_t MAX_RELOCATIONS = (std::numeric_limits<uint16_t>::max)();
82 constexpr static size_t MAX_COMMANDS = (std::numeric_limits<uint16_t>::max)();
85 static std::unique_ptr<Binary>
parse(
const std::string& file);
87 static std::unique_ptr<Binary>
parse(
const std::vector<uint8_t>& data,
90 static std::unique_ptr<Binary>
parse(
const std::vector<uint8_t>& data, uint64_t fat_offset,
93 static std::unique_ptr<Binary>
parse(std::unique_ptr<BinaryStream> stream, uint64_t fat_offset,
102 using exports_list_t = std::vector<std::unique_ptr<ExportInfo>>;
107 template<
class MACHO_T>
110 template<
class MACHO_T>
113 template<
class MACHO_T>
116 template<
class MACHO_T>
124 template<
class MACHO_T>
129 template<
class MACHO_T>
132 template<
class MACHO_T>
135 template<
class MACHO_T>
138 template<
class MACHO_T>
141 using it_opaque_segments =
void*;
143 template<
class MACHO_T>
145 uint64_t segment_offset,
const std::string& symbol_name,
146 int32_t ord, int64_t addend,
bool is_weak,
147 bool is_non_weak_definition, it_opaque_segments segments_ptr, uint64_t offset = 0);
150 template<
class MACHO_T>
151 ok_error_t do_rebase(uint8_t type, uint8_t segment_idx, uint64_t segment_offset,
152 it_opaque_segments segments);
158 template<
class MACHO_T>
161 template<
class MACHO_T>
162 ok_error_t parse_chained_import(
const details::dyld_chained_fixups_header& header,
164 template<
class MACHO_T>
165 ok_error_t parse_chained_fixup(
const details::dyld_chained_fixups_header& header,
168 template<
class MACHO_T>
170 uint64_t offset, uint32_t seg_idx);
172 template<
class MACHO_T>
174 int64_t addend,
bool is_weak);
176 template<
class MACHO_T>
178 const details::dyld_chained_starts_in_segment& seg_info);
180 template<
class MACHO_T>
181 result<uint64_t> next_chain(uint64_t chain_offset,
const details::dyld_chained_starts_in_segment& seg_info);
183 template<
class MACHO_T>
185 const details::dyld_chained_starts_in_segment& seg_info);
188 const details::dyld_chained_starts_in_segment& seg_info,
189 const details::dyld_chained_ptr_arm64e& fixup);
192 const details::dyld_chained_starts_in_segment& seg_info,
193 const details::dyld_chained_ptr_generic64& fixup);
196 const details::dyld_chained_starts_in_segment& seg_info,
197 const details::dyld_chained_ptr_generic32 & fixup);
199 template<
class MACHO_T>
202 template<
class MACHO_T>
205 template<
class MACHO_T>
208 template<
class MACHO_T>
211 template<
class MACHO_T>
214 template<
class MACHO_T>
217 template<
class MACHO_T>
220 template<
class MACHO_T>
223 template<
class MACHO_T>
233 ok_error_t parse_export_trie(exports_list_t& exports, uint64_t start,
234 uint64_t end,
const std::string& prefix,
235 bool* invalid_names);
239 std::unique_ptr<BinaryStream> stream_;
240 std::unique_ptr<Binary> binary_;
244 std::set<uint64_t> visited_;
245 std::unordered_map<std::string, Symbol*> memoized_symbols_;
246 std::map<uint64_t, Symbol*> memoized_symbols_by_address_;
248 std::vector<DylibCommand*> binding_libs_;
249 std::set<uint64_t> dyld_reloc_addrs_;