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
32#include "LIEF/visibility.h"
33#include "LIEF/utils.hpp"
34
36
37#include "LIEF/iterators.hpp"
38#include "LIEF/errors.hpp"
39
40namespace LIEF {
41
42namespace objc {
43class Metadata;
44}
45
47namespace MachO {
48
49class AtomInfo;
50class BinaryParser;
51class Builder;
52class CodeSignature;
53class CodeSignatureDir;
54class DataInCode;
55class DyldChainedFixups;
56class DyldEnvironment;
57class DyldExportsTrie;
58class DyldInfo;
59class DylibCommand;
60class DylinkerCommand;
61class DynamicSymbolCommand;
62class EncryptionInfo;
63class ExportInfo;
64class FunctionStarts;
65class FunctionVariants;
66class FunctionVariantFixups;
67class Header;
68class IndirectBindingInfo;
69class LinkerOptHint;
70class MainCommand;
71class Parser;
72class RPathCommand;
73class Relocation;
74class Routine;
75class Section;
76class SegmentCommand;
77class SegmentSplitInfo;
78class SourceVersion;
79class SubClient;
80class SubFramework;
81class Symbol;
82class SymbolCommand;
83class ThreadCommand;
84class TwoLevelHints;
85class UUIDCommand;
86class VersionMin;
87
90
91 friend class Parser;
92 friend class BinaryParser;
93 friend class Builder;
94 friend class DyldInfo;
95 friend class BindingInfoIterator;
96
97 public:
98 struct range_t {
99 uint64_t start = 0;
100 uint64_t end = 0;
101
102 uint64_t size() const {
103 return end - start;
104 }
105
106 bool empty() const {
107 return start == end;
108 }
109 };
110
112 using commands_t = std::vector<std::unique_ptr<LoadCommand>>;
113
116
119
121 using symbols_t = std::vector<std::unique_ptr<Symbol>>;
122
125
128
131
135
138
142
144 using sections_cache_t = std::vector<Section*>;
145
148
151
153 using segments_cache_t = std::vector<SegmentCommand*>;
154
157
160
162 using libraries_cache_t = std::vector<DylibCommand*>;
163
166
169
171 using fileset_binaries_t = std::vector<std::unique_ptr<Binary>>;
172
175
179
180 struct KeyCmp {
181 bool operator()(const Relocation* lhs, const Relocation* rhs) const;
182 };
183
187 using relocations_t = std::set<Relocation*, KeyCmp>;
188
191
195
198
202
205
209
211
214
217
221
222 public:
223 Binary(const Binary&) = delete;
224 Binary& operator=(const Binary&) = delete;
225
228 return header_;
229 }
230
232 return header_;
233 }
234
238 return commands_;
239 }
240
242 return commands_;
243 }
244
248 return filesets_;
249 }
250
252 return filesets_;
253 }
254
257 return symbols_;
258 }
260 return symbols_;
261 }
262
264 bool has_symbol(const std::string& name) const {
265 return get_symbol(name) != nullptr;
266 }
267
270 const Symbol* get_symbol(const std::string& name) const LIEF_LIFETIMEBOUND;
271 Symbol* get_symbol(const std::string& name) LIEF_LIFETIMEBOUND {
272 return const_cast<Symbol*>(static_cast<const Binary*>(this)->get_symbol(name));
273 }
274
276 static bool is_exported(const Symbol& symbol);
277
280 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
281 return is_exported(*symbol);
282 }};
283 }
285 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
286 return is_exported(*symbol);
287 }};
288 }
289
291 static bool is_imported(const Symbol& symbol);
292
295 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
296 return is_imported(*symbol);
297 }};
298 }
299
301 return {symbols_, [](const std::unique_ptr<Symbol>& symbol) {
302 return is_imported(*symbol);
303 }};
304 }
305
308 return libraries_;
309 }
310
312 return libraries_;
313 }
314
317 return segments_;
318 }
320 return segments_;
321 }
322
325 return sections_;
326 }
328 return sections_;
329 }
330
333 return static_cast<const Binary*>(this)->relocations();
334 }
335
337
341 void write(const std::string& filename);
342
350 void write(const std::string& filename, Builder::config_t config);
351
355 void write(std::ostream& os);
356
362 void write(std::ostream& os, Builder::config_t config);
363
365 std::vector<uint8_t> raw();
366
368 bool has(LoadCommand::TYPE type) const;
369
374 return const_cast<LoadCommand*>(static_cast<const Binary*>(this)->get(type));
375 }
376
377 LoadCommand* add(std::unique_ptr<LoadCommand> command) LIEF_LIFETIMEBOUND;
378
381 return add(command.clone());
382 }
383
386
389
392
394 LoadCommand* add_library(const std::string& name) LIEF_LIFETIMEBOUND;
395
398
403 const DylibCommand*
404 find_library(const std::string& name) const LIEF_LIFETIMEBOUND;
405
406 DylibCommand* find_library(const std::string& name) LIEF_LIFETIMEBOUND {
407 return const_cast<DylibCommand*>(
408 static_cast<const Binary*>(this)->find_library(name)
409 );
410 }
411
417 const Section& section) LIEF_LIFETIMEBOUND;
418
423 void remove_section(const std::string& name, bool clear = false) override;
424
432 void remove_section(const std::string& segname, const std::string& secname,
433 bool clear = false);
434
437
440
442 bool remove_command(size_t index);
443
446
448 bool extend(const LoadCommand& command, uint64_t size);
449
451 bool extend_segment(const SegmentCommand& segment, size_t size);
452
459 bool extend_section(Section& section, size_t size);
460
463
465 uint64_t imagebase() const override;
466
468 uint64_t virtual_size() const override {
469 return align(va_ranges().size(), (uint64_t)page_size());
470 }
471
474 std::string loader() const;
475
477 bool has_section(const std::string& name) const {
478 return get_section(name) != nullptr;
479 }
480
483 Section* get_section(const std::string& name) LIEF_LIFETIMEBOUND {
484 return const_cast<Section*>(
485 static_cast<const Binary*>(this)->get_section(name)
486 );
487 }
488
491 const Section* get_section(const std::string& name) const LIEF_LIFETIMEBOUND;
492
496 Section* get_section(const std::string& segname,
497 const std::string& secname) LIEF_LIFETIMEBOUND {
498 return const_cast<Section*>(
499 static_cast<const Binary*>(this)->get_section(segname, secname)
500 );
501 }
502
503 const Section* get_section(const std::string& segname,
504 const std::string& secname) const LIEF_LIFETIMEBOUND;
505
507 bool has_segment(const std::string& name) const {
508 return get_segment(name) != nullptr;
509 }
510
512 const SegmentCommand*
513 get_segment(const std::string& name) const LIEF_LIFETIMEBOUND;
514
517 return const_cast<SegmentCommand*>(
518 static_cast<const Binary*>(this)->get_segment(name)
519 );
520 }
521
523 bool remove_symbol(const std::string& name);
524
526 bool remove(const Symbol& sym);
527
529 bool can_remove(const Symbol& sym) const;
530
532 bool can_remove_symbol(const std::string& name) const;
533
535 bool unexport(const std::string& name);
536
538 bool unexport(const Symbol& sym);
539
543 return const_cast<Section*>(
544 static_cast<const Binary*>(this)->section_from_offset(offset)
545 );
546 }
547 const Section* section_from_offset(uint64_t offset) const LIEF_LIFETIMEBOUND;
548
551 Section*
553 return const_cast<Section*>(
554 static_cast<const Binary*>(this)->section_from_virtual_address(
555 virtual_address
556 )
557 );
558 }
560 uint64_t virtual_address
561 ) const LIEF_LIFETIMEBOUND;
562
564 result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const;
565
572 uint64_t slide = 0) const override;
573
578 return const_cast<SegmentCommand*>(
579 static_cast<const Binary*>(this)->segment_from_offset(offset)
580 );
581 }
582 const SegmentCommand*
584
586 size_t segment_index(const SegmentCommand& segment) const;
587
589 uint64_t fat_offset() const {
590 return fat_offset_;
591 }
592
597 return const_cast<SegmentCommand*>(
598 static_cast<const Binary*>(this)->segment_from_virtual_address(
599 virtual_address
600 )
601 );
602 }
604 uint64_t virtual_address
605 ) const LIEF_LIFETIMEBOUND;
606
609
612
615
618 bool is_valid_addr(uint64_t address) const {
619 const range_t& r = va_ranges();
620 return r.start <= address && address < r.end;
621 }
622
624 void accept(LIEF::Visitor& visitor) const override;
625
626 std::ostream& print(std::ostream& os) const override;
627
634 void patch_address(uint64_t address, const std::vector<uint8_t>& patch_value,
635 LIEF::Binary::VA_TYPES addr_type =
637
646 uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t),
648 ) override;
649
652 uint64_t virtual_address, uint64_t size,
654 ) const override;
655
657 uint64_t entrypoint() const override;
658
660 bool is_pie() const override {
661 return header().has(Header::FLAGS::PIE);
662 }
663
665 bool has_nx() const override {
666 return has_nx_stack();
667 }
668
670 bool has_nx_stack() const {
672 }
673
675 bool has_nx_heap() const {
677 }
678
682 bool has_entrypoint() const {
684 }
685
687 bool has_uuid() const {
688 return uuid() != nullptr;
689 }
690
694
696 bool has_main_command() const {
697 return main_command() != nullptr;
698 }
699
703
705 bool has_dylinker() const {
706 return dylinker() != nullptr;
707 }
708
712
714 bool has_dyld_info() const {
715 return dyld_info() != nullptr;
716 }
717
721
723 bool has_function_starts() const {
724 return function_starts() != nullptr;
725 }
726
730
732 bool has_source_version() const {
733 return source_version() != nullptr;
734 }
735
739
741 bool has_version_min() const {
742 return version_min() != nullptr;
743 }
744
748
750 bool has_thread_command() const {
751 return thread_command() != nullptr;
752 }
753
757
759 bool has_routine_command() const {
760 return routine_command() != nullptr;
761 }
762
766
768 bool has_rpath() const {
769 return rpath() != nullptr;
770 }
771
775
779
781 bool has_symbol_command() const {
782 return symbol_command() != nullptr;
783 }
784
788
791 return dynamic_symbol_command() != nullptr;
792 }
793
797
799 bool has_code_signature() const {
800 return code_signature() != nullptr;
801 }
802
805 return const_cast<CodeSignature*>(
806 static_cast<const Binary*>(this)->code_signature()
807 );
808 }
810
813 return code_signature_dir() != nullptr;
814 }
815
818 return const_cast<CodeSignatureDir*>(
819 static_cast<const Binary*>(this)->code_signature_dir()
820 );
821 }
823
825 bool has_data_in_code() const {
826 return data_in_code() != nullptr;
827 }
828
832
835 return segment_split_info() != nullptr;
836 }
837
841
843 bool has_sub_framework() const {
844 return sub_framework() != nullptr;
845 }
846
848 bool has_encryption_info() const {
849 return encryption_info() != nullptr;
850 }
851
855
859
863
864 bool has_subclients() const;
865
867 bool has_dyld_environment() const {
868 return dyld_environment() != nullptr;
869 }
870
874
876 bool has_build_version() const {
877 return build_version() != nullptr;
878 }
879
883
886 if (const BuildVersion* version = build_version()) {
887 return version->platform();
888 }
890 }
891
897
903
904
907 return dyld_chained_fixups() != nullptr;
908 }
909
913
916 return dyld_exports_trie() != nullptr;
917 }
918
922
924 bool has_two_level_hints() const {
925 return two_level_hints() != nullptr;
926 }
927
930 return const_cast<TwoLevelHints*>(
931 static_cast<const Binary*>(this)->two_level_hints()
932 );
933 }
935
937 bool has_linker_opt_hint() const {
938 return linker_opt_hint() != nullptr;
939 }
940
943 return const_cast<LinkerOptHint*>(
944 static_cast<const Binary*>(this)->linker_opt_hint()
945 );
946 }
948
951 const std::string& name) LIEF_LIFETIMEBOUND;
952
954 Symbol* add_local_symbol(uint64_t address,
955 const std::string& name) LIEF_LIFETIMEBOUND;
956
958 std::unique_ptr<objc::Metadata> objc_metadata() const;
959
968
970 bool has_atom_info() const {
971 return atom_info() != nullptr;
972 }
973
976 return const_cast<AtomInfo*>(static_cast<const Binary*>(this)->atom_info());
977 }
979
982
984
986 bool has_notes() const {
987 return get(LoadCommand::TYPE::NOTE) != nullptr;
988 }
989
992 return function_variants() != nullptr;
993 }
994
997 return const_cast<FunctionVariants*>(
998 static_cast<const Binary*>(this)->function_variants()
999 );
1000 }
1001
1003
1006 return function_variant_fixups() != nullptr;
1007 }
1008
1011 return const_cast<FunctionVariantFixups*>(
1012 static_cast<const Binary*>(this)->function_variant_fixups()
1013 );
1014 }
1015
1017
1018 template<class T>
1020
1021 template<class T>
1023
1024 template<class T>
1025 LIEF_LOCAL const T* command() const;
1026
1027 template<class T>
1029
1030 template<class CMD, class Func>
1032
1034 return get(type);
1035 }
1037 return get(type);
1038 }
1039
1042
1045
1048
1050 bool has_filesets() const {
1051 return filesets_.empty();
1052 }
1053
1056 const std::string& fileset_name() const {
1057 return fileset_info_.name;
1058 }
1059
1061 uint64_t fileset_addr() const {
1062 return fileset_info_.address;
1063 }
1064
1067
1068 ~Binary() override;
1069
1072 ok_error_t shift(size_t value);
1073
1076
1081 uint64_t memory_base_address() const {
1082 return in_memory_base_addr_;
1083 }
1084
1087 return header().cpu_type() == Header::CPU_TYPE::ARM64 &&
1088 (header().cpu_subtype() & ~Header::SUBTYPE_MASK) ==
1090 }
1091
1095
1097 result<uint64_t> get_function_address(const std::string& name) const override;
1098
1099 static bool classof(const LIEF::Binary* bin) {
1100 return bin->format() == Binary::FORMATS::MACHO;
1101 }
1102
1104 return overlay_;
1105 }
1106
1109
1111 static LIEF_LOCAL bool can_cache_segment(const SegmentCommand& segment);
1112
1114 LIEF_LOCAL size_t available_command_space() const {
1115 return available_command_space_;
1116 }
1117
1118 private:
1121
1122 LIEF_LOCAL void shift_command(size_t width, uint64_t from_offset);
1123
1126 LIEF_LOCAL size_t add_cached_segment(SegmentCommand& segment);
1127
1128 template<class T>
1129 LIEF_LOCAL ok_error_t patch_relocation(Relocation& relocation, uint64_t from,
1130 uint64_t shift);
1131
1132 LIEF::Header get_abstract_header() const override {
1133 return LIEF::Header::from(*this);
1134 }
1135
1136 LIEF_LOCAL LIEF::Binary::sections_t get_abstract_sections() override;
1137 LIEF_LOCAL LIEF::Binary::symbols_t get_abstract_symbols() override;
1138 LIEF_LOCAL LIEF::Binary::relocations_t get_abstract_relocations() override;
1140 get_abstract_exported_functions() const override;
1142 get_abstract_imported_functions() const override;
1143 LIEF_LOCAL std::vector<std::string>
1144 get_abstract_imported_libraries() const override;
1145
1149 ok_error_t ensure_command_space(size_t size) {
1150 return available_command_space_ < size ? shift(size) : ok();
1151 }
1152
1153 relocations_t& relocations_list() {
1154 return this->relocations_;
1155 }
1156
1157 const relocations_t& relocations_list() const {
1158 return this->relocations_;
1159 }
1160
1161 size_t pointer_size() const {
1162 return this->is64_ ? sizeof(uint64_t) : sizeof(uint32_t);
1163 }
1164
1165 bool is64_ = true;
1166 Header header_;
1167 commands_t commands_;
1168 symbols_t symbols_;
1169
1170 // Same purpose as sections_cache_t
1171 libraries_cache_t libraries_;
1172
1173 // The sections are owned by the SegmentCommand object.
1174 // This attribute is a cache to speed-up the iteration
1175 sections_cache_t sections_;
1176
1177 // Same purpose as sections_cache_t
1178 segments_cache_t segments_;
1179
1180 fileset_binaries_t filesets_;
1181
1182 // Cached relocations from segment / sections
1183 mutable relocations_t relocations_;
1184 size_t available_command_space_ = 0;
1185
1186 // This is used to improve performances of
1187 // offset_to_virtual_address
1188 std::map<uint64_t, SegmentCommand*> offset_seg_;
1189
1190 protected:
1191 struct fileset_info_t {
1192 std::string name;
1193 uint64_t address = 0;
1194 };
1195
1196 uint64_t fat_offset_ = 0;
1197 uint64_t in_memory_base_addr_ = 0;
1198 std::vector<uint8_t> overlay_;
1199 std::vector<std::unique_ptr<IndirectBindingInfo>> indirect_bindings_;
1200 fileset_info_t fileset_info_;
1201 mutable std::mutex mu_;
1202};
1203
1204} // namespace MachO
1205} // namespace LIEF
1206#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:89
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:876
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:1099
const_filter_iterator< const commands_t &, const RPathCommand * > it_const_rpaths
Iterator which outputs const RPathCommand&.
Definition MachO/Binary.hpp:200
bool is_pie() const override
Check if the binary is position independent.
Definition MachO/Binary.hpp:660
uint64_t fileset_addr() const
Original address associated with the LC_FILESET_ENTRY for this MachO.
Definition MachO/Binary.hpp:1061
bool has_function_starts() const
true if the binary has a MachO::FunctionStarts command.
Definition MachO/Binary.hpp:723
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:834
it_imported_symbols imported_symbols()
Return binary's imported symbols (iterator over LIEF::MachO::Symbol).
Definition MachO/Binary.hpp:294
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:542
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:732
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:1005
it_commands commands()
Return an iterator over the MachO LoadCommand present in the binary.
Definition MachO/Binary.hpp:237
filter_iterator< commands_t &, NoteCommand * > it_notes
Iterator which outputs NoteCommand&.
Definition MachO/Binary.hpp:216
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:193
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:970
bool has_dynamic_symbol_command() const
true if the binary has a MachO::DynamicSymbolCommand command.
Definition MachO/Binary.hpp:790
friend class BindingInfoIterator
Definition MachO/Binary.hpp:95
const_ref_iterator< const commands_t &, LoadCommand * > it_const_commands
Iterator that outputs const LoadCommand&.
Definition MachO/Binary.hpp:118
TwoLevelHints * two_level_hints()
Return the MachO::TwoLevelHints if present, a nullptr otherwise.
Definition MachO/Binary.hpp:929
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:618
filter_iterator< commands_t &, RPathCommand * > it_rpaths
Iterator which outputs RPathCommand&.
Definition MachO/Binary.hpp:197
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:705
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:496
bool has_dyld_chained_fixups() const
true if the binary has the command LC_DYLD_CHAINED_FIXUPS.
Definition MachO/Binary.hpp:906
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:714
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:162
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:264
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:781
const LoadCommand * operator[](LoadCommand::TYPE type) const
Definition MachO/Binary.hpp:1036
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:768
it_const_fileset_binaries filesets() const
Definition MachO/Binary.hpp:251
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:153
it_relocations relocations()
Return an iterator over the MachO::Relocation.
Definition MachO/Binary.hpp:332
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:665
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:759
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:137
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:996
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:899
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:552
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:92
bool has_segment(const std::string &name) const
Check if a segment with the given name exists.
Definition MachO/Binary.hpp:507
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:687
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:327
it_const_symbols symbols() const
Definition MachO/Binary.hpp:259
std::vector< std::unique_ptr< LoadCommand > > commands_t
Internal container for storing Mach-O LoadCommand.
Definition MachO/Binary.hpp:112
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:915
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator which outputs Relocation&.
Definition MachO/Binary.hpp:190
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:256
LoadCommand * operator[](LoadCommand::TYPE type)
Definition MachO/Binary.hpp:1033
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:937
const_ref_iterator< const sections_cache_t & > it_const_sections
Iterator that outputs const Section&.
Definition MachO/Binary.hpp:150
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:210
std::vector< std::unique_ptr< Binary > > fileset_binaries_t
Internal container for storing Mach-O Fileset Binary.
Definition MachO/Binary.hpp:171
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:316
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:483
it_fileset_binaries filesets()
Return an iterator over the MachO::Binary associated with the LoadCommand::TYPE::FILESET_ENTRY comman...
Definition MachO/Binary.hpp:247
Binary & operator=(const Binary &)=delete
filter_iterator< commands_t &, SubClient * > it_sub_clients
Iterator which outputs SubClient&.
Definition MachO/Binary.hpp:204
const FunctionVariants * function_variants() const
it_const_segments segments() const
Definition MachO/Binary.hpp:319
const_filter_iterator< const commands_t &, const NoteCommand * > it_const_notes
Iterator which outputs const NoteCommand&.
Definition MachO/Binary.hpp:219
bool has_nx_stack() const
Return True if the stack is flagged as non-executable. False otherwise.
Definition MachO/Binary.hpp:670
it_libraries libraries()
Return binary imported libraries (MachO::DylibCommand).
Definition MachO/Binary.hpp:307
bool has_data_in_code() const
true if the binary has a MachO::DataInCode command.
Definition MachO/Binary.hpp:825
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:279
filter_iterator< symbols_t &, Symbol * > it_exported_symbols
Iterator that outputs exported Symbol&.
Definition MachO/Binary.hpp:130
BuildVersion::PLATFORMS platform() const
Return the platform for which this Mach-O has been compiled for.
Definition MachO/Binary.hpp:885
it_const_relocations relocations() const
span< const uint8_t > overlay() const
Definition MachO/Binary.hpp:1103
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:596
friend class Builder
Definition MachO/Binary.hpp:93
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:127
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:516
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:165
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:207
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:942
uint64_t fat_offset() const
Return binary's fat offset. 0 if not relevant.
Definition MachO/Binary.hpp:589
const Header & header() const
Definition MachO/Binary.hpp:231
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:675
const AtomInfo * atom_info() const
LoadCommand * add(const LoadCommand &command)
Insert a new LoadCommand.
Definition MachO/Binary.hpp:380
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:741
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:986
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:121
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:804
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:124
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:1081
bool has_sub_framework() const
true if the binary has a sub framework command.
Definition MachO/Binary.hpp:843
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:147
FunctionStarts * function_starts()
Return the MachO::FunctionStarts command if present, a nullptr otherwise.
friend class Parser
Definition MachO/Binary.hpp:91
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:156
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:893
bool has_entrypoint() const
true if the binary has an entrypoint.
Definition MachO/Binary.hpp:682
ref_iterator< fileset_binaries_t &, Binary * > it_fileset_binaries
Iterator that outputs Binary&.
Definition MachO/Binary.hpp:174
bool has_two_level_hints() const
true if the binary has the command LC_TWO_LEVEL_HINTS.
Definition MachO/Binary.hpp:924
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:140
bool has_encryption_info() const
true if the binary has Encryption Info.
Definition MachO/Binary.hpp:848
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:406
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:812
CodeSignatureDir * code_signature_dir()
Return the MachO::CodeSignatureDir if present, a nullptr otherwise.
Definition MachO/Binary.hpp:817
const_ref_iterator< const segments_cache_t & > it_const_segments
Iterator that outputs const SegmentCommand&.
Definition MachO/Binary.hpp:159
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:187
bool has_code_signature() const
true if the binary is signed with LC_CODE_SIGNATURE command
Definition MachO/Binary.hpp:799
AtomInfo * atom_info()
Return the MachO::AtomInfo if present, a nullptr otherwise.
Definition MachO/Binary.hpp:975
ref_iterator< commands_t &, LoadCommand * > it_commands
Iterator that outputs LoadCommand&.
Definition MachO/Binary.hpp:115
std::vector< Section * > sections_cache_t
Internal container for caching Mach-O Section.
Definition MachO/Binary.hpp:144
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:477
it_const_imported_symbols imported_symbols() const
Definition MachO/Binary.hpp:300
bool has_main_command() const
true if the binary has a MachO::MainCommand command.
Definition MachO/Binary.hpp:696
Header & header()
Return a reference to the MachO::Header.
Definition MachO/Binary.hpp:227
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:1086
it_const_commands commands() const
Definition MachO/Binary.hpp:241
bool has_dyld_environment() const
true if the binary has Dyld environment variables.
Definition MachO/Binary.hpp:867
it_const_libraries libraries() const
Definition MachO/Binary.hpp:311
bool has_function_variants() const
true if the binary has the command LC_FUNCTION_VARIANTS.
Definition MachO/Binary.hpp:991
const_filter_iterator< const symbols_t &, const Symbol * > it_const_exported_symbols
Iterator that outputs exported const Symbol&.
Definition MachO/Binary.hpp:133
const std::string & fileset_name() const
Name associated with the LC_FILESET_ENTRY for this MachO. For instance: com.apple....
Definition MachO/Binary.hpp:1056
Binary & for_commands(Func f)
FunctionVariantFixups * function_variant_fixups()
Return the FunctionVariantFixups if present, a nullptr otherwise.
Definition MachO/Binary.hpp:1010
iterator_range< Stub::Iterator > stub_iterator
Iterator type for Symbol's stub.
Definition MachO/Binary.hpp:213
bool has_filesets() const
true if the binary has a LoadCommand::TYPE::FILESET_ENTRY command
Definition MachO/Binary.hpp:1050
Symbol * get_symbol(const std::string &name)
Definition MachO/Binary.hpp:271
SegmentCommand * segment_from_offset(uint64_t offset)
Return the binary's SegmentCommand that encompasses the provided offset.
Definition MachO/Binary.hpp:577
friend class DyldInfo
Definition MachO/Binary.hpp:94
const_ref_iterator< const fileset_binaries_t &, Binary * > it_const_fileset_binaries
Iterator that outputs const Binary&.
Definition MachO/Binary.hpp:177
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:284
bool has_thread_command() const
true if the binary has a MachO::ThreadCommand command.
Definition MachO/Binary.hpp:750
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:468
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:168
it_sections sections()
Return an iterator over the MachO::Section.
Definition MachO/Binary.hpp:324
Definition BuildVersion.hpp:34
@ 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:41
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
Base 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 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: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. According 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 returns a ref on container's values given predicates.
Definition iterators.hpp:325
Definition iterators.hpp:599
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:117
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
#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:42
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 returns a const ref on container's values given predicates.
Definition iterators.hpp:591
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:101
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:318
PLATFORMS
Definition platforms.hpp:26
Definition MachO/Binary.hpp:180
bool operator()(const Relocation *lhs, const Relocation *rhs) const
Definition MachO/Binary.hpp:98
uint64_t start
Definition MachO/Binary.hpp:99
uint64_t size() const
Definition MachO/Binary.hpp:102
uint64_t end
Definition MachO/Binary.hpp:100
bool empty() const
Definition MachO/Binary.hpp:106
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46