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
25#include "LIEF/MachO/Header.hpp"
28#include "LIEF/MachO/Stub.hpp"
30
31#include "LIEF/visibility.h"
32#include "LIEF/utils.hpp"
33
35
36#include "LIEF/iterators.hpp"
37#include "LIEF/errors.hpp"
38
39namespace LIEF {
40
41namespace objc {
42class Metadata;
43}
44
46namespace MachO {
47
48class AtomInfo;
49class BinaryParser;
50class Builder;
51class CodeSignature;
52class CodeSignatureDir;
53class DataInCode;
54class DyldChainedFixups;
55class DyldEnvironment;
56class DyldExportsTrie;
57class DyldInfo;
58class DylibCommand;
59class DylinkerCommand;
60class DynamicSymbolCommand;
61class EncryptionInfo;
62class ExportInfo;
63class FunctionStarts;
64class FunctionVariants;
65class FunctionVariantFixups;
66class Header;
67class IndirectBindingInfo;
68class LinkerOptHint;
69class MainCommand;
70class Parser;
71class RPathCommand;
72class Relocation;
73class Routine;
74class Section;
75class SegmentCommand;
76class SegmentSplitInfo;
77class SourceVersion;
78class SubClient;
79class SubFramework;
80class Symbol;
81class SymbolCommand;
82class ThreadCommand;
83class TwoLevelHints;
84class UUIDCommand;
85class VersionMin;
86
89
90 friend class Parser;
91 friend class BinaryParser;
92 friend class Builder;
93 friend class DyldInfo;
94 friend class BindingInfoIterator;
95
96 public:
97 struct range_t {
98 uint64_t start = 0;
99 uint64_t end = 0;
100
101 uint64_t size() const {
102 return end - start;
103 }
104
105 bool empty() const {
106 return start == end;
107 }
108 };
109
111 using commands_t = std::vector<std::unique_ptr<LoadCommand>>;
112
115
118
120 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
121
124
127
130
134
137
141
143 using sections_cache_t = std::vector<Section*>;
144
147
150
152 using segments_cache_t = std::vector<SegmentCommand*>;
153
156
159
161 using libraries_cache_t = std::vector<DylibCommand*>;
162
165
168
170 using fileset_binaries_t = std::vector<std::unique_ptr<Binary>>;
171
174
178
179 struct KeyCmp {
180 bool operator()(const Relocation* lhs, const Relocation* rhs) const;
181 };
182
186 using relocations_t = std::set<Relocation*, KeyCmp>;
187
190
194
197
201
204
208
210
213
216
220
221 public:
222 Binary(const Binary&) = delete;
223 Binary& operator=(const Binary&) = delete;
224
227 return header_;
228 }
229
230 const Header& header() const {
231 return header_;
232 }
233
237 return commands_;
238 }
239
241 return commands_;
242 }
243
247 return filesets_;
248 }
249
251 return filesets_;
252 }
253
256 return symbols_;
257 }
259 return symbols_;
260 }
261
263 bool has_symbol(const std::string& name) const {
264 return get_symbol(name) != nullptr;
265 }
266
269 const Symbol* get_symbol(const std::string& name) const;
270 Symbol* get_symbol(const std::string& name) {
271 return const_cast<Symbol*>(static_cast<const Binary*>(this)->get_symbol(name));
272 }
273
275 static bool is_exported(const Symbol& symbol);
276
279 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
280 return is_exported(*symbol);
281 }};
282 }
284 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
285 return is_exported(*symbol);
286 }};
287 }
288
290 static bool is_imported(const Symbol& symbol);
291
294 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
295 return is_imported(*symbol);
296 }};
297 }
298
300 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
301 return is_imported(*symbol);
302 }};
303 }
304
307 return libraries_;
308 }
309
311 return libraries_;
312 }
313
316 return segments_;
317 }
319 return segments_;
320 }
321
324 return sections_;
325 }
327 return sections_;
328 }
329
333
337 void write(const std::string& filename);
338
346 void write(const std::string& filename, Builder::config_t config);
347
351 void write(std::ostream& os);
352
358 void write(std::ostream& os, Builder::config_t config);
359
361 std::vector<uint8_t> raw();
362
364 bool has(LoadCommand::TYPE type) const;
365
370 return const_cast<LoadCommand*>(static_cast<const Binary*>(this)->get(type));
371 }
372
373 LoadCommand* add(std::unique_ptr<LoadCommand> command);
374
377 return add(command.clone());
378 }
379
381 LoadCommand* add(const LoadCommand& command, size_t index);
382
384 LoadCommand* add(const DylibCommand& library);
385
388
390 LoadCommand* add_library(const std::string& name);
391
393 Section* add_section(const Section& section);
394
399 const DylibCommand* find_library(const std::string& name) const;
400
401 DylibCommand* find_library(const std::string& name) {
402 return const_cast<DylibCommand*>(
403 static_cast<const Binary*>(this)->find_library(name)
404 );
405 }
406
411 Section* add_section(const SegmentCommand& segment, const Section& section);
412
417 void remove_section(const std::string& name, bool clear = false) override;
418
426 void remove_section(const std::string& segname, const std::string& secname,
427 bool clear = false);
428
431
434
436 bool remove_command(size_t index);
437
440
442 bool extend(const LoadCommand& command, uint64_t size);
443
445 bool extend_segment(const SegmentCommand& segment, size_t size);
446
453 bool extend_section(Section& section, size_t size);
454
457
459 uint64_t imagebase() const override;
460
462 uint64_t virtual_size() const override {
463 return align(va_ranges().size(), (uint64_t)page_size());
464 }
465
468 std::string loader() const;
469
471 bool has_section(const std::string& name) const {
472 return get_section(name) != nullptr;
473 }
474
477 Section* get_section(const std::string& name) {
478 return const_cast<Section*>(
479 static_cast<const Binary*>(this)->get_section(name)
480 );
481 }
482
485 const Section* get_section(const std::string& name) const;
486
490 Section* get_section(const std::string& segname, const std::string& secname) {
491 return const_cast<Section*>(
492 static_cast<const Binary*>(this)->get_section(segname, secname)
493 );
494 }
495
496 const Section* get_section(const std::string& segname,
497 const std::string& secname) const;
498
500 bool has_segment(const std::string& name) const {
501 return get_segment(name) != nullptr;
502 }
503
505 const SegmentCommand* get_segment(const std::string& name) const;
506
508 SegmentCommand* get_segment(const std::string& name) {
509 return const_cast<SegmentCommand*>(
510 static_cast<const Binary*>(this)->get_segment(name)
511 );
512 }
513
515 bool remove_symbol(const std::string& name);
516
518 bool remove(const Symbol& sym);
519
521 bool can_remove(const Symbol& sym) const;
522
524 bool can_remove_symbol(const std::string& name) const;
525
527 bool unexport(const std::string& name);
528
530 bool unexport(const Symbol& sym);
531
534 Section* section_from_offset(uint64_t offset) {
535 return const_cast<Section*>(
536 static_cast<const Binary*>(this)->section_from_offset(offset)
537 );
538 }
539 const Section* section_from_offset(uint64_t offset) const;
540
543 Section* section_from_virtual_address(uint64_t virtual_address) {
544 return const_cast<Section*>(
545 static_cast<const Binary*>(this)->section_from_virtual_address(
546 virtual_address
547 )
548 );
549 }
550 const Section* section_from_virtual_address(uint64_t virtual_address) const;
551
553 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
554
561 uint64_t slide = 0) const override;
562
567 return const_cast<SegmentCommand*>(
568 static_cast<const Binary*>(this)->segment_from_offset(offset)
569 );
570 }
571 const SegmentCommand* segment_from_offset(uint64_t offset) const;
572
574 size_t segment_index(const SegmentCommand& segment) const;
575
577 uint64_t fat_offset() const {
578 return fat_offset_;
579 }
580
583 SegmentCommand* segment_from_virtual_address(uint64_t virtual_address) {
584 return const_cast<SegmentCommand*>(
585 static_cast<const Binary*>(this)->segment_from_virtual_address(
586 virtual_address
587 )
588 );
589 }
590 const SegmentCommand*
591 segment_from_virtual_address(uint64_t virtual_address) const;
592
595
598
601
604 bool is_valid_addr(uint64_t address) const {
605 const range_t& r = va_ranges();
606 return r.start <= address && address < r.end;
607 }
608
610 void accept(LIEF::Visitor& visitor) const override;
611
612 std::ostream& print(std::ostream& os) const override;
613
620 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
621 LIEF::Binary::VA_TYPES addr_type =
623
632 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
634 ) override;
635
638 uint64_t virtual_address, uint64_t size,
640 ) const override;
641
643 uint64_t entrypoint() const override;
644
646 bool is_pie() const override {
647 return header().has(Header::FLAGS::PIE);
648 }
649
651 bool has_nx() const override {
652 return has_nx_stack();
653 }
654
656 bool has_nx_stack() const {
658 }
659
661 bool has_nx_heap() const {
663 }
664
668 bool has_entrypoint() const {
670 }
671
673 bool has_uuid() const {
674 return uuid() != nullptr;
675 }
676
679 const UUIDCommand* uuid() const;
680
682 bool has_main_command() const {
683 return main_command() != nullptr;
684 }
685
688 const MainCommand* main_command() const;
689
691 bool has_dylinker() const {
692 return dylinker() != nullptr;
693 }
694
697 const DylinkerCommand* dylinker() const;
698
700 bool has_dyld_info() const {
701 return dyld_info() != nullptr;
702 }
703
706 const DyldInfo* dyld_info() const;
707
709 bool has_function_starts() const {
710 return function_starts() != nullptr;
711 }
712
716
718 bool has_source_version() const {
719 return source_version() != nullptr;
720 }
721
725
727 bool has_version_min() const {
728 return version_min() != nullptr;
729 }
730
733 const VersionMin* version_min() const;
734
736 bool has_thread_command() const {
737 return thread_command() != nullptr;
738 }
739
743
745 bool has_routine_command() const {
746 return routine_command() != nullptr;
747 }
748
751 const Routine* routine_command() const;
752
754 bool has_rpath() const {
755 return rpath() != nullptr;
756 }
757
760 const RPathCommand* rpath() const;
761
765
767 bool has_symbol_command() const {
768 return symbol_command() != nullptr;
769 }
770
774
777 return dynamic_symbol_command() != nullptr;
778 }
779
783
785 bool has_code_signature() const {
786 return code_signature() != nullptr;
787 }
788
791 return const_cast<CodeSignature*>(
792 static_cast<const Binary*>(this)->code_signature()
793 );
794 }
796
799 return code_signature_dir() != nullptr;
800 }
801
804 return const_cast<CodeSignatureDir*>(
805 static_cast<const Binary*>(this)->code_signature_dir()
806 );
807 }
809
811 bool has_data_in_code() const {
812 return data_in_code() != nullptr;
813 }
814
817 const DataInCode* data_in_code() const;
818
821 return segment_split_info() != nullptr;
822 }
823
827
829 bool has_sub_framework() const {
830 return sub_framework() != nullptr;
831 }
832
834 bool has_encryption_info() const {
835 return encryption_info() != nullptr;
836 }
837
841
845
849
850 bool has_subclients() const;
851
853 bool has_dyld_environment() const {
854 return dyld_environment() != nullptr;
855 }
856
860
862 bool has_build_version() const {
863 return build_version() != nullptr;
864 }
865
869
872 if (const BuildVersion* version = build_version()) {
873 return version->platform();
874 }
876 }
877
883
889
890
893 return dyld_chained_fixups() != nullptr;
894 }
895
899
902 return dyld_exports_trie() != nullptr;
903 }
904
908
910 bool has_two_level_hints() const {
911 return two_level_hints() != nullptr;
912 }
913
916 return const_cast<TwoLevelHints*>(
917 static_cast<const Binary*>(this)->two_level_hints()
918 );
919 }
921
923 bool has_linker_opt_hint() const {
924 return linker_opt_hint() != nullptr;
925 }
926
929 return const_cast<LinkerOptHint*>(
930 static_cast<const Binary*>(this)->linker_opt_hint()
931 );
932 }
934
936 ExportInfo* add_exported_function(uint64_t address, const std::string& name);
937
939 Symbol* add_local_symbol(uint64_t address, const std::string& name);
940
942 std::unique_ptr<objc::Metadata> objc_metadata() const;
943
952
954 bool has_atom_info() const {
955 return atom_info() != nullptr;
956 }
957
960 return const_cast<AtomInfo*>(static_cast<const Binary*>(this)->atom_info());
961 }
962 const AtomInfo* atom_info() const;
963
966
968
970 bool has_notes() const {
971 return get(LoadCommand::TYPE::NOTE) != nullptr;
972 }
973
976 return function_variants() != nullptr;
977 }
978
981 return const_cast<FunctionVariants*>(
982 static_cast<const Binary*>(this)->function_variants()
983 );
984 }
985
987
990 return function_variant_fixups() != nullptr;
991 }
992
995 return const_cast<FunctionVariantFixups*>(
996 static_cast<const Binary*>(this)->function_variant_fixups()
997 );
998 }
999
1001
1002 template<class T>
1004
1005 template<class T>
1007
1008 template<class T>
1009 LIEF_LOCAL const T* command() const;
1010
1011 template<class T>
1013
1014 template<class CMD, class Func>
1016
1018 return get(type);
1019 }
1021 return get(type);
1022 }
1023
1026
1029
1032
1034 bool has_filesets() const {
1035 return filesets_.empty();
1036 }
1037
1040 const std::string& fileset_name() const {
1041 return fileset_info_.name;
1042 }
1043
1045 uint64_t fileset_addr() const {
1046 return fileset_info_.address;
1047 }
1048
1050 Symbol& add(const Symbol& symbol);
1051
1052 ~Binary() override;
1053
1056 ok_error_t shift(size_t value);
1057
1060
1065 uint64_t memory_base_address() const {
1066 return in_memory_base_addr_;
1067 }
1068
1071 return header().cpu_type() == Header::CPU_TYPE::ARM64 &&
1072 (header().cpu_subtype() & ~Header::SUBTYPE_MASK) ==
1074 }
1075
1079
1081 result<uint64_t> get_function_address(const std::string& name) const override;
1082
1083 static bool classof(const LIEF::Binary* bin) {
1084 return bin->format() == Binary::FORMATS::MACHO;
1085 }
1086
1088 return overlay_;
1089 }
1090
1093
1095 static LIEF_LOCAL bool can_cache_segment(const SegmentCommand& segment);
1096
1098 LIEF_LOCAL size_t available_command_space() const {
1099 return available_command_space_;
1100 }
1101
1102 private:
1105
1106 LIEF_LOCAL void shift_command(size_t width, uint64_t from_offset);
1107
1110 LIEF_LOCAL size_t add_cached_segment(SegmentCommand& segment);
1111
1112 template<class T>
1113 LIEF_LOCAL ok_error_t patch_relocation(Relocation& relocation, uint64_t from,
1114 uint64_t shift);
1115
1116 LIEF::Header get_abstract_header() const override {
1117 return LIEF::Header::from(*this);
1118 }
1119
1120 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1121 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1122 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1124 get_abstract_exported_functions() const override;
1126 get_abstract_imported_functions() const override;
1127 LIEF_LOCAL std::vector<std::string>
1128 get_abstract_imported_libraries() const override;
1129
1133 ok_error_t ensure_command_space(size_t size) {
1134 return available_command_space_ < size ? shift(size) : ok();
1135 }
1136
1137 relocations_t& relocations_list() {
1138 return this->relocations_;
1139 }
1140
1141 const relocations_t& relocations_list() const {
1142 return this->relocations_;
1143 }
1144
1145 size_t pointer_size() const {
1146 return this->is64_ ? sizeof(uint64_t) : sizeof(uint32_t);
1147 }
1148
1149 bool is64_ = true;
1150 Header header_;
1151 commands_t commands_;
1152 symbols_t symbols_;
1153
1154 // Same purpose as sections_cache_t
1155 libraries_cache_t libraries_;
1156
1157 // The sections are owned by the SegmentCommand object.
1158 // This attribute is a cache to speed-up the iteration
1159 sections_cache_t sections_;
1160
1161 // Same purpose as sections_cache_t
1162 segments_cache_t segments_;
1163
1164 fileset_binaries_t filesets_;
1165
1166 // Cached relocations from segment / sections
1167 mutable relocations_t relocations_;
1168 size_t available_command_space_ = 0;
1169
1170 // This is used to improve performances of
1171 // offset_to_virtual_address
1172 std::map<uint64_t, SegmentCommand*> offset_seg_;
1173
1174 protected:
1175 struct fileset_info_t {
1176 std::string name;
1177 uint64_t address = 0;
1178 };
1179
1180 uint64_t fat_offset_ = 0;
1181 uint64_t in_memory_base_addr_ = 0;
1182 std::vector<uint8_t> overlay_;
1183 std::vector<std::unique_ptr<IndirectBindingInfo>> indirect_bindings_;
1184 fileset_info_t fileset_info_;
1185};
1186
1187} // namespace MachO
1188} // namespace LIEF
1189#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:59
std::vector< Function > functions_t
Definition Abstract/Binary.hpp:82
@ MACHO
Definition Abstract/Binary.hpp:78
FORMATS format() const
Executable format (ELF, PE, Mach-O) of the underlying binary.
Definition Abstract/Binary.hpp:124
std::vector< Symbol * > symbols_t
Internal container.
Definition Abstract/Binary.hpp:94
VA_TYPES
Enumeration of virtual address types used for patching and memory access.
Definition Abstract/Binary.hpp:62
@ AUTO
Automatically determine if the address is absolute or relative (default behavior).
Definition Abstract/Binary.hpp:65
std::vector< Section * > sections_t
Internal container.
Definition Abstract/Binary.hpp:85
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:103
Definition Abstract/Header.hpp:40
static Header from(const LIEF::ELF::Binary &elf)
Class which represents the LC_ATOM_INFO command.
Definition AtomInfo.hpp:35
Class which represents a MachO binary.
Definition MachO/Binary.hpp:88
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:862
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:1083
const_filter_iterator< const commands_t &, const RPathCommand * > it_const_rpaths
Iterator which outputs const RPathCommand&.
Definition MachO/Binary.hpp:199
bool is_pie() const override
Check if the binary is position independent.
Definition MachO/Binary.hpp:646
void write(std::ostream &os, Builder::config_t config)
Reconstruct the binary object and write the result in the given os stream for the given configuration...
uint64_t fileset_addr() const
Original address associated with the LC_FILESET_ENTRY for this MachO.
Definition MachO/Binary.hpp:1045
bool has_function_starts() const
true if the binary has a MachO::FunctionStarts command.
Definition MachO/Binary.hpp:709
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:820
it_imported_symbols imported_symbols()
Return binary's imported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:293
const ThreadCommand * thread_command() const
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:534
const SegmentSplitInfo * segment_split_info() const
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:718
const SegmentCommand * get_segment(const std::string &name) const
Return the segment from the given name.
const UUIDCommand * uuid() const
bool has_function_variant_fixups() const
true if the binary has the command LC_FUNCTION_VARIANT_FIXUPS.
Definition MachO/Binary.hpp:989
it_commands commands()
Return an iterator over the MachO LoadCommand present in the binary.
Definition MachO/Binary.hpp:236
filter_iterator< commands_t &, NoteCommand * > it_notes
Iterator which outputs NoteCommand&.
Definition MachO/Binary.hpp:215
range_t off_ranges() const
Return the range of offsets.
const DataInCode * data_in_code() const
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:192
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:954
bool has_dynamic_symbol_command() const
true if the binary has a MachO::DynamicSymbolCommand command.
Definition MachO/Binary.hpp:776
friend class BindingInfoIterator
Definition MachO/Binary.hpp:94
const_ref_iterator< const commands_t &, LoadCommand * > it_const_commands
Iterator that outputs const LoadCommand&.
Definition MachO/Binary.hpp:117
const DyldInfo * dyld_info() const
TwoLevelHints * two_level_hints()
Return the MachO::DyldChainedFixups if present, a nullptr otherwise.
Definition MachO/Binary.hpp:915
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:604
filter_iterator< commands_t &, RPathCommand * > it_rpaths
Iterator which outputs RPathCommand&.
Definition MachO/Binary.hpp:196
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.
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:691
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:490
const VersionMin * version_min() const
bool has_dyld_chained_fixups() const
true if the binary has the command LC_DYLD_CHAINED_FIXUPS.
Definition MachO/Binary.hpp:892
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:700
EncryptionInfo * encryption_info()
Return the MachO::DyldEnvironment 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:161
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:263
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:767
const LoadCommand * operator[](LoadCommand::TYPE type) const
Definition MachO/Binary.hpp:1020
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:754
it_const_fileset_binaries filesets() const
Definition MachO/Binary.hpp:250
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:152
it_relocations relocations()
Return an iterator over the MachO::Relocation.
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:651
bool can_remove(const Symbol &sym) const
Check if the given symbol can be safely removed.
void write(std::ostream &os)
Reconstruct the binary object and write the result in the given os stream.
it_const_sub_clients subclients() const
const SourceVersion * source_version() const
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:745
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:136
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:980
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:885
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:543
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:91
bool has_segment(const std::string &name) const
Check if a segment with the given name exists.
Definition MachO/Binary.hpp:500
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:673
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::DyldChainedFixups if present, a nullptr otherwise.
it_notes notes()
Iterator over the different LC_NOTE commands.
const DyldEnvironment * dyld_environment() const
it_const_sections sections() const
Definition MachO/Binary.hpp:326
it_const_symbols symbols() const
Definition MachO/Binary.hpp:258
std::vector< std::unique_ptr< LoadCommand > > commands_t
Internal container for storing Mach-O LoadCommand.
Definition MachO/Binary.hpp:111
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_CHAINED_FIXUPS.
Definition MachO/Binary.hpp:901
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation&.
Definition MachO/Binary.hpp:189
bool remove(LoadCommand::TYPE type)
Remove all LoadCommand with the given type (MachO::LoadCommand::TYPE).
const Routine * routine_command() const
it_symbols symbols()
Return binary's symbols .
Definition MachO/Binary.hpp:255
LoadCommand * operator[](LoadCommand::TYPE type)
Definition MachO/Binary.hpp:1017
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:923
const DyldChainedFixups * dyld_chained_fixups() const
const_ref_iterator< const sections_cache_t & > it_const_sections
Iterator that outputs const Section&.
Definition MachO/Binary.hpp:149
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:209
std::vector< std::unique_ptr< Binary > > fileset_binaries_t
Internal container for storing Mach-O Fileset Binary.
Definition MachO/Binary.hpp:170
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.
const FunctionStarts * function_starts() const
it_segments segments()
Return an iterator over the SegmentCommand.
Definition MachO/Binary.hpp:315
Binary(const Binary &)=delete
Section * get_section(const std::string &name)
Return the section from the given name of a nullptr if the section can't be found.
Definition MachO/Binary.hpp:477
it_fileset_binaries filesets()
Return an iterator over the MachO::Binary associated with the LoadCommand::TYPE::FILESET_ENTRY comman...
Definition MachO/Binary.hpp:246
Binary & operator=(const Binary &)=delete
filter_iterator< commands_t &, SubClient * > it_sub_clients
Iterator which outputs SubClient&.
Definition MachO/Binary.hpp:203
const FunctionVariants * function_variants() const
it_const_segments segments() const
Definition MachO/Binary.hpp:318
const_filter_iterator< const commands_t &, const NoteCommand * > it_const_notes
Iterator which outputs const NoteCommand&.
Definition MachO/Binary.hpp:218
bool has_nx_stack() const
Return True if the stack is flagged as non-executable. False otherwise.
Definition MachO/Binary.hpp:656
it_libraries libraries()
Return binary imported libraries (MachO::DylibCommand).
Definition MachO/Binary.hpp:306
bool has_data_in_code() const
true if the binary has a MachO::DataInCode command.
Definition MachO/Binary.hpp:811
const SubFramework * sub_framework() const
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
void write(const std::string &filename, Builder::config_t config)
Reconstruct the binary object and write the result in the given filename.
it_exported_symbols exported_symbols()
Return binary's exported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:278
const MainCommand * main_command() const
filter_iterator< symbols_t &, Symbol * > it_exported_symbols
Iterator that outputs exported Symbol&.
Definition MachO/Binary.hpp:129
BuildVersion::PLATFORMS platform() const
Return the platform for which this Mach-O has been compiled for.
Definition MachO/Binary.hpp:871
it_const_relocations relocations() const
span< const uint8_t > overlay() const
Definition MachO/Binary.hpp:1087
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:583
friend class Builder
Definition MachO/Binary.hpp:92
DyldChainedFixups * dyld_chained_fixups()
Return the MachO::DyldChainedFixups if present, a nullptr otherwise.
const RPathCommand * rpath() const
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:126
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:508
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:164
const DynamicSymbolCommand * dynamic_symbol_command() const
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:206
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:928
uint64_t fat_offset() const
Return binary's fat offset. 0 if not relevant.
Definition MachO/Binary.hpp:577
const Header & header() const
Definition MachO/Binary.hpp:230
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:661
const AtomInfo * atom_info() const
LoadCommand * add(const LoadCommand &command)
Insert a new LoadCommand.
Definition MachO/Binary.hpp:376
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:727
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:970
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:120
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:790
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 exists, 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:123
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:1065
bool has_sub_framework() const
true if the binary has a sub framework command.
Definition MachO/Binary.hpp:829
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
it_const_notes notes() const
ref_iterator< sections_cache_t & > it_sections
Iterator that outputs Section&.
Definition MachO/Binary.hpp:146
FunctionStarts * function_starts()
Return the MachO::FunctionStarts command if present, a nullptr otherwise.
friend class Parser
Definition MachO/Binary.hpp:90
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:155
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.
LoadCommand * get(LoadCommand::TYPE type)
Definition MachO/Binary.hpp:369
bool is_ios() const
True if this binary targets iOS.
Definition MachO/Binary.hpp:879
bool has_entrypoint() const
true if the binary has an entrypoint.
Definition MachO/Binary.hpp:668
ref_iterator< fileset_binaries_t &, Binary * > it_fileset_binaries
Iterator that outputs Binary&.
Definition MachO/Binary.hpp:173
bool has_two_level_hints() const
true if the binary has the command LC_TWO_LEVEL_HINTS.
Definition MachO/Binary.hpp:910
it_const_rpaths rpaths() const
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.
const EncryptionInfo * encryption_info() const
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:139
bool has_encryption_info() const
true if the binary has Encryption Info.
Definition MachO/Binary.hpp:834
bool has(LoadCommand::TYPE type) const
Check if the current binary has the given MachO::LoadCommand::TYPE.
const DyldExportsTrie * dyld_exports_trie() const
const SymbolCommand * symbol_command() const
DylibCommand * find_library(const std::string &name)
Definition MachO/Binary.hpp:401
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:798
CodeSignatureDir * code_signature_dir()
Return the MachO::CodeSignatureDir if present, a nullptr otherwise.
Definition MachO/Binary.hpp:803
const_ref_iterator< const segments_cache_t & > it_const_segments
Iterator that outputs const SegmentCommand&.
Definition MachO/Binary.hpp:158
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:186
bool has_code_signature() const
true if the binary is signed with LC_CODE_SIGNATURE command
Definition MachO/Binary.hpp:785
AtomInfo * atom_info()
Return the MachO::AtomInfo if present, a nullptr otherwise.
Definition MachO/Binary.hpp:959
ref_iterator< commands_t &, LoadCommand * > it_commands
Iterator that outputs LoadCommand&.
Definition MachO/Binary.hpp:114
std::vector< Section * > sections_cache_t
Internal container for caching Mach-O Section.
Definition MachO/Binary.hpp:143
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:471
it_const_imported_symbols imported_symbols() const
Definition MachO/Binary.hpp:299
bool has_main_command() const
true if the binary has a MachO::MainCommand command.
Definition MachO/Binary.hpp:682
Header & header()
Return a reference to the MachO::Header.
Definition MachO/Binary.hpp:226
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:1070
it_const_commands commands() const
Definition MachO/Binary.hpp:240
bool has_dyld_environment() const
true if the binary has Dyld envrionment variables.
Definition MachO/Binary.hpp:853
it_const_libraries libraries() const
Definition MachO/Binary.hpp:310
bool has_function_variants() const
true if the binary has the command LC_FUNCTION_VARIANTS.
Definition MachO/Binary.hpp:975
const_filter_iterator< const symbols_t &, const Symbol * > it_const_exported_symbols
Iterator that outputs exported const Symbol&.
Definition MachO/Binary.hpp:132
const std::string & fileset_name() const
Name associated with the LC_FILESET_ENTRY for this MachO. For instance: com.apple....
Definition MachO/Binary.hpp:1040
Binary & for_commands(Func f)
FunctionVariantFixups * function_variant_fixups()
Return the FunctionVariantFixups if present, a nullptr otherwise.
Definition MachO/Binary.hpp:994
iterator_range< Stub::Iterator > stub_iterator
Iterator type for Symbol's stub.
Definition MachO/Binary.hpp:212
bool has_filesets() const
true if the binary has a LoadCommand::TYPE::FILESET_ENTRY command
Definition MachO/Binary.hpp:1034
Symbol * get_symbol(const std::string &name)
Definition MachO/Binary.hpp:270
SegmentCommand * segment_from_offset(uint64_t offset)
Return the binary's SegmentCommand that encompasses the provided offset.
Definition MachO/Binary.hpp:566
friend class DyldInfo
Definition MachO/Binary.hpp:93
const_ref_iterator< const fileset_binaries_t &, Binary * > it_const_fileset_binaries
Iterator that outputs const Binary&.
Definition MachO/Binary.hpp:176
const DylinkerCommand * dylinker() const
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:283
bool has_thread_command() const
true if the binary has a MachO::ThreadCommand command.
Definition MachO/Binary.hpp:736
Symbol & add(const Symbol &symbol)
Add a symbol to this binary.
bool unexport(const Symbol &sym)
Remove the given symbol from the export table.
const BuildVersion * build_version() const
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:462
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:167
it_sections sections()
Return an iterator over the MachO::Section.
Definition MachO/Binary.hpp:323
Definition BuildVersion.hpp:34
PLATFORMS
Definition BuildVersion.hpp:44
@ MACOS
Definition BuildVersion.hpp:46
@ UNKNOWN
Definition BuildVersion.hpp:45
@ IOS
Definition BuildVersion.hpp:47
Definition CodeSignatureDir.hpp:36
Definition CodeSignature.hpp:37
Interface of the LC_DATA_IN_CODE command This command is used to list slices of code sections that co...
Definition DataInCode.hpp:42
Class that represents the LC_DYLD_CHAINED_FIXUPS command.
Definition DyldChainedFixups.hpp:49
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:40
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:39
Class which represents the LC_FUNCTION_VARIANT_FIXUPS command.
Definition FunctionVariantFixups.hpp:34
Class representing the LC_FUNCTION_VARIANTS load command.
Definition FunctionVariants.hpp:59
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:37
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
TYPE
Definition LoadCommand.hpp:45
@ NOTE
Definition LoadCommand.hpp:96
@ VERSION_MIN_MACOSX
Definition LoadCommand.hpp:83
@ VERSION_MIN_IPHONEOS
Definition LoadCommand.hpp:84
Class that represent the LC_MAIN command. This kind of command can be used to determine the entrypoin...
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. Accodring to the Mach-O loader....
Definition Routine.hpp:38
Class that represents a Mach-O section.
Definition MachO/Section.hpp:47
Class which represents a LoadCommand::TYPE::SEGMENT / LoadCommand::TYPE::SEGMENT_64 command.
Definition SegmentCommand.hpp:51
Class that represents the LoadCommand::TYPE::SEGMENT_SPLIT_INFO command.
Definition SegmentSplitInfo.hpp:35
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. Accodring to the Mach-O loader.h documentation:
Definition SubFramework.hpp:46
Class that represents the LC_SYMTAB command.
Definition SymbolCommand.hpp:35
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:42
Class which represents the LC_TWOLEVEL_HINTS command.
Definition TwoLevelHints.hpp:39
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:29
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:212
Iterator which return a ref on container's values given predicates.
Definition iterators.hpp:293
Definition iterators.hpp:567
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:114
Iterator which returns reference on container's values.
Definition iterators.hpp:45
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
Namespace related to ObjC metadata.
Definition MachO/Binary.hpp:41
LIEF namespace.
Definition Abstract/Binary.hpp:40
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 return a const ref on container's values given predicates.
Definition iterators.hpp:559
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:98
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 return const ref on container's values.
Definition iterators.hpp:286
Definition MachO/Binary.hpp:179
bool operator()(const Relocation *lhs, const Relocation *rhs) const
Definition MachO/Binary.hpp:97
uint64_t start
Definition MachO/Binary.hpp:98
uint64_t size() const
Definition MachO/Binary.hpp:101
uint64_t end
Definition MachO/Binary.hpp:99
bool empty() const
Definition MachO/Binary.hpp:105
Options to tweak the building process.
Definition MachO/Builder.hpp:66
#define LIEF_API
Definition visibility.h:43
#define LIEF_LOCAL
Definition visibility.h:44