LIEF: Library to Instrument Executable Formats Version 1.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 <vector>
20#include <map>
21#include <set>
22#include <memory>
23#include <mutex>
24
26#include "LIEF/MachO/Header.hpp"
29#include "LIEF/MachO/Stub.hpp"
31
33#include "LIEF/visibility.h"
34#include "LIEF/utils.hpp"
35
37
38#include "LIEF/iterators.hpp"
39#include "LIEF/errors.hpp"
40
41namespace LIEF {
42
43namespace objc {
44class Metadata;
45}
46
48namespace MachO {
49
50class AtomInfo;
51class BinaryParser;
52class Builder;
53class CodeSignature;
54class CodeSignatureDir;
55class DataInCode;
56class DyldChainedFixups;
57class DyldEnvironment;
58class DyldExportsTrie;
59class DyldInfo;
60class DylibCommand;
61class DylinkerCommand;
62class DynamicSymbolCommand;
63class EncryptionInfo;
64class ExportInfo;
65class FunctionStarts;
66class FunctionVariants;
67class FunctionVariantFixups;
68class LazyLoadDylibInfo;
69class Header;
70class IndirectBindingInfo;
71class LinkerOptHint;
72class MainCommand;
73class Parser;
74class RPathCommand;
75class Relocation;
76class Routine;
77class Section;
78class SegmentCommand;
79class SegmentSplitInfo;
80class SourceVersion;
81class SubClient;
82class SubFramework;
83class Symbol;
84class SymbolCommand;
85class ThreadCommand;
86class TwoLevelHints;
87class UUIDCommand;
88class VersionMin;
89
92
93 friend class Parser;
94 friend class BinaryParser;
95 friend class Builder;
96 friend class DyldInfo;
97 friend class BindingInfoIterator;
98
99 public:
100 struct range_t {
101 uint64_t start = 0;
102 uint64_t end = 0;
103
104 uint64_t size() const {
105 return end - start;
106 }
107
108 bool empty() const {
109 return start == end;
110 }
111 };
112
114 using commands_t = std::vector<std::unique_ptr<LoadCommand>>;
115
118
121
123 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
124
127
130
133
137
140
144
146 using sections_cache_t = std::vector<Section*>;
147
150
153
155 using segments_cache_t = std::vector<SegmentCommand*>;
156
159
162
164 using libraries_cache_t = std::vector<DylibCommand*>;
165
168
171
173 using lazy_load_dylib_info_cache_t = std::vector<LazyLoadDylibInfo*>;
174
177
181
183 using fileset_binaries_t = std::vector<std::unique_ptr<Binary>>;
184
187
191
192 struct KeyCmp {
193 bool operator()(const Relocation* lhs, const Relocation* rhs) const;
194 };
195
199 using relocations_t = std::set<Relocation*, KeyCmp>;
200
203
207
210
214
217
221
223
226
229
233
234 public:
235 Binary(const Binary&) = delete;
236 Binary& operator=(const Binary&) = delete;
237
240 return header_;
241 }
242
244 return header_;
245 }
246
250 return commands_;
251 }
252
254 return commands_;
255 }
256
260 return filesets_;
261 }
262
264 return filesets_;
265 }
266
269 return symbols_;
270 }
272 return symbols_;
273 }
274
276 bool has_symbol(const std::string& name) const {
277 return get_symbol(name) != nullptr;
278 }
279
282 const Symbol* get_symbol(const std::string& name) const LIEF_LIFETIMEBOUND;
283 Symbol* get_symbol(const std::string& name) LIEF_LIFETIMEBOUND {
284 return const_cast<Symbol*>(static_cast<const Binary*>(this)->get_symbol(name));
285 }
286
288 static bool is_exported(const Symbol& symbol);
289
292 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
293 return is_exported(*symbol);
294 }};
295 }
297 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
298 return is_exported(*symbol);
299 }};
300 }
301
303 static bool is_imported(const Symbol& symbol);
304
307 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
308 return is_imported(*symbol);
309 }};
310 }
311
313 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
314 return is_imported(*symbol);
315 }};
316 }
317
320 return libraries_;
321 }
322
324 return libraries_;
325 }
326
330 return lazy_load_dylib_infos_;
331 }
332
334 return lazy_load_dylib_infos_;
335 }
336
339 return segments_;
340 }
342 return segments_;
343 }
344
347 return sections_;
348 }
350 return sections_;
351 }
352
355 return static_cast<const Binary*>(this)->relocations();
356 }
357
359
363 void write(const std::string& filename);
364
372 void write(const std::string& filename, Builder::config_t config);
373
377 void write(std::ostream& os);
378
384 void write(std::ostream& os, Builder::config_t config);
385
387 std::vector<uint8_t> raw();
388
390 bool has(LoadCommand::TYPE type) const;
391
396 return const_cast<LoadCommand*>(static_cast<const Binary*>(this)->get(type));
397 }
398
399 LoadCommand* add(std::unique_ptr<LoadCommand> command) LIEF_LIFETIMEBOUND;
400
403 return add(command.clone());
404 }
405
408
411
414
416 LoadCommand* add_library(const std::string& name) LIEF_LIFETIMEBOUND;
417
420
425 const DylibCommand*
426 find_library(const std::string& name) const LIEF_LIFETIMEBOUND;
427
428 DylibCommand* find_library(const std::string& name) LIEF_LIFETIMEBOUND {
429 return const_cast<DylibCommand*>(
430 static_cast<const Binary*>(this)->find_library(name)
431 );
432 }
433
439 const Section& section) LIEF_LIFETIMEBOUND;
440
445 void remove_section(const std::string& name, bool clear = false) override;
446
454 void remove_section(const std::string& segname, const std::string& secname,
455 bool clear = false);
456
459
462
464 bool remove_command(size_t index);
465
468
470 bool extend(const LoadCommand& command, uint64_t size);
471
473 bool extend_segment(const SegmentCommand& segment, size_t size);
474
481 bool extend_section(Section& section, size_t size);
482
485
487 uint64_t imagebase() const override;
488
490 uint64_t virtual_size() const override {
491 return align(va_ranges().size(), (uint64_t)page_size());
492 }
493
496 std::string loader() const;
497
499 bool has_section(const std::string& name) const {
500 return get_section(name) != nullptr;
501 }
502
505 Section* get_section(const std::string& name) LIEF_LIFETIMEBOUND {
506 return const_cast<Section*>(
507 static_cast<const Binary*>(this)->get_section(name)
508 );
509 }
510
513 const Section* get_section(const std::string& name) const LIEF_LIFETIMEBOUND;
514
518 Section* get_section(const std::string& segname,
519 const std::string& secname) LIEF_LIFETIMEBOUND {
520 return const_cast<Section*>(
521 static_cast<const Binary*>(this)->get_section(segname, secname)
522 );
523 }
524
525 const Section* get_section(const std::string& segname,
526 const std::string& secname) const LIEF_LIFETIMEBOUND;
527
529 bool has_segment(const std::string& name) const {
530 return get_segment(name) != nullptr;
531 }
532
534 const SegmentCommand*
535 get_segment(const std::string& name) const LIEF_LIFETIMEBOUND;
536
539 return const_cast<SegmentCommand*>(
540 static_cast<const Binary*>(this)->get_segment(name)
541 );
542 }
543
545 bool remove_symbol(const std::string& name);
546
548 bool remove(const Symbol& sym);
549
551 bool can_remove(const Symbol& sym) const;
552
554 bool can_remove_symbol(const std::string& name) const;
555
557 bool unexport(const std::string& name);
558
560 bool unexport(const Symbol& sym);
561
565 return const_cast<Section*>(
566 static_cast<const Binary*>(this)->section_from_offset(offset)
567 );
568 }
569 const Section* section_from_offset(uint64_t offset) const LIEF_LIFETIMEBOUND;
570
573 Section*
575 return const_cast<Section*>(
576 static_cast<const Binary*>(this)->section_from_virtual_address(
577 virtual_address
578 )
579 );
580 }
582 uint64_t virtual_address
583 ) const LIEF_LIFETIMEBOUND;
584
586 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
587
594 uint64_t slide = 0) const override;
595
600 return const_cast<SegmentCommand*>(
601 static_cast<const Binary*>(this)->segment_from_offset(offset)
602 );
603 }
604 const SegmentCommand*
606
608 size_t segment_index(const SegmentCommand& segment) const;
609
611 uint64_t fat_offset() const {
612 return fat_offset_;
613 }
614
619 return const_cast<SegmentCommand*>(
620 static_cast<const Binary*>(this)->segment_from_virtual_address(
621 virtual_address
622 )
623 );
624 }
626 uint64_t virtual_address
627 ) const LIEF_LIFETIMEBOUND;
628
631
634
637
640 bool is_valid_addr(uint64_t address) const {
641 const range_t& r = va_ranges();
642 return r.start <= address && address < r.end;
643 }
644
646 void accept(LIEF::Visitor& visitor) const override;
647
648 std::ostream& print(std::ostream& os) const override;
649
656 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
657 LIEF::Binary::VA_TYPES addr_type =
659
668 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
670 ) override;
671
674 uint64_t virtual_address, uint64_t size,
676 ) const LIEF_LIFETIMEBOUND override;
677
679 uint64_t entrypoint() const override;
680
682 bool is_pie() const override {
683 return header().has(Header::FLAGS::PIE);
684 }
685
687 bool has_nx() const override {
688 return has_nx_stack();
689 }
690
692 bool has_nx_stack() const {
694 }
695
697 bool has_nx_heap() const {
699 }
700
704 bool has_entrypoint() const {
706 }
707
709 bool has_uuid() const {
710 return uuid() != nullptr;
711 }
712
716
718 bool has_main_command() const {
719 return main_command() != nullptr;
720 }
721
725
727 bool has_dylinker() const {
728 return dylinker() != nullptr;
729 }
730
734
736 bool has_dyld_info() const {
737 return dyld_info() != nullptr;
738 }
739
743
745 bool has_function_starts() const {
746 return function_starts() != nullptr;
747 }
748
752
754 bool has_source_version() const {
755 return source_version() != nullptr;
756 }
757
761
763 bool has_version_min() const {
764 return version_min() != nullptr;
765 }
766
770
772 bool has_thread_command() const {
773 return thread_command() != nullptr;
774 }
775
779
781 bool has_routine_command() const {
782 return routine_command() != nullptr;
783 }
784
788
790 bool has_rpath() const {
791 return rpath() != nullptr;
792 }
793
797
801
803 bool has_symbol_command() const {
804 return symbol_command() != nullptr;
805 }
806
810
813 return dynamic_symbol_command() != nullptr;
814 }
815
819
821 bool has_code_signature() const {
822 return code_signature() != nullptr;
823 }
824
827 return const_cast<CodeSignature*>(
828 static_cast<const Binary*>(this)->code_signature()
829 );
830 }
832
835 return code_signature_dir() != nullptr;
836 }
837
840 return const_cast<CodeSignatureDir*>(
841 static_cast<const Binary*>(this)->code_signature_dir()
842 );
843 }
845
847 bool has_data_in_code() const {
848 return data_in_code() != nullptr;
849 }
850
854
857 return segment_split_info() != nullptr;
858 }
859
863
865 bool has_sub_framework() const {
866 return sub_framework() != nullptr;
867 }
868
870 bool has_encryption_info() const {
871 return encryption_info() != nullptr;
872 }
873
877
881
885
886 bool has_subclients() const;
887
889 bool has_dyld_environment() const {
890 return dyld_environment() != nullptr;
891 }
892
896
898 bool has_build_version() const {
899 return build_version() != nullptr;
900 }
901
905
908 if (const BuildVersion* version = build_version()) {
909 return version->platform();
910 }
912 }
913
919
925
926
929 return dyld_chained_fixups() != nullptr;
930 }
931
935
938 return dyld_exports_trie() != nullptr;
939 }
940
944
946 bool has_two_level_hints() const {
947 return two_level_hints() != nullptr;
948 }
949
952 return const_cast<TwoLevelHints*>(
953 static_cast<const Binary*>(this)->two_level_hints()
954 );
955 }
957
959 bool has_linker_opt_hint() const {
960 return linker_opt_hint() != nullptr;
961 }
962
965 return const_cast<LinkerOptHint*>(
966 static_cast<const Binary*>(this)->linker_opt_hint()
967 );
968 }
970
973 const std::string& name) LIEF_LIFETIMEBOUND;
974
976 Symbol* add_local_symbol(uint64_t address,
977 const std::string& name) LIEF_LIFETIMEBOUND;
978
980 std::unique_ptr<objc::Metadata> objc_metadata() const;
981
990
992 bool has_atom_info() const {
993 return atom_info() != nullptr;
994 }
995
998 return const_cast<AtomInfo*>(static_cast<const Binary*>(this)->atom_info());
999 }
1001
1004
1006
1008 bool has_notes() const {
1009 return get(LoadCommand::TYPE::NOTE) != nullptr;
1010 }
1011
1014 return function_variants() != nullptr;
1015 }
1016
1019 return const_cast<FunctionVariants*>(
1020 static_cast<const Binary*>(this)->function_variants()
1021 );
1022 }
1023
1025
1028 return function_variant_fixups() != nullptr;
1029 }
1030
1033 return const_cast<FunctionVariantFixups*>(
1034 static_cast<const Binary*>(this)->function_variant_fixups()
1035 );
1036 }
1037
1039
1040 template<class T>
1042
1043 template<class T>
1045
1046 template<class T>
1047 LIEF_LOCAL const T* command() const;
1048
1049 template<class T>
1051
1052 template<class CMD, class Func>
1054
1056 return get(type);
1057 }
1059 return get(type);
1060 }
1061
1064
1067
1070
1072 bool has_filesets() const {
1073 return !filesets_.empty();
1074 }
1075
1078 const std::string& fileset_name() const {
1079 return fileset_info_.name;
1080 }
1081
1083 uint64_t fileset_addr() const {
1084 return fileset_info_.address;
1085 }
1086
1089
1090 ~Binary() override;
1091
1094 ok_error_t shift(size_t value);
1095
1098
1103 uint64_t memory_base_address() const {
1104 return in_memory_base_addr_;
1105 }
1106
1109 return header().cpu_type() == Header::CPU_TYPE::ARM64 &&
1110 (header().cpu_subtype() & ~Header::SUBTYPE_MASK) ==
1112 }
1113
1117
1119 result<uint64_t> get_function_address(const std::string& name) const override;
1120
1121 static bool classof(const LIEF::Binary* bin) {
1122 return bin->format() == Binary::FORMATS::MACHO;
1123 }
1124
1126 return overlay_;
1127 }
1128
1131
1133 static LIEF_LOCAL bool can_cache_segment(const SegmentCommand& segment);
1134
1136 LIEF_LOCAL size_t available_command_space() const {
1137 return available_command_space_;
1138 }
1139
1140 private:
1143
1144 LIEF_LOCAL void shift_command(size_t width, uint64_t from_offset);
1145
1148 LIEF_LOCAL size_t add_cached_segment(SegmentCommand& segment);
1149
1150 template<class T>
1151 LIEF_LOCAL ok_error_t patch_relocation(Relocation& relocation, uint64_t from,
1152 uint64_t shift);
1153
1154 LIEF::Header get_abstract_header() const override {
1155 return LIEF::Header::from(*this);
1156 }
1157
1158 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1159 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1160 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1162 get_abstract_exported_functions() const override;
1164 get_abstract_imported_functions() const override;
1165 LIEF_LOCAL std::vector<std::string>
1166 get_abstract_imported_libraries() const override;
1167
1171 ok_error_t ensure_command_space(size_t size) {
1172 return available_command_space_ < size ? shift(size) : ok();
1173 }
1174
1175 relocations_t& relocations_list() {
1176 return this->relocations_;
1177 }
1178
1179 const relocations_t& relocations_list() const {
1180 return this->relocations_;
1181 }
1182
1183 size_t pointer_size() const {
1184 return this->is64_ ? sizeof(uint64_t) : sizeof(uint32_t);
1185 }
1186
1187 bool is64_ = true;
1188 Header header_;
1189 commands_t commands_;
1190 symbols_t symbols_;
1191
1192 // Same purpose as sections_cache_t
1193 libraries_cache_t libraries_;
1194
1195 // Cache of the LC_LAZY_LOAD_DYLIB_INFO commands
1196 lazy_load_dylib_info_cache_t lazy_load_dylib_infos_;
1197
1198 // The sections are owned by the SegmentCommand object.
1199 // This attribute is a cache to speed-up the iteration
1200 sections_cache_t sections_;
1201
1202 // Same purpose as sections_cache_t
1203 segments_cache_t segments_;
1204
1205 fileset_binaries_t filesets_;
1206
1207 // Cached relocations from segment / sections
1208 mutable relocations_t relocations_;
1209 size_t available_command_space_ = 0;
1210
1211 // This is used to improve performances of
1212 // offset_to_virtual_address
1213 std::map<uint64_t, SegmentCommand*> offset_seg_;
1214
1215 protected:
1216 struct fileset_info_t {
1217 std::string name;
1218 uint64_t address = 0;
1219 };
1220
1221 uint64_t fat_offset_ = 0;
1222 uint64_t in_memory_base_addr_ = 0;
1223 std::vector<uint8_t> overlay_;
1224 std::vector<std::unique_ptr<IndirectBindingInfo>> indirect_bindings_;
1225 fileset_info_t fileset_info_;
1226 mutable std::mutex mu_;
1227};
1228
1229} // namespace MachO
1230} // namespace LIEF
1231#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:36
Class which represents a MachO binary.
Definition MachO/Binary.hpp:91
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:898
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:1121
const_filter_iterator< const commands_t &, const RPathCommand * > it_const_rpaths
Iterator which outputs const RPathCommand&.
Definition MachO/Binary.hpp:212
bool is_pie() const override
Check if the binary is position independent.
Definition MachO/Binary.hpp:682
uint64_t fileset_addr() const
Original address associated with the LC_FILESET_ENTRY for this MachO.
Definition MachO/Binary.hpp:1083
bool has_function_starts() const
true if the binary has a MachO::FunctionStarts command.
Definition MachO/Binary.hpp:745
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:856
it_imported_symbols imported_symbols()
Return binary's imported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:306
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:564
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:754
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:1027
it_commands commands()
Return an iterator over the MachO LoadCommand present in the binary.
Definition MachO/Binary.hpp:249
filter_iterator< commands_t &, NoteCommand * > it_notes
Iterator which outputs NoteCommand&.
Definition MachO/Binary.hpp:228
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:205
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:992
bool has_dynamic_symbol_command() const
true if the binary has a MachO::DynamicSymbolCommand command.
Definition MachO/Binary.hpp:812
friend class BindingInfoIterator
Definition MachO/Binary.hpp:97
const_ref_iterator< const commands_t &, LoadCommand * > it_const_commands
Iterator that outputs const LoadCommand&.
Definition MachO/Binary.hpp:120
TwoLevelHints * two_level_hints()
Return the MachO::TwoLevelHints if present, a nullptr otherwise.
Definition MachO/Binary.hpp:951
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:640
it_const_lazy_load_dylib_info lazy_load_dylib_infos() const
Definition MachO/Binary.hpp:333
filter_iterator< commands_t &, RPathCommand * > it_rpaths
Iterator which outputs RPathCommand&.
Definition MachO/Binary.hpp:209
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:329
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:727
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:518
bool has_dyld_chained_fixups() const
true if the binary has the command LC_DYLD_CHAINED_FIXUPS.
Definition MachO/Binary.hpp:928
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:736
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:164
std::string loader() const
Return the binary's loader (e.g. /usr/lib/dyld) or an empty string if the binary does not use a loade...
bool has_symbol(const std::string &name) const
Check if a symbol with the given name exists.
Definition MachO/Binary.hpp:276
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:803
const LoadCommand * operator[](LoadCommand::TYPE type) const
Definition MachO/Binary.hpp:1058
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:790
it_const_fileset_binaries filesets() const
Definition MachO/Binary.hpp:263
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:155
it_relocations relocations()
Return an iterator over the MachO::Relocation.
Definition MachO/Binary.hpp:354
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:687
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:781
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:139
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:1018
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:921
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:574
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:94
bool has_segment(const std::string &name) const
Check if a segment with the given name exists.
Definition MachO/Binary.hpp:529
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:709
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:349
it_const_symbols symbols() const
Definition MachO/Binary.hpp:271
std::vector< std::unique_ptr< LoadCommand > > commands_t
Internal container for storing Mach-O LoadCommand.
Definition MachO/Binary.hpp:114
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:937
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation&.
Definition MachO/Binary.hpp:202
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:268
std::vector< LazyLoadDylibInfo * > lazy_load_dylib_info_cache_t
Internal container for storing Mach-O LazyLoadDylibInfo.
Definition MachO/Binary.hpp:173
LoadCommand * operator[](LoadCommand::TYPE type)
Definition MachO/Binary.hpp:1055
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:959
const_ref_iterator< const sections_cache_t & > it_const_sections
Iterator that outputs const Section&.
Definition MachO/Binary.hpp:152
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:222
std::vector< std::unique_ptr< Binary > > fileset_binaries_t
Internal container for storing Mach-O Fileset Binary.
Definition MachO/Binary.hpp:183
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:338
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:505
it_fileset_binaries filesets()
Return an iterator over the MachO::Binary associated with the LoadCommand::TYPE::FILESET_ENTRY comman...
Definition MachO/Binary.hpp:259
Binary & operator=(const Binary &)=delete
filter_iterator< commands_t &, SubClient * > it_sub_clients
Iterator which outputs SubClient&.
Definition MachO/Binary.hpp:216
const FunctionVariants * function_variants() const
it_const_segments segments() const
Definition MachO/Binary.hpp:341
const_filter_iterator< const commands_t &, const NoteCommand * > it_const_notes
Iterator which outputs const NoteCommand&.
Definition MachO/Binary.hpp:231
bool has_nx_stack() const
Return True if the stack is flagged as non-executable. False otherwise.
Definition MachO/Binary.hpp:692
it_libraries libraries()
Return binary imported libraries (MachO::DylibCommand).
Definition MachO/Binary.hpp:319
bool has_data_in_code() const
true if the binary has a MachO::DataInCode command.
Definition MachO/Binary.hpp:847
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:291
filter_iterator< symbols_t &, Symbol * > it_exported_symbols
Iterator that outputs exported Symbol&.
Definition MachO/Binary.hpp:132
BuildVersion::PLATFORMS platform() const
Return the platform for which this Mach-O has been compiled for.
Definition MachO/Binary.hpp:907
it_const_relocations relocations() const
span< const uint8_t > overlay() const
Definition MachO/Binary.hpp:1125
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:618
friend class Builder
Definition MachO/Binary.hpp:95
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:129
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:538
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:167
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:219
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:964
uint64_t fat_offset() const
Return binary's fat offset. 0 if not relevant.
Definition MachO/Binary.hpp:611
const Header & header() const
Definition MachO/Binary.hpp:243
ref_iterator< lazy_load_dylib_info_cache_t & > it_lazy_load_dylib_info
Iterator that outputs LazyLoadDylibInfo&.
Definition MachO/Binary.hpp:176
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:697
const AtomInfo * atom_info() const
LoadCommand * add(const LoadCommand &command)
Insert a new LoadCommand.
Definition MachO/Binary.hpp:402
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:763
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:1008
bool remove(const LoadCommand &command)
Remove the given LoadCommand.
SourceVersion * source_version()
Return the MachO::SourceVersion command if present, a nullptr otherwise.
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:123
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:826
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:126
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:1103
bool has_sub_framework() const
true if the binary has a sub framework command.
Definition MachO/Binary.hpp:865
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:149
FunctionStarts * function_starts()
Return the MachO::FunctionStarts command if present, a nullptr otherwise.
friend class Parser
Definition MachO/Binary.hpp:93
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:158
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:915
bool has_entrypoint() const
true if the binary has an entrypoint.
Definition MachO/Binary.hpp:704
ref_iterator< fileset_binaries_t &, Binary * > it_fileset_binaries
Iterator that outputs Binary&.
Definition MachO/Binary.hpp:186
bool has_two_level_hints() const
true if the binary has the command LC_TWO_LEVEL_HINTS.
Definition MachO/Binary.hpp:946
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:142
bool has_encryption_info() const
true if the binary has Encryption Info.
Definition MachO/Binary.hpp:870
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:428
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:834
CodeSignatureDir * code_signature_dir()
Return the MachO::CodeSignatureDir if present, a nullptr otherwise.
Definition MachO/Binary.hpp:839
const_ref_iterator< const segments_cache_t & > it_const_segments
Iterator that outputs const SegmentCommand&.
Definition MachO/Binary.hpp:161
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:199
bool has_code_signature() const
true if the binary is signed with LC_CODE_SIGNATURE command
Definition MachO/Binary.hpp:821
AtomInfo * atom_info()
Return the MachO::AtomInfo if present, a nullptr otherwise.
Definition MachO/Binary.hpp:997
ref_iterator< commands_t &, LoadCommand * > it_commands
Iterator that outputs LoadCommand&.
Definition MachO/Binary.hpp:117
std::vector< Section * > sections_cache_t
Internal container for caching Mach-O Section.
Definition MachO/Binary.hpp:146
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:499
it_const_imported_symbols imported_symbols() const
Definition MachO/Binary.hpp:312
bool has_main_command() const
true if the binary has a MachO::MainCommand command.
Definition MachO/Binary.hpp:718
Header & header()
Return a reference to the MachO::Header.
Definition MachO/Binary.hpp:239
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:1108
it_const_commands commands() const
Definition MachO/Binary.hpp:253
bool has_dyld_environment() const
true if the binary has Dyld environment variables.
Definition MachO/Binary.hpp:889
it_const_libraries libraries() const
Definition MachO/Binary.hpp:323
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:179
bool has_function_variants() const
true if the binary has the command LC_FUNCTION_VARIANTS.
Definition MachO/Binary.hpp:1013
const_filter_iterator< const symbols_t &, const Symbol * > it_const_exported_symbols
Iterator that outputs exported const Symbol&.
Definition MachO/Binary.hpp:135
const std::string & fileset_name() const
Name associated with the LC_FILESET_ENTRY for this MachO. For instance: com.apple....
Definition MachO/Binary.hpp:1078
Binary & for_commands(Func f)
FunctionVariantFixups * function_variant_fixups()
Return the FunctionVariantFixups if present, a nullptr otherwise.
Definition MachO/Binary.hpp:1032
iterator_range< Stub::Iterator > stub_iterator
Iterator type for Symbol's stub.
Definition MachO/Binary.hpp:225
bool has_filesets() const
true if the binary has a LoadCommand::TYPE::FILESET_ENTRY command
Definition MachO/Binary.hpp:1072
Symbol * get_symbol(const std::string &name)
Definition MachO/Binary.hpp:283
SegmentCommand * segment_from_offset(uint64_t offset)
Return the binary's SegmentCommand that encompasses the provided offset.
Definition MachO/Binary.hpp:599
friend class DyldInfo
Definition MachO/Binary.hpp:96
const_ref_iterator< const fileset_binaries_t &, Binary * > it_const_fileset_binaries
Iterator that outputs const Binary&.
Definition MachO/Binary.hpp:189
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:296
bool has_thread_command() const
true if the binary has a MachO::ThreadCommand command.
Definition MachO/Binary.hpp:772
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:490
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:170
it_sections sections()
Return an iterator over the MachO::Section.
Definition MachO/Binary.hpp:346
Definition BuildVersion.hpp:34
@ MACOS
Definition BuildVersion.hpp:46
@ UNKNOWN
Definition BuildVersion.hpp:45
@ IOS
Definition BuildVersion.hpp:47
Definition CodeSignatureDir.hpp:37
Definition CodeSignature.hpp:38
Interface of the LC_DATA_IN_CODE command This command is used to list slices of code sections that co...
Definition DataInCode.hpp:43
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:34
Class that represents the LC_DYLD_EXPORTS_TRIE command.
Definition DyldExportsTrie.hpp:43
Class which represents a library dependency.
Definition DylibCommand.hpp:34
Class that represents the Mach-O linker, also named loader. Most of the time, DylinkerCommand::name()...
Definition DylinkerCommand.hpp:34
Class that represents the LC_DYSYMTAB command.
Definition DynamicSymbolCommand.hpp:40
Class that represents the LC_ENCRYPTION_INFO / LC_ENCRYPTION_INFO_64 commands.
Definition EncryptionInfo.hpp:35
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:40
Class which represents the LC_FUNCTION_VARIANT_FIXUPS command.
Definition FunctionVariantFixups.hpp:60
Class representing the LC_FUNCTION_VARIANTS load command.
Definition FunctionVariants.hpp:69
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:38
Base class for the Mach-O load commands.
Definition LoadCommand.hpp:38
TYPE
Definition LoadCommand.hpp:46
@ NOTE
Definition LoadCommand.hpp:97
@ VERSION_MIN_MACOSX
Definition LoadCommand.hpp:84
@ VERSION_MIN_IPHONEOS
Definition LoadCommand.hpp:85
Class that represents the LC_MAIN command. This kind of command can be used to determine the entrypoi...
Definition MainCommand.hpp:33
Class that represents the LC_RPATH command.
Definition RPathCommand.hpp:36
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:38
Class that represents a Mach-O section.
Definition MachO/Section.hpp:48
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:52
Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:36
Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION This command is used to provide the...
Definition SourceVersion.hpp:35
Class that represents the SubFramework command. According to the Mach-O loader.h documentation:
Definition SubFramework.hpp:46
Class that represents the LC_SYMTAB command.
Definition SymbolCommand.hpp:36
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:43
Class which represents the LC_TWOLEVEL_HINTS command.
Definition TwoLevelHints.hpp:40
Class that represents the UUID command.
Definition UUIDCommand.hpp:35
Class that wraps the LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, ... commands.
Definition VersionMin.hpp:34
Main interface to parse an executable regardless of its format.
Definition Abstract/Parser.hpp:30
Class which represents an abstracted Relocation.
Definition Abstract/Relocation.hpp:27
Class which represents an abstracted section.
Definition Abstract/Section.hpp:30
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:212
Iterator which returns a ref on container's values given predicates.
Definition iterators.hpp:327
Definition iterators.hpp:601
This class is the main interface to inspect Objective-C metadata.
Definition ObjC/Metadata.hpp:37
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:118
Iterator which returns reference on container's values.
Definition iterators.hpp:47
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:78
#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:43
LIEF namespace.
Definition Abstract/Binary.hpp:41
uint64_t align(uint64_t value, uint64_t align_on)
Definition utils.hpp:28
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:593
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:102
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:320
PLATFORMS
Definition platforms.hpp:26
Definition MachO/Binary.hpp:192
bool operator()(const Relocation *lhs, const Relocation *rhs) const
Definition MachO/Binary.hpp:100
uint64_t start
Definition MachO/Binary.hpp:101
uint64_t size() const
Definition MachO/Binary.hpp:104
uint64_t end
Definition MachO/Binary.hpp:102
bool empty() const
Definition MachO/Binary.hpp:108
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46