LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
MachO/Binary.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_MACHO_BINARY_H
17#define LIEF_MACHO_BINARY_H
18
19#include <string_view>
20#include <map>
21#include <memory>
22#include <mutex>
23#include <set>
24#include <vector>
25
27
31#include "LIEF/MachO/Header.hpp"
33#include "LIEF/MachO/Stub.hpp"
34
36#include "LIEF/utils.hpp"
37#include "LIEF/visibility.h"
38
40
41#include "LIEF/errors.hpp"
42#include "LIEF/iterators.hpp"
43
44namespace LIEF {
45
46namespace objc {
47class Metadata;
48}
49
51namespace MachO {
52
53class AtomInfo;
54class BinaryParser;
55class Builder;
56class CodeSignature;
57class CodeSignatureDir;
58class DataInCode;
59class DyldChainedFixups;
60class DyldEnvironment;
61class DyldExportsTrie;
62class DyldInfo;
63class DylibCommand;
64class DylinkerCommand;
65class DynamicSymbolCommand;
66class EncryptionInfo;
67class ExportInfo;
68class FunctionStarts;
69class FunctionVariants;
70class FunctionVariantFixups;
71class LazyLoadDylibInfo;
72class Header;
73class IndirectBindingInfo;
74class LinkerOptHint;
75class MainCommand;
76class Parser;
77class RPathCommand;
78class Relocation;
79class Routine;
80class Section;
81class SegmentCommand;
82class SegmentSplitInfo;
83class SourceVersion;
84class SubClient;
85class SubFramework;
86class Symbol;
87class SymbolCommand;
88class ThreadCommand;
89class TwoLevelHints;
90class UUIDCommand;
91class VersionMin;
92
95
96 friend class Parser;
97 friend class BinaryParser;
98 friend class Builder;
99 friend class DyldInfo;
101
102 public:
103 struct range_t {
104 uint64_t start = 0;
105 uint64_t end = 0;
106
107 uint64_t size() const {
108 return end - start;
109 }
110
111 bool empty() const {
112 return start == end;
113 }
114 };
115
117 using commands_t = std::vector<std::unique_ptr<LoadCommand>>;
118
121
124
126 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
127
130
133
136
140
143
147
149 using sections_cache_t = std::vector<Section*>;
150
153
156
158 using segments_cache_t = std::vector<SegmentCommand*>;
159
162
165
167 using libraries_cache_t = std::vector<DylibCommand*>;
168
171
174
176 using lazy_load_dylib_info_cache_t = std::vector<LazyLoadDylibInfo*>;
177
180
184
186 using fileset_binaries_t = std::vector<std::unique_ptr<Binary>>;
187
190
194
195 struct KeyCmp {
196 bool operator()(const Relocation* lhs, const Relocation* rhs) const;
197 };
198
202 using relocations_t = std::set<Relocation*, KeyCmp>;
203
206
210
213
217
220
224
226
229
232
236
237 public:
238 Binary(const Binary&) = delete;
239 Binary& operator=(const Binary&) = delete;
240
243 return header_;
244 }
245
247 return header_;
248 }
249
253 return commands_;
254 }
255
257 return commands_;
258 }
259
263 return filesets_;
264 }
265
267 return filesets_;
268 }
269
272 return symbols_;
273 }
275 return symbols_;
276 }
277
279 bool has_symbol(const std::string& name) const {
280 return get_symbol(name) != nullptr;
281 }
282
285 const Symbol* get_symbol(const std::string& name) const LIEF_LIFETIMEBOUND;
286 Symbol* get_symbol(const std::string& name) LIEF_LIFETIMEBOUND {
287 return const_cast<Symbol*>(static_cast<const Binary*>(this)->get_symbol(name));
288 }
289
291 static bool is_exported(const Symbol& symbol);
292
295 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
296 return is_exported(*symbol);
297 }};
298 }
300 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
301 return is_exported(*symbol);
302 }};
303 }
304
306 static bool is_imported(const Symbol& symbol);
307
310 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
311 return is_imported(*symbol);
312 }};
313 }
314
316 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
317 return is_imported(*symbol);
318 }};
319 }
320
323 return libraries_;
324 }
325
327 return libraries_;
328 }
329
333 return lazy_load_dylib_infos_;
334 }
335
337 return lazy_load_dylib_infos_;
338 }
339
342 return segments_;
343 }
345 return segments_;
346 }
347
350 return sections_;
351 }
353 return sections_;
354 }
355
358 return static_cast<const Binary*>(this)->relocations();
359 }
360
362
366 void write(const std::string& filename);
367
375 void write(const std::string& filename, Builder::config_t config);
376
380 void write(std::ostream& os);
381
387 void write(std::ostream& os, Builder::config_t config);
388
390 std::vector<uint8_t> raw();
391
393 bool has(LoadCommand::TYPE type) const;
394
399 return const_cast<LoadCommand*>(static_cast<const Binary*>(this)->get(type));
400 }
401
402 LoadCommand* add(std::unique_ptr<LoadCommand> command) LIEF_LIFETIMEBOUND;
403
406 return add(command.clone());
407 }
408
411
414
417
419 LoadCommand* add_library(const std::string& name) LIEF_LIFETIMEBOUND;
420
423
428 const DylibCommand*
429 find_library(const std::string& name) const LIEF_LIFETIMEBOUND;
430
431 DylibCommand* find_library(const std::string& name) LIEF_LIFETIMEBOUND {
432 return const_cast<DylibCommand*>(
433 static_cast<const Binary*>(this)->find_library(name)
434 );
435 }
436
442 const Section& section) LIEF_LIFETIMEBOUND;
443
448 void remove_section(const std::string& name, bool clear = false) override;
449
457 void remove_section(const std::string& segname, const std::string& secname,
458 bool clear = false);
459
462
465
467 bool remove_command(size_t index);
468
471
473 bool extend(const LoadCommand& command, uint64_t size);
474
476 bool extend_segment(const SegmentCommand& segment, size_t size);
477
484 bool extend_section(Section& section, size_t size);
485
488
490 uint64_t imagebase() const override;
491
493 uint64_t virtual_size() const override {
494 return align(va_ranges().size(), (uint64_t)page_size());
495 }
496
499 std::string_view loader() const LIEF_LIFETIMEBOUND;
500
502 bool has_section(const std::string& name) const {
503 return get_section(name) != nullptr;
504 }
505
508 Section* get_section(const std::string& name) LIEF_LIFETIMEBOUND {
509 return const_cast<Section*>(
510 static_cast<const Binary*>(this)->get_section(name)
511 );
512 }
513
516 const Section* get_section(const std::string& name) const LIEF_LIFETIMEBOUND;
517
521 Section* get_section(const std::string& segname,
522 const std::string& secname) LIEF_LIFETIMEBOUND {
523 return const_cast<Section*>(
524 static_cast<const Binary*>(this)->get_section(segname, secname)
525 );
526 }
527
528 const Section* get_section(const std::string& segname,
529 const std::string& secname) const LIEF_LIFETIMEBOUND;
530
532 bool has_segment(const std::string& name) const {
533 return get_segment(name) != nullptr;
534 }
535
537 const SegmentCommand*
538 get_segment(const std::string& name) const LIEF_LIFETIMEBOUND;
539
542 return const_cast<SegmentCommand*>(
543 static_cast<const Binary*>(this)->get_segment(name)
544 );
545 }
546
548 bool remove_symbol(const std::string& name);
549
551 bool remove(const Symbol& sym);
552
554 bool can_remove(const Symbol& sym) const;
555
557 bool can_remove_symbol(const std::string& name) const;
558
560 bool unexport(const std::string& name);
561
563 bool unexport(const Symbol& sym);
564
568 return const_cast<Section*>(
569 static_cast<const Binary*>(this)->section_from_offset(offset)
570 );
571 }
572 const Section* section_from_offset(uint64_t offset) const LIEF_LIFETIMEBOUND;
573
576 Section*
578 return const_cast<Section*>(
579 static_cast<const Binary*>(this)->section_from_virtual_address(
580 virtual_address
581 )
582 );
583 }
585 uint64_t virtual_address
586 ) const LIEF_LIFETIMEBOUND;
587
589 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
590
597 uint64_t slide = 0) const override;
598
603 return const_cast<SegmentCommand*>(
604 static_cast<const Binary*>(this)->segment_from_offset(offset)
605 );
606 }
607 const SegmentCommand*
609
611 size_t segment_index(const SegmentCommand& segment) const;
612
614 uint64_t fat_offset() const {
615 return fat_offset_;
616 }
617
622 return const_cast<SegmentCommand*>(
623 static_cast<const Binary*>(this)->segment_from_virtual_address(
624 virtual_address
625 )
626 );
627 }
629 uint64_t virtual_address
630 ) const LIEF_LIFETIMEBOUND;
631
634
637
640
643 bool is_valid_addr(uint64_t address) const {
644 const range_t& r = va_ranges();
645 return r.start <= address && address < r.end;
646 }
647
649 void accept(LIEF::Visitor& visitor) const override;
650
651 std::ostream& print(std::ostream& os) const override;
652
659 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
660 LIEF::Binary::VA_TYPES addr_type =
662
671 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
673 ) override;
674
677 uint64_t virtual_address, uint64_t size,
679 ) const LIEF_LIFETIMEBOUND override;
680
682 uint64_t entrypoint() const override;
683
685 bool is_pie() const override {
686 return header().has(Header::FLAGS::PIE);
687 }
688
690 bool has_nx() const override {
691 return has_nx_stack();
692 }
693
695 bool has_nx_stack() const {
697 }
698
700 bool has_nx_heap() const {
702 }
703
707 bool has_entrypoint() const {
709 }
710
712 bool has_uuid() const {
713 return uuid() != nullptr;
714 }
715
719
721 bool has_main_command() const {
722 return main_command() != nullptr;
723 }
724
728
730 bool has_dylinker() const {
731 return dylinker() != nullptr;
732 }
733
737
739 bool has_dyld_info() const {
740 return dyld_info() != nullptr;
741 }
742
746
748 bool has_function_starts() const {
749 return function_starts() != nullptr;
750 }
751
755
757 bool has_source_version() const {
758 return source_version() != nullptr;
759 }
760
764
766 bool has_version_min() const {
767 return version_min() != nullptr;
768 }
769
773
775 bool has_thread_command() const {
776 return thread_command() != nullptr;
777 }
778
782
784 bool has_routine_command() const {
785 return routine_command() != nullptr;
786 }
787
791
793 bool has_rpath() const {
794 return rpath() != nullptr;
795 }
796
800
804
806 bool has_symbol_command() const {
807 return symbol_command() != nullptr;
808 }
809
813
816 return dynamic_symbol_command() != nullptr;
817 }
818
822
824 bool has_code_signature() const {
825 return code_signature() != nullptr;
826 }
827
830 return const_cast<CodeSignature*>(
831 static_cast<const Binary*>(this)->code_signature()
832 );
833 }
835
838 return code_signature_dir() != nullptr;
839 }
840
843 return const_cast<CodeSignatureDir*>(
844 static_cast<const Binary*>(this)->code_signature_dir()
845 );
846 }
848
850 bool has_data_in_code() const {
851 return data_in_code() != nullptr;
852 }
853
857
860 return segment_split_info() != nullptr;
861 }
862
866
868 bool has_sub_framework() const {
869 return sub_framework() != nullptr;
870 }
871
873 bool has_encryption_info() const {
874 return encryption_info() != nullptr;
875 }
876
880
884
888
889 bool has_subclients() const;
890
892 bool has_dyld_environment() const {
893 return dyld_environment() != nullptr;
894 }
895
899
901 bool has_build_version() const {
902 return build_version() != nullptr;
903 }
904
908
911 if (const BuildVersion* version = build_version()) {
912 return version->platform();
913 }
915 }
916
922
928
929
932 return dyld_chained_fixups() != nullptr;
933 }
934
938
941 return dyld_exports_trie() != nullptr;
942 }
943
947
949 bool has_two_level_hints() const {
950 return two_level_hints() != nullptr;
951 }
952
955 return const_cast<TwoLevelHints*>(
956 static_cast<const Binary*>(this)->two_level_hints()
957 );
958 }
960
962 bool has_linker_opt_hint() const {
963 return linker_opt_hint() != nullptr;
964 }
965
968 return const_cast<LinkerOptHint*>(
969 static_cast<const Binary*>(this)->linker_opt_hint()
970 );
971 }
973
976 const std::string& name) LIEF_LIFETIMEBOUND;
977
979 Symbol* add_local_symbol(uint64_t address,
980 const std::string& name) LIEF_LIFETIMEBOUND;
981
983 std::unique_ptr<objc::Metadata> objc_metadata() const;
984
993
995 bool has_atom_info() const {
996 return atom_info() != nullptr;
997 }
998
1001 return const_cast<AtomInfo*>(static_cast<const Binary*>(this)->atom_info());
1002 }
1004
1007
1009
1011 bool has_notes() const {
1012 return get(LoadCommand::TYPE::NOTE) != nullptr;
1013 }
1014
1017 return function_variants() != nullptr;
1018 }
1019
1022 return const_cast<FunctionVariants*>(
1023 static_cast<const Binary*>(this)->function_variants()
1024 );
1025 }
1026
1028
1031 return function_variant_fixups() != nullptr;
1032 }
1033
1036 return const_cast<FunctionVariantFixups*>(
1037 static_cast<const Binary*>(this)->function_variant_fixups()
1038 );
1039 }
1040
1042
1043 template<class T>
1045
1046 template<class T>
1048
1049 template<class T>
1050 LIEF_LOCAL const T* command() const;
1051
1052 template<class T>
1054
1055 template<class CMD, class Func>
1057
1059 return get(type);
1060 }
1062 return get(type);
1063 }
1064
1067
1070
1073
1075 bool has_filesets() const {
1076 return !filesets_.empty();
1077 }
1078
1081 std::string_view fileset_name() const LIEF_LIFETIMEBOUND {
1082 return fileset_info_.name;
1083 }
1084
1086 uint64_t fileset_addr() const {
1087 return fileset_info_.address;
1088 }
1089
1092
1093 ~Binary() override;
1094
1097 ok_error_t shift(size_t value);
1098
1101
1106 uint64_t memory_base_address() const {
1107 return in_memory_base_addr_;
1108 }
1109
1112 return header().cpu_type() == Header::CPU_TYPE::ARM64 &&
1113 (header().cpu_subtype() & ~Header::SUBTYPE_MASK) ==
1115 }
1116
1120
1122 result<uint64_t> get_function_address(const std::string& name) const override;
1123
1124 static bool classof(const LIEF::Binary* bin) {
1125 return bin->format() == Binary::FORMATS::MACHO;
1126 }
1127
1129 return overlay_;
1130 }
1131
1134
1136 static LIEF_LOCAL bool can_cache_segment(const SegmentCommand& segment);
1137
1139 LIEF_LOCAL size_t available_command_space() const {
1140 return available_command_space_;
1141 }
1142
1143 private:
1146
1147 LIEF_LOCAL void shift_command(size_t width, uint64_t from_offset);
1148
1151 LIEF_LOCAL size_t add_cached_segment(SegmentCommand& segment);
1152
1153 template<class T>
1154 LIEF_LOCAL ok_error_t patch_relocation(Relocation& relocation, uint64_t from,
1155 uint64_t shift);
1156
1157 LIEF::Header get_abstract_header() const override {
1158 return LIEF::Header::from(*this);
1159 }
1160
1161 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1162 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1163 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1165 get_abstract_exported_functions() const override;
1167 get_abstract_imported_functions() const override;
1168 LIEF_LOCAL std::vector<std::string>
1169 get_abstract_imported_libraries() const override;
1170
1174 ok_error_t ensure_command_space(size_t size) {
1175 return available_command_space_ < size ? shift(size) : ok();
1176 }
1177
1178 relocations_t& relocations_list() {
1179 return relocations_;
1180 }
1181
1182 const relocations_t& relocations_list() const {
1183 return relocations_;
1184 }
1185
1186 size_t pointer_size() const {
1187 return is64_ ? sizeof(uint64_t) : sizeof(uint32_t);
1188 }
1189
1190 bool is64_ = true;
1191 Header header_;
1192 commands_t commands_;
1193 symbols_t symbols_;
1194
1195 // Same purpose as sections_cache_t
1196 libraries_cache_t libraries_;
1197
1198 // Cache of the LC_LAZY_LOAD_DYLIB_INFO commands
1199 lazy_load_dylib_info_cache_t lazy_load_dylib_infos_;
1200
1201 // The sections are owned by the SegmentCommand object.
1202 // This attribute is a cache to speed-up the iteration
1203 sections_cache_t sections_;
1204
1205 // Same purpose as sections_cache_t
1206 segments_cache_t segments_;
1207
1208 fileset_binaries_t filesets_;
1209
1210 // Cached relocations from segment / sections
1211 mutable relocations_t relocations_;
1212 size_t available_command_space_ = 0;
1213
1214 // This is used to improve performances of
1215 // offset_to_virtual_address
1216 std::map<uint64_t, SegmentCommand*> offset_seg_;
1217
1218 protected:
1219 struct fileset_info_t {
1220 std::string name;
1221 uint64_t address = 0;
1222 };
1223
1224 uint64_t fat_offset_ = 0;
1225 uint64_t in_memory_base_addr_ = 0;
1226 std::vector<uint8_t> overlay_;
1227 std::vector<std::unique_ptr<IndirectBindingInfo>> indirect_bindings_;
1228 fileset_info_t fileset_info_;
1229 mutable std::mutex mu_;
1230};
1231
1232}
1233}
1234#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:60
std::vector< Function > functions_t
Definition Abstract/Binary.hpp:83
@ MACHO
Definition Abstract/Binary.hpp:79
FORMATS format() const
Executable format (ELF, PE, Mach-O) of the underlying binary.
Definition Abstract/Binary.hpp:125
std::vector< Symbol * > symbols_t
Internal container.
Definition Abstract/Binary.hpp:95
VA_TYPES
Enumeration of virtual address types used for patching and memory access.
Definition Abstract/Binary.hpp:63
@ AUTO
Automatically determine if the address is absolute or relative (default behavior).
Definition Abstract/Binary.hpp:66
std::vector< Section * > sections_t
Internal container.
Definition Abstract/Binary.hpp:86
virtual uint64_t page_size() const
Get the default memory page size according to the architecture and the format of the current binary.
std::vector< Relocation * > relocations_t
Internal container.
Definition Abstract/Binary.hpp:104
Definition Abstract/Header.hpp:40
static Header from(const LIEF::ELF::Binary &elf)
Class which represents the LC_ATOM_INFO command.
Definition AtomInfo.hpp:37
Class which represents a MachO binary.
Definition MachO/Binary.hpp:94
Symbol * add_local_symbol(uint64_t address, const std::string &name)
Add a symbol in LC_SYMTAB command of the current binary.
UUIDCommand * uuid()
Return the MachO::UUIDCommand if present, a nullptr otherwise.
bool has_build_version() const
true if the binary has the BuildVersion command.
Definition MachO/Binary.hpp:901
std::vector< uint8_t > raw()
Reconstruct the binary object and return its content as bytes.
size_t count_commands() const
static bool classof(const LIEF::Binary *bin)
Definition MachO/Binary.hpp:1124
const_filter_iterator< const commands_t &, const RPathCommand * > it_const_rpaths
Iterator which outputs const RPathCommand&.
Definition MachO/Binary.hpp:215
bool is_pie() const override
Check if the binary is position independent.
Definition MachO/Binary.hpp:685
uint64_t fileset_addr() const
Original address associated with the LC_FILESET_ENTRY for this MachO.
Definition MachO/Binary.hpp:1086
bool has_function_starts() const
true if the binary has a MachO::FunctionStarts command.
Definition MachO/Binary.hpp:748
uint64_t entrypoint() const override
The binary entrypoint.
bool has_segment_split_info() const
true if the binary has segment split info.
Definition MachO/Binary.hpp:859
it_imported_symbols imported_symbols()
Return binary's imported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:309
Section * section_from_offset(uint64_t offset)
Return the MachO::Section that encompasses the provided offset. If a section can't be found,...
Definition MachO/Binary.hpp:567
const Section * section_from_offset(uint64_t offset) const
bool has_source_version() const
true if the binary has a MachO::SourceVersion command.
Definition MachO/Binary.hpp:757
const SegmentCommand * get_segment(const std::string &name) const
Return the segment from the given name.
bool has_function_variant_fixups() const
true if the binary has the command LC_FUNCTION_VARIANT_FIXUPS.
Definition MachO/Binary.hpp:1030
it_commands commands()
Return an iterator over the MachO LoadCommand present in the binary.
Definition MachO/Binary.hpp:252
filter_iterator< commands_t &, NoteCommand * > it_notes
Iterator which outputs NoteCommand&.
Definition MachO/Binary.hpp:231
range_t off_ranges() const
Return the range of offsets.
result< uint64_t > offset_to_virtual_address(uint64_t offset, uint64_t slide=0) const override
Convert the given offset into a virtual address.
const SegmentCommand * segment_from_virtual_address(uint64_t virtual_address) const
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Iterator which outputs const Relocation&.
Definition MachO/Binary.hpp:208
range_t tlv_initial_content_range() const
Return the TLV initial content range.
result< uint64_t > virtual_address_to_offset(uint64_t virtual_address) const
Convert a virtual address to an offset in the file.
bool has_atom_info() const
true if the binary has the command LC_ATOM_INFO.
Definition MachO/Binary.hpp:995
bool has_dynamic_symbol_command() const
true if the binary has a MachO::DynamicSymbolCommand command.
Definition MachO/Binary.hpp:815
friend class BindingInfoIterator
Definition MachO/Binary.hpp:100
const_ref_iterator< const commands_t &, LoadCommand * > it_const_commands
Iterator that outputs const LoadCommand&.
Definition MachO/Binary.hpp:123
TwoLevelHints * two_level_hints()
Return the MachO::TwoLevelHints if present, a nullptr otherwise.
Definition MachO/Binary.hpp:954
bool is_valid_addr(uint64_t address) const
Check if the given address is encompassed in the binary's virtual addresses range.
Definition MachO/Binary.hpp:643
it_const_lazy_load_dylib_info lazy_load_dylib_infos() const
Definition MachO/Binary.hpp:336
filter_iterator< commands_t &, RPathCommand * > it_rpaths
Iterator which outputs RPathCommand&.
Definition MachO/Binary.hpp:212
void write(const std::string &filename)
Reconstruct the binary object and write the result in the given filename.
LoadCommand * add(const DylibCommand &library)
Insert the given DylibCommand.
it_lazy_load_dylib_info lazy_load_dylib_infos()
Return an iterator over the binary's LazyLoadDylibInfo commands (LC_LAZY_LOAD_DYLIB_INFO).
Definition MachO/Binary.hpp:332
DylinkerCommand * dylinker()
Return the MachO::DylinkerCommand if present, a nullptr otherwise.
bool has_dylinker() const
true if the binary has a MachO::DylinkerCommand.
Definition MachO/Binary.hpp:730
Section * get_section(const std::string &segname, const std::string &secname)
Return the section from the segment with the name given in the first parameter and with the section's...
Definition MachO/Binary.hpp:521
bool has_dyld_chained_fixups() const
true if the binary has the command LC_DYLD_CHAINED_FIXUPS.
Definition MachO/Binary.hpp:931
std::string_view fileset_name() const
Name associated with the LC_FILESET_ENTRY for this MachO. For instance: com.apple....
Definition MachO/Binary.hpp:1081
it_sub_clients subclients()
Iterator over all the MachO::SubClient commands.
bool has_dyld_info() const
true if the binary has a MachO::DyldInfo command.
Definition MachO/Binary.hpp:739
EncryptionInfo * encryption_info()
Return the MachO::EncryptionInfo if present, a nullptr otherwise.
DataInCode * data_in_code()
Return the MachO::DataInCode if present, a nullptr otherwise.
bool extend_section(Section &section, size_t size)
Extend the content of the given Section.
const TwoLevelHints * two_level_hints() const
std::vector< DylibCommand * > libraries_cache_t
Internal container for storing Mach-O DylibCommand.
Definition MachO/Binary.hpp:167
bool has_symbol(const std::string &name) const
Check if a symbol with the given name exists.
Definition MachO/Binary.hpp:279
BuildVersion * build_version()
Return the MachO::BuildVersion if present, a nullptr otherwise.
bool has_symbol_command() const
true if the binary has a MachO::SymbolCommand command.
Definition MachO/Binary.hpp:806
const LoadCommand * operator[](LoadCommand::TYPE type) const
Definition MachO/Binary.hpp:1061
size_t segment_index(const SegmentCommand &segment) const
Return the index of the given SegmentCommand.
bool has_rpath() const
true if the binary has a MachO::RPathCommand command.
Definition MachO/Binary.hpp:793
it_const_fileset_binaries filesets() const
Definition MachO/Binary.hpp:266
ok_error_t shift_linkedit(size_t width)
Shift the position on the __LINKEDIT data by width.
std::vector< SegmentCommand * > segments_cache_t
Internal container for storing Mach-O SegmentCommand.
Definition MachO/Binary.hpp:158
it_relocations relocations()
Return an iterator over the MachO::Relocation.
Definition MachO/Binary.hpp:357
bool extend(const LoadCommand &command, uint64_t size)
Extend the size of the given LoadCommand.
VersionMin * version_min()
Return the MachO::VersionMin command if present, a nullptr otherwise.
bool remove_signature()
Remove the LC_SIGNATURE command.
bool has_nx() const override
Check if the binary uses NX protection.
Definition MachO/Binary.hpp:690
bool can_remove(const Symbol &sym) const
Check if the given symbol can be safely removed.
it_bindings bindings() const
Return an iterator over the binding info which can come from either DyldInfo or DyldChainedFixups com...
bool has_routine_command() const
true if the binary has a MachO::Routine command.
Definition MachO/Binary.hpp:784
const FunctionVariantFixups * function_variant_fixups() const
void remove_section(const std::string &segname, const std::string &secname, bool clear=false)
Remove the section from the segment with the name given in the first parameter and with the section's...
filter_iterator< symbols_t &, Symbol * > it_imported_symbols
Iterator that outputs imported Symbol&.
Definition MachO/Binary.hpp:142
uint64_t imagebase() const override
Return the binary's imagebase. 0 if not relevant.
std::ostream & print(std::ostream &os) const override
FunctionVariants * function_variants()
Return the FunctionVariants if present, a nullptr otherwise.
Definition MachO/Binary.hpp:1021
const DylibCommand * find_library(const std::string &name) const
Try to find the library with the given library name.
bool is_macos() const
True if this binary targets macOS.
Definition MachO/Binary.hpp:924
bool disable_pie()
Remove the PIE flag.
bool can_remove_symbol(const std::string &name) const
Check if the MachO::Symbol with the given name can be safely removed.
ThreadCommand * thread_command()
Return the MachO::ThreadCommand command if present, a nullptr otherwise.
Section * section_from_virtual_address(uint64_t virtual_address)
Return the MachO::Section that encompasses the provided virtual address. If a section can't be found,...
Definition MachO/Binary.hpp:577
static bool can_cache_segment(const SegmentCommand &segment)
Check if the given segment can go in the offset_seg_ cache.
friend class BinaryParser
Definition MachO/Binary.hpp:97
bool has_segment(const std::string &name) const
Check if a segment with the given name exists.
Definition MachO/Binary.hpp:532
result< uint64_t > get_function_address(const std::string &name) const override
Try to get the address for the function's name given in parameter.
bool has_uuid() const
true if the binary has a MachO::UUIDCommand command.
Definition MachO/Binary.hpp:712
const Section * section_from_virtual_address(uint64_t virtual_address) const
bool remove_symbol(const std::string &name)
Remove the symbol with the given name.
DyldExportsTrie * dyld_exports_trie()
Return the MachO::DyldExportsTrie if present, a nullptr otherwise.
it_notes notes()
Iterator over the different LC_NOTE commands.
it_const_sections sections() const
Definition MachO/Binary.hpp:352
it_const_symbols symbols() const
Definition MachO/Binary.hpp:274
std::vector< std::unique_ptr< LoadCommand > > commands_t
Internal container for storing Mach-O LoadCommand.
Definition MachO/Binary.hpp:117
void accept(LIEF::Visitor &visitor) const override
Method so that the visitor can visit us.
bool has_dyld_exports_trie() const
true if the binary has the command LC_DYLD_EXPORTS_TRIE.
Definition MachO/Binary.hpp:940
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation&.
Definition MachO/Binary.hpp:205
bool remove(LoadCommand::TYPE type)
Remove all LoadCommand with the given type (MachO::LoadCommand::TYPE).
it_symbols symbols()
Return binary's symbols .
Definition MachO/Binary.hpp:271
std::vector< LazyLoadDylibInfo * > lazy_load_dylib_info_cache_t
Internal container for storing Mach-O LazyLoadDylibInfo.
Definition MachO/Binary.hpp:176
LoadCommand * operator[](LoadCommand::TYPE type)
Definition MachO/Binary.hpp:1058
bool has_subclients() const
bool has_linker_opt_hint() const
true if the binary has the command LC_LINKER_OPTIMIZATION_HINT.
Definition MachO/Binary.hpp:962
const_ref_iterator< const sections_cache_t & > it_const_sections
Iterator that outputs const Section&.
Definition MachO/Binary.hpp:155
ok_error_t shift(size_t value)
Shift the content located right after the Load commands table. This operation can be used to add a ne...
iterator_range< BindingInfoIterator > it_bindings
Definition MachO/Binary.hpp:225
std::vector< std::unique_ptr< Binary > > fileset_binaries_t
Internal container for storing Mach-O Fileset Binary.
Definition MachO/Binary.hpp:186
LIEF::Binary::functions_t ctor_functions() const override
Return the list of the MachO's constructors.
std::unique_ptr< objc::Metadata > objc_metadata() const
Return Objective-C metadata if present.
it_segments segments()
Return an iterator over the SegmentCommand.
Definition MachO/Binary.hpp:341
Binary(const Binary &)=delete
Section * get_section(const std::string &name)
Return the section from the given name or a nullptr if the section can't be found.
Definition MachO/Binary.hpp:508
it_fileset_binaries filesets()
Return an iterator over the MachO::Binary associated with the LoadCommand::TYPE::FILESET_ENTRY comman...
Definition MachO/Binary.hpp:262
Binary & operator=(const Binary &)=delete
filter_iterator< commands_t &, SubClient * > it_sub_clients
Iterator which outputs SubClient&.
Definition MachO/Binary.hpp:219
const FunctionVariants * function_variants() const
it_const_segments segments() const
Definition MachO/Binary.hpp:344
const_filter_iterator< const commands_t &, const NoteCommand * > it_const_notes
Iterator which outputs const NoteCommand&.
Definition MachO/Binary.hpp:234
bool has_nx_stack() const
Return True if the stack is flagged as non-executable. False otherwise.
Definition MachO/Binary.hpp:695
it_libraries libraries()
Return binary imported libraries (MachO::DylibCommand).
Definition MachO/Binary.hpp:322
bool has_data_in_code() const
true if the binary has a MachO::DataInCode command.
Definition MachO/Binary.hpp:850
const Section * get_section(const std::string &name) const
Return the section from the given name or a nullptr if the section can't be found.
static bool is_exported(const Symbol &symbol)
Check if the given symbol is exported.
Section * add_section(const Section &section)
Add a new MachO::Section in the __TEXT segment.
const SegmentCommand * segment_from_offset(uint64_t offset) const
it_exported_symbols exported_symbols()
Return binary's exported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:294
filter_iterator< symbols_t &, Symbol * > it_exported_symbols
Iterator that outputs exported Symbol&.
Definition MachO/Binary.hpp:135
BuildVersion::PLATFORMS platform() const
Return the platform for which this Mach-O has been compiled for.
Definition MachO/Binary.hpp:910
it_const_relocations relocations() const
span< const uint8_t > overlay() const
Definition MachO/Binary.hpp:1128
SegmentCommand * segment_from_virtual_address(uint64_t virtual_address)
Return the binary's SegmentCommand which encompasses the given virtual address or a nullptr if not fo...
Definition MachO/Binary.hpp:621
friend class Builder
Definition MachO/Binary.hpp:98
DyldChainedFixups * dyld_chained_fixups()
Return the MachO::DyldChainedFixups if present, a nullptr otherwise.
const CodeSignature * code_signature() const
const_ref_iterator< const symbols_t &, const Symbol * > it_const_symbols
Iterator that outputs const Symbol&.
Definition MachO/Binary.hpp:132
RPathCommand * rpath()
Return the MachO::RPathCommand command if present, a nullptr otherwise.
SegmentCommand * get_segment(const std::string &name)
Return the segment from the given name.
Definition MachO/Binary.hpp:541
span< const uint8_t > get_content_from_virtual_address(uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type=Binary::VA_TYPES::AUTO) const override
Return the content located at virtual address.
const CodeSignatureDir * code_signature_dir() const
bool extend_segment(const SegmentCommand &segment, size_t size)
Extend the content of the given SegmentCommand.
ref_iterator< libraries_cache_t & > it_libraries
Iterator that outputs DylibCommand&.
Definition MachO/Binary.hpp:170
const T * command() const
const_filter_iterator< const commands_t &, const SubClient * > it_const_sub_clients
Iterator which outputs const SubClient&.
Definition MachO/Binary.hpp:222
SymbolCommand * symbol_command()
Return the MachO::SymbolCommand if present, a nullptr otherwise.
LinkerOptHint * linker_opt_hint()
Return the MachO::LinkerOptHint if present, a nullptr otherwise.
Definition MachO/Binary.hpp:967
uint64_t fat_offset() const
Return binary's fat offset. 0 if not relevant.
Definition MachO/Binary.hpp:614
const Header & header() const
Definition MachO/Binary.hpp:246
ref_iterator< lazy_load_dylib_info_cache_t & > it_lazy_load_dylib_info
Iterator that outputs LazyLoadDylibInfo&.
Definition MachO/Binary.hpp:179
it_rpaths rpaths()
Iterator over all the MachO::RPathCommand commands.
bool has_nx_heap() const
Return True if the heap is flagged as non-executable. False otherwise.
Definition MachO/Binary.hpp:700
const AtomInfo * atom_info() const
LoadCommand * add(const LoadCommand &command)
Insert a new LoadCommand.
Definition MachO/Binary.hpp:405
bool remove(const Symbol &sym)
Remove the given symbol.
bool has_version_min() const
true if the binary has a MachO::VersionMin command.
Definition MachO/Binary.hpp:766
DyldEnvironment * dyld_environment()
Return the MachO::DyldEnvironment if present, a nullptr otherwise.
bool has_command() const
bool has_notes() const
True if the binary contains LC_NOTE command(s).
Definition MachO/Binary.hpp:1011
bool remove(const LoadCommand &command)
Remove the given LoadCommand.
SourceVersion * source_version()
Return the MachO::SourceVersion command if present, a nullptr otherwise.
std::string_view loader() const
Return the binary's loader (e.g. /usr/lib/dyld) or an empty string if the binary does not use a loade...
static bool is_imported(const Symbol &symbol)
Check if the given symbol is an imported one.
LoadCommand * add(const LoadCommand &command, size_t index)
Insert a new LoadCommand at the specified index.
std::vector< std::unique_ptr< Symbol > > symbols_t
Internal container for storing Mach-O Symbol.
Definition MachO/Binary.hpp:126
void patch_address(uint64_t address, uint64_t patch_value, size_t size=sizeof(uint64_t), LIEF::Binary::VA_TYPES addr_type=LIEF::Binary::VA_TYPES::AUTO) override
Patch the address with the given value.
CodeSignature * code_signature()
Return the MachO::CodeSignature if present, a nullptr otherwise.
Definition MachO/Binary.hpp:829
LoadCommand * add_library(const std::string &name)
Insert a new shared library through a LC_LOAD_DYLIB command.
Section * add_section(const SegmentCommand &segment, const Section &section)
Add a section in the given MachO::SegmentCommand.
void remove_section(const std::string &name, bool clear=false) override
Remove the section with the name provided in the first parameter.
const Symbol * get_symbol(const std::string &name) const
Return Symbol from the given name. If the symbol does not exist, it returns a null pointer.
bool remove_command(size_t index)
Remove the Load Command at the provided index.
ref_iterator< symbols_t &, Symbol * > it_symbols
Iterator that outputs Symbol&.
Definition MachO/Binary.hpp:129
uint64_t memory_base_address() const
If this Mach-O binary has been parsed from memory, it returns the in-memory base address of this bina...
Definition MachO/Binary.hpp:1106
bool has_sub_framework() const
true if the binary has a sub framework command.
Definition MachO/Binary.hpp:868
LIEF::Binary::functions_t functions() const
Return all the functions found in this MachO.
const LoadCommand * get(LoadCommand::TYPE type) const
Return the LoadCommand associated with the given LoadCommand::TYPE or a nullptr if the command can't ...
const LinkerOptHint * linker_opt_hint() const
ref_iterator< sections_cache_t & > it_sections
Iterator that outputs Section&.
Definition MachO/Binary.hpp:152
FunctionStarts * function_starts()
Return the MachO::FunctionStarts command if present, a nullptr otherwise.
friend class Parser
Definition MachO/Binary.hpp:96
SegmentSplitInfo * segment_split_info()
Return the MachO::SegmentSplitInfo if present, a nullptr otherwise.
ref_iterator< segments_cache_t & > it_segments
Iterator that outputs SegmentCommand&.
Definition MachO/Binary.hpp:161
stub_iterator symbol_stubs() const
Return an iterator over the symbol stubs.
LoadCommand * add(const SegmentCommand &segment)
Add a new LC_SEGMENT command from the given SegmentCommand.
bool is_ios() const
True if this binary targets iOS.
Definition MachO/Binary.hpp:918
bool has_entrypoint() const
true if the binary has an entrypoint.
Definition MachO/Binary.hpp:707
ref_iterator< fileset_binaries_t &, Binary * > it_fileset_binaries
Iterator that outputs Binary&.
Definition MachO/Binary.hpp:189
bool has_two_level_hints() const
true if the binary has the command LC_TWO_LEVEL_HINTS.
Definition MachO/Binary.hpp:949
DyldInfo * dyld_info()
Return the MachO::Dyld command if present, a nullptr otherwise.
void patch_address(uint64_t address, const std::vector< uint8_t > &patch_value, LIEF::Binary::VA_TYPES addr_type=LIEF::Binary::VA_TYPES::AUTO) override
Patch the content at virtual address address with patch_value.
MainCommand * main_command()
Return the MachO::MainCommand if present, a nullptr otherwise.
const_filter_iterator< const symbols_t &, const Symbol * > it_const_imported_symbols
Iterator that outputs imported const Symbol&.
Definition MachO/Binary.hpp:145
bool has_encryption_info() const
true if the binary has Encryption Info.
Definition MachO/Binary.hpp:873
bool has(LoadCommand::TYPE type) const
Check if the current binary has the given MachO::LoadCommand::TYPE.
DylibCommand * find_library(const std::string &name)
Definition MachO/Binary.hpp:431
range_t va_ranges() const
Return the range of virtual addresses.
DynamicSymbolCommand * dynamic_symbol_command()
Return the MachO::SymbolCommand if present, a nullptr otherwise.
bool has_code_signature_dir() const
true if the binary is signed with the command DYLIB_CODE_SIGN_DRS
Definition MachO/Binary.hpp:837
CodeSignatureDir * code_signature_dir()
Return the MachO::CodeSignatureDir if present, a nullptr otherwise.
Definition MachO/Binary.hpp:842
const_ref_iterator< const segments_cache_t & > it_const_segments
Iterator that outputs const SegmentCommand&.
Definition MachO/Binary.hpp:164
std::set< Relocation *, KeyCmp > relocations_t
Internal container that store all the relocations found in a Mach-O. The relocations are actually own...
Definition MachO/Binary.hpp:202
bool has_code_signature() const
true if the binary is signed with LC_CODE_SIGNATURE command
Definition MachO/Binary.hpp:824
AtomInfo * atom_info()
Return the MachO::AtomInfo if present, a nullptr otherwise.
Definition MachO/Binary.hpp:1000
ref_iterator< commands_t &, LoadCommand * > it_commands
Iterator that outputs LoadCommand&.
Definition MachO/Binary.hpp:120
std::vector< Section * > sections_cache_t
Internal container for caching Mach-O Section.
Definition MachO/Binary.hpp:149
const Section * get_section(const std::string &segname, const std::string &secname) const
bool has_section(const std::string &name) const
Check if a section with the given name exists.
Definition MachO/Binary.hpp:502
it_const_imported_symbols imported_symbols() const
Definition MachO/Binary.hpp:315
bool has_main_command() const
true if the binary has a MachO::MainCommand command.
Definition MachO/Binary.hpp:721
Header & header()
Return a reference to the MachO::Header.
Definition MachO/Binary.hpp:242
ExportInfo * add_exported_function(uint64_t address, const std::string &name)
Add a symbol in the export trie of the current binary.
bool support_arm64_ptr_auth() const
Check if the binary is supporting ARM64 pointer authentication (arm64e).
Definition MachO/Binary.hpp:1111
it_const_commands commands() const
Definition MachO/Binary.hpp:256
bool has_dyld_environment() const
true if the binary has Dyld environment variables.
Definition MachO/Binary.hpp:892
it_const_libraries libraries() const
Definition MachO/Binary.hpp:326
const_ref_iterator< const lazy_load_dylib_info_cache_t & > it_const_lazy_load_dylib_info
Iterator that outputs const LazyLoadDylibInfo&.
Definition MachO/Binary.hpp:182
bool has_function_variants() const
true if the binary has the command LC_FUNCTION_VARIANTS.
Definition MachO/Binary.hpp:1016
const_filter_iterator< const symbols_t &, const Symbol * > it_const_exported_symbols
Iterator that outputs exported const Symbol&.
Definition MachO/Binary.hpp:138
Binary & for_commands(Func f)
FunctionVariantFixups * function_variant_fixups()
Return the FunctionVariantFixups if present, a nullptr otherwise.
Definition MachO/Binary.hpp:1035
iterator_range< Stub::Iterator > stub_iterator
Iterator type for Symbol's stub.
Definition MachO/Binary.hpp:228
bool has_filesets() const
true if the binary has a LoadCommand::TYPE::FILESET_ENTRY command
Definition MachO/Binary.hpp:1075
Symbol * get_symbol(const std::string &name)
Definition MachO/Binary.hpp:286
SegmentCommand * segment_from_offset(uint64_t offset)
Return the binary's SegmentCommand that encompasses the provided offset.
Definition MachO/Binary.hpp:602
friend class DyldInfo
Definition MachO/Binary.hpp:99
const_ref_iterator< const fileset_binaries_t &, Binary * > it_const_fileset_binaries
Iterator that outputs const Binary&.
Definition MachO/Binary.hpp:192
LoadCommand * add(std::unique_ptr< LoadCommand > command)
bool unexport(const std::string &name)
Remove the given MachO::Symbol with the given name from the export table.
LIEF::Binary::functions_t unwind_functions() const
Return the functions found in the __unwind_info section.
it_const_exported_symbols exported_symbols() const
Definition MachO/Binary.hpp:299
bool has_thread_command() const
true if the binary has a MachO::ThreadCommand command.
Definition MachO/Binary.hpp:775
Symbol & add(const Symbol &symbol)
Add a symbol to this binary.
bool unexport(const Symbol &sym)
Remove the given symbol from the export table.
SubFramework * sub_framework()
Return the MachO::SubFramework if present, a nullptr otherwise.
uint64_t virtual_size() const override
Size of the binary in memory when mapped by the loader (dyld).
Definition MachO/Binary.hpp:493
Routine * routine_command()
Return the MachO::Routine command if present, a nullptr otherwise.
const_ref_iterator< const libraries_cache_t & > it_const_libraries
Iterator that outputs const DylibCommand&.
Definition MachO/Binary.hpp:173
it_sections sections()
Return an iterator over the MachO::Section.
Definition MachO/Binary.hpp:349
Definition BuildVersion.hpp:35
@ MACOS
Definition BuildVersion.hpp:47
@ UNKNOWN
Definition BuildVersion.hpp:46
@ IOS
Definition BuildVersion.hpp:48
Definition CodeSignatureDir.hpp:38
Definition CodeSignature.hpp:39
Interface of the LC_DATA_IN_CODE command This command is used to list slices of code sections that co...
Definition DataInCode.hpp:44
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:50
Class that represents a LC_DYLD_ENVIRONMENT command which is used by the Mach-O linker/loader to init...
Definition DyldEnvironment.hpp:36
Class that represents the LC_DYLD_EXPORTS_TRIE command.
Definition DyldExportsTrie.hpp:43
Class which represents a library dependency.
Definition DylibCommand.hpp:36
Class that represents the Mach-O linker, also named loader. Most of the time, DylinkerCommand::name()...
Definition DylinkerCommand.hpp:36
Class that represents the LC_DYSYMTAB command.
Definition DynamicSymbolCommand.hpp:41
Class that represents the LC_ENCRYPTION_INFO / LC_ENCRYPTION_INFO_64 commands.
Definition EncryptionInfo.hpp:36
Class that provides an interface over the Dyld export info.
Definition ExportInfo.hpp:38
Class which represents the LC_FUNCTION_STARTS command.
Definition FunctionStarts.hpp:41
Class which represents the LC_FUNCTION_VARIANT_FIXUPS command.
Definition FunctionVariantFixups.hpp:61
Class representing the LC_FUNCTION_VARIANTS load command.
Definition FunctionVariants.hpp:70
Class that represents the Mach-O header.
Definition MachO/Header.hpp:38
@ NO_HEAP_EXECUTION
Definition MachO/Header.hpp:95
@ ALLOW_STACK_EXECUTION
Definition MachO/Header.hpp:88
@ PIE
Definition MachO/Header.hpp:92
static constexpr auto CPU_SUBTYPE_ARM64_ARM64E
Definition MachO/Header.hpp:132
@ ARM64
Definition MachO/Header.hpp:115
Class which represents the LC_LINKER_OPTIMIZATION_HINT command.
Definition LinkerOptHint.hpp:39
Base class for the Mach-O load commands.
Definition LoadCommand.hpp:38
TYPE
Definition LoadCommand.hpp:47
@ NOTE
Definition LoadCommand.hpp:98
@ VERSION_MIN_MACOSX
Definition LoadCommand.hpp:85
@ VERSION_MIN_IPHONEOS
Definition LoadCommand.hpp:86
Class that represents the LC_MAIN command. This kind of command can be used to determine the entrypoi...
Definition MainCommand.hpp:34
Class that represents the LC_RPATH command.
Definition RPathCommand.hpp:38
Class that represents a Mach-O relocation.
Definition MachO/Relocation.hpp:40
Class that represents the LC_ROUTINE/LC_ROUTINE64 commands. According to the Mach-O loader....
Definition Routine.hpp:39
Class that represents a Mach-O section.
Definition MachO/Section.hpp:49
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:54
Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:37
Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION This command is used to provide the...
Definition SourceVersion.hpp:36
Class that represents the SubFramework command. According to the Mach-O loader.h documentation:
Definition SubFramework.hpp:49
Class that represents the LC_SYMTAB command.
Definition SymbolCommand.hpp:37
Class that represents a Symbol in a Mach-O file.
Definition MachO/Symbol.hpp:47
Class that represents the LC_THREAD / LC_UNIXTHREAD commands and that can be used to get the binary e...
Definition ThreadCommand.hpp:44
Class which represents the LC_TWOLEVEL_HINTS command.
Definition TwoLevelHints.hpp:41
Class that represents the UUID command.
Definition UUIDCommand.hpp:36
Class that wraps the LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, ... commands.
Definition VersionMin.hpp:35
Main interface to parse an executable regardless of its format.
Definition Abstract/Parser.hpp:31
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
Class which represents an abstracted section.
Definition Abstract/Section.hpp:31
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:30
Definition Visitor.hpp:212
Iterator which returns a ref on container's values given predicates.
Definition iterators.hpp:323
Definition iterators.hpp:591
This class is the main interface to inspect Objective-C metadata.
Definition ObjC/Metadata.hpp:39
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:119
Iterator which returns reference on container's values.
Definition iterators.hpp:47
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
Namespace related to ObjC metadata.
Definition MachO/Binary.hpp:46
LIEF namespace.
Definition Abstract/Binary.hpp:41
uint64_t align(uint64_t value, uint64_t align_on)
Definition utils.hpp:29
filter_iterator< CT, U, typename decay_t< CT >::const_iterator > const_filter_iterator
Iterator which returns a const ref on container's values given predicates.
Definition iterators.hpp:583
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:103
tcb::span< ElementType, Extent > span
Definition span.hpp:22
lief_version_t version()
Return the current version.
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:316
PLATFORMS
Definition platforms.hpp:35
Definition MachO/Binary.hpp:195
bool operator()(const Relocation *lhs, const Relocation *rhs) const
Definition MachO/Binary.hpp:103
uint64_t start
Definition MachO/Binary.hpp:104
uint64_t size() const
Definition MachO/Binary.hpp:107
uint64_t end
Definition MachO/Binary.hpp:105
bool empty() const
Definition MachO/Binary.hpp:111
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46