LLVM 19.0.0git
MachO.h
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/MachO.h - The MachO file format -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines manifest constants for the MachO object file format.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_BINARYFORMAT_MACHO_H
14#define LLVM_BINARYFORMAT_MACHO_H
15
18#include "llvm/Support/Error.h"
20
21namespace llvm {
22
23class Triple;
24
25namespace MachO {
26// Enums from <mach-o/loader.h>
27enum : uint32_t {
28 // Constants for the "magic" field in llvm::MachO::mach_header and
29 // llvm::MachO::mach_header_64
30 MH_MAGIC = 0xFEEDFACEu,
31 MH_CIGAM = 0xCEFAEDFEu,
32 MH_MAGIC_64 = 0xFEEDFACFu,
33 MH_CIGAM_64 = 0xCFFAEDFEu,
34 FAT_MAGIC = 0xCAFEBABEu,
35 FAT_CIGAM = 0xBEBAFECAu,
36 FAT_MAGIC_64 = 0xCAFEBABFu,
37 FAT_CIGAM_64 = 0xBFBAFECAu
38};
39
41 // Constants for the "filetype" field in llvm::MachO::mach_header and
42 // llvm::MachO::mach_header_64
43 MH_OBJECT = 0x1u,
44 MH_EXECUTE = 0x2u,
45 MH_FVMLIB = 0x3u,
46 MH_CORE = 0x4u,
47 MH_PRELOAD = 0x5u,
48 MH_DYLIB = 0x6u,
50 MH_BUNDLE = 0x8u,
52 MH_DSYM = 0xAu,
54 MH_FILESET = 0xCu,
55};
56
57enum {
58 // Constant bits for the "flags" field in llvm::MachO::mach_header and
59 // llvm::MachO::mach_header_64
60 MH_NOUNDEFS = 0x00000001u,
61 MH_INCRLINK = 0x00000002u,
62 MH_DYLDLINK = 0x00000004u,
63 MH_BINDATLOAD = 0x00000008u,
64 MH_PREBOUND = 0x00000010u,
65 MH_SPLIT_SEGS = 0x00000020u,
66 MH_LAZY_INIT = 0x00000040u,
67 MH_TWOLEVEL = 0x00000080u,
68 MH_FORCE_FLAT = 0x00000100u,
69 MH_NOMULTIDEFS = 0x00000200u,
70 MH_NOFIXPREBINDING = 0x00000400u,
71 MH_PREBINDABLE = 0x00000800u,
72 MH_ALLMODSBOUND = 0x00001000u,
74 MH_CANONICAL = 0x00004000u,
75 MH_WEAK_DEFINES = 0x00008000u,
76 MH_BINDS_TO_WEAK = 0x00010000u,
78 MH_ROOT_SAFE = 0x00040000u,
79 MH_SETUID_SAFE = 0x00080000u,
81 MH_PIE = 0x00200000u,
84 MH_NO_HEAP_EXECUTION = 0x01000000u,
85 MH_APP_EXTENSION_SAFE = 0x02000000u,
87 MH_SIM_SUPPORT = 0x08000000u,
88 MH_DYLIB_IN_CACHE = 0x80000000u,
89};
90
91enum : uint32_t {
92 // Flags for the "cmd" field in llvm::MachO::load_command
93 LC_REQ_DYLD = 0x80000000u
94};
95
96#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) LCName = LCValue,
97
99#include "llvm/BinaryFormat/MachO.def"
100};
101
102#undef HANDLE_LOAD_COMMAND
103
104enum : uint32_t {
105 // Constant bits for the "flags" field in llvm::MachO::segment_command
106 SG_HIGHVM = 0x1u,
107 SG_FVMLIB = 0x2u,
111
112 // Constant masks for the "flags" field in llvm::MachO::section and
113 // llvm::MachO::section_64
114 SECTION_TYPE = 0x000000ffu, // SECTION_TYPE
115 SECTION_ATTRIBUTES = 0xffffff00u, // SECTION_ATTRIBUTES
116 SECTION_ATTRIBUTES_USR = 0xff000000u, // SECTION_ATTRIBUTES_USR
117 SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS
119
120/// These are the section type and attributes fields. A MachO section can
121/// have only one Type, but can have any of the attributes specified.
123 // Constant masks for the "flags[7:0]" field in llvm::MachO::section and
124 // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE)
125
126 /// S_REGULAR - Regular section.
127 S_REGULAR = 0x00u,
128 /// S_ZEROFILL - Zero fill on demand section.
129 S_ZEROFILL = 0x01u,
130 /// S_CSTRING_LITERALS - Section with literal C strings.
132 /// S_4BYTE_LITERALS - Section with 4 byte literals.
134 /// S_8BYTE_LITERALS - Section with 8 byte literals.
136 /// S_LITERAL_POINTERS - Section with pointers to literals.
138 /// S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
140 /// S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
142 /// S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in
143 /// the Reserved2 field.
145 /// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for
146 /// initialization.
148 /// S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for
149 /// termination.
151 /// S_COALESCED - Section contains symbols that are to be coalesced.
152 S_COALESCED = 0x0bu,
153 /// S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4
154 /// gigabytes).
156 /// S_INTERPOSING - Section with only pairs of function pointers for
157 /// interposing.
159 /// S_16BYTE_LITERALS - Section with only 16 byte literals.
161 /// S_DTRACE_DOF - Section contains DTrace Object Format.
163 /// S_LAZY_DYLIB_SYMBOL_POINTERS - Section with lazy symbol pointers to
164 /// lazy loaded dylibs.
166 /// S_THREAD_LOCAL_REGULAR - Thread local data section.
168 /// S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
170 /// S_THREAD_LOCAL_VARIABLES - Section with thread local variable
171 /// structure data.
173 /// S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread
174 /// local structures.
176 /// S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local
177 /// variable initialization pointers to functions.
179 /// S_INIT_FUNC_OFFSETS - Section with 32-bit offsets to initializer
180 /// functions.
182
185
186enum : uint32_t {
187 // Constant masks for the "flags[31:24]" field in llvm::MachO::section and
188 // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
189
190 /// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine
191 /// instructions.
193 /// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be
194 /// in a ranlib table of contents.
195 S_ATTR_NO_TOC = 0x40000000u,
196 /// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section
197 /// in files with the MY_DYLDLINK flag.
199 /// S_ATTR_NO_DEAD_STRIP - No dead stripping.
200 S_ATTR_NO_DEAD_STRIP = 0x10000000u,
201 /// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
202 S_ATTR_LIVE_SUPPORT = 0x08000000u,
203 /// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by
204 /// dyld.
206 /// S_ATTR_DEBUG - A debug section.
207 S_ATTR_DEBUG = 0x02000000u,
208
209 // Constant masks for the "flags[23:8]" field in llvm::MachO::section and
210 // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
211
212 /// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
214 /// S_ATTR_EXT_RELOC - Section has external relocation entries.
215 S_ATTR_EXT_RELOC = 0x00000200u,
216 /// S_ATTR_LOC_RELOC - Section has local relocation entries.
217 S_ATTR_LOC_RELOC = 0x00000100u,
218
219 // Constant masks for the value of an indirect symbol in an indirect
220 // symbol table
222 INDIRECT_SYMBOL_ABS = 0x40000000u
224
226 // Constants for the "kind" field in a data_in_code_entry structure
233
239
241
253
259
266
267enum {
270
272 BIND_IMMEDIATE_MASK = 0x0Fu
274
290
291enum {
297
303
304enum {
305 // Constant masks for the "n_type" field in llvm::MachO::nlist and
306 // llvm::MachO::nlist_64
307 N_STAB = 0xe0,
308 N_PEXT = 0x10,
309 N_TYPE = 0x0e,
310 N_EXT = 0x01
312
313enum NListType : uint8_t {
314 // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and
315 // llvm::MachO::nlist_64
316 N_UNDF = 0x0u,
317 N_ABS = 0x2u,
318 N_SECT = 0xeu,
319 N_PBUD = 0xcu,
320 N_INDR = 0xau
322
324 // Constants for the "n_sect" field in llvm::MachO::nlist and
325 // llvm::MachO::nlist_64
327 MAX_SECT = 0xffu
329
330enum {
331 // Constant masks for the "n_desc" field in llvm::MachO::nlist and
332 // llvm::MachO::nlist_64
333 // The low 3 bits are the for the REFERENCE_TYPE.
341 // Flag bits (some overlap with the library ordinal bits).
345 N_WEAK_REF = 0x0040u,
346 N_WEAK_DEF = 0x0080u,
348 N_ALT_ENTRY = 0x0200u,
349 N_COLD_FUNC = 0x0400u,
350 // For undefined symbols coming from libraries, see GET_LIBRARY_ORDINAL()
351 // as these are in the top 8 bits.
355 EXECUTABLE_ORDINAL = 0xff
357
359 // Constant values for the "n_type" field in llvm::MachO::nlist and
360 // llvm::MachO::nlist_64 when "(n_type & N_STAB) != 0"
361 N_GSYM = 0x20u,
362 N_FNAME = 0x22u,
363 N_FUN = 0x24u,
364 N_STSYM = 0x26u,
365 N_LCSYM = 0x28u,
366 N_BNSYM = 0x2Eu,
367 N_PC = 0x30u,
368 N_AST = 0x32u,
369 N_OPT = 0x3Cu,
370 N_RSYM = 0x40u,
371 N_SLINE = 0x44u,
372 N_ENSYM = 0x4Eu,
373 N_SSYM = 0x60u,
374 N_SO = 0x64u,
375 N_OSO = 0x66u,
376 N_LIB = 0x68u,
377 N_LSYM = 0x80u,
378 N_BINCL = 0x82u,
379 N_SOL = 0x84u,
380 N_PARAMS = 0x86u,
381 N_VERSION = 0x88u,
382 N_OLEVEL = 0x8Au,
383 N_PSYM = 0xA0u,
384 N_EINCL = 0xA2u,
385 N_ENTRY = 0xA4u,
386 N_LBRAC = 0xC0u,
387 N_EXCL = 0xC2u,
388 N_RBRAC = 0xE0u,
389 N_BCOMM = 0xE2u,
390 N_ECOMM = 0xE4u,
391 N_ECOML = 0xE8u,
392 N_LENG = 0xFEu
394
395enum : uint32_t {
396 // Constant values for the r_symbolnum field in an
397 // llvm::MachO::relocation_info structure when r_extern is 0.
398 R_ABS = 0,
399
400 // Constant bits for the r_address field in an
401 // llvm::MachO::relocation_info structure.
402 R_SCATTERED = 0x80000000
404
406 // Constant values for the r_type field in an
407 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
408 // structure.
416
417 // Constant values for the r_type field in a PowerPC architecture
418 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
419 // structure.
436
437 // Constant values for the r_type field in an ARM architecture
438 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
439 // structure.
447 ARM_THUMB_32BIT_BRANCH = 7, // obsolete
450
451 // Constant values for the r_type field in an ARM64 architecture
452 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
453 // structure.
454
455 // For pointers.
457 // Must be followed by an ARM64_RELOC_UNSIGNED
459 // A B/BL instruction with 26-bit displacement.
461 // PC-rel distance to page of target.
463 // Offset within page, scaled by r_length.
465 // PC-rel distance to page of GOT slot.
467 // Offset within page of GOT slot, scaled by r_length.
469 // For pointers to GOT slots.
471 // PC-rel distance to page of TLVP slot.
473 // Offset within page of TLVP slot, scaled by r_length.
475 // Must be followed by ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12.
477 // An authenticated pointer.
479
480 // Constant values for the r_type field in an x86_64 architecture
481 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
482 // structure
494
495// Values for segment_command.initprot.
496// From <mach/vm_prot.h>
497enum { VM_PROT_READ = 0x1, VM_PROT_WRITE = 0x2, VM_PROT_EXECUTE = 0x4 };
498
499// Values for platform field in build_version_command.
501#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
502 marketing) \
503 PLATFORM_##platform = id,
504#include "MachO.def"
505};
506
507// Values for tools enum in build_tool_version.
508enum { TOOL_CLANG = 1, TOOL_SWIFT = 2, TOOL_LD = 3, TOOL_LLD = 4 };
509
510// Structs from <mach-o/loader.h>
511
520};
521
531};
532
536};
537
541 char segname[16];
550};
551
555 char segname[16];
564};
565
566struct section {
567 char sectname[16];
568 char segname[16];
578};
579
581 char sectname[16];
582 char segname[16];
593};
594
595inline bool isVirtualSection(uint8_t type) {
596 return (type == MachO::S_ZEROFILL || type == MachO::S_GB_ZEROFILL ||
598}
599
600struct fvmlib {
604};
605
606// The fvmlib_command is obsolete and no longer supported.
611};
612
613struct dylib {
618};
619
623 struct dylib dylib;
624};
625
630};
631
636};
637
642};
643
648};
649
650// The prebound_dylib_command is obsolete and no longer supported.
657};
658
663};
664
668};
669
681};
682
694};
695
703};
704
726};
727
731};
732
747};
748
763};
764
766 uint32_t isym : 24, flags : 8;
767};
768
769// The twolevel_hints_command is obsolete and no longer supported.
775};
776
777// The twolevel_hints_command is obsolete and no longer supported.
780};
781
782// The prebind_cksum_command is obsolete and no longer supported.
787};
788
792 uint8_t uuid[16];
793};
794
799};
800
806};
807
812};
813
818};
819
826};
827
835};
836
838 uint32_t cmd; // LC_VERSION_MIN_MACOSX or
839 // LC_VERSION_MIN_IPHONEOS
840 uint32_t cmdsize; // sizeof(struct version_min_command)
841 uint32_t version; // X.Y.Z is encoded in nibbles xxxx.yy.zz
842 uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz
843};
844
846 uint32_t cmd; // LC_NOTE
847 uint32_t cmdsize; // sizeof(struct note_command)
848 char data_owner[16]; // owner name for this LC_NOTE
849 uint64_t offset; // file offset of this data
850 uint64_t size; // length of data region
851};
852
854 uint32_t tool; // enum for the tool
855 uint32_t version; // version of the tool
856};
857
859 uint32_t cmd; // LC_BUILD_VERSION
860 uint32_t cmdsize; // sizeof(struct build_version_command) +
861 // ntools * sizeof(struct build_tool_version)
862 uint32_t platform; // platform
863 uint32_t minos; // X.Y.Z is encoded in nibbles xxxx.yy.zz
864 uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz
865 uint32_t ntools; // number of tool entries following this
866};
867
872};
873
887};
888
893};
894
895union lc_str {
897};
898
906};
907
908// The symseg_command is obsolete and no longer supported.
914};
915
916// The ident_command is obsolete and no longer supported.
920};
921
922// The fvmfile_command is obsolete and no longer supported.
928};
929
934};
935
940};
941
943 uintptr_t thunk;
944 uintptr_t key;
945 uintptr_t offset;
946};
947
953};
954
955// Structs from <mach-o/fat.h>
959};
960
961struct fat_arch {
967};
968
976};
977
978// Structs from <mach-o/reloc.h>
980 int32_t r_address;
983};
984
986#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
987 uint32_t r_scattered : 1, r_pcrel : 1, r_length : 2, r_type : 4,
988 r_address : 24;
989#else
992#endif
993 int32_t r_value;
994};
995
996// Structs NOT from <mach-o/reloc.h>, but that make LLVM's life easier
999};
1000
1001// Structs from <mach-o/nlist.h>
1004 uint8_t n_type;
1005 uint8_t n_sect;
1007};
1008
1009struct nlist {
1011 uint8_t n_type;
1012 uint8_t n_sect;
1013 int16_t n_desc;
1015};
1016
1017struct nlist_64 {
1019 uint8_t n_type;
1020 uint8_t n_sect;
1023};
1024
1025// Values for dyld_chained_fixups_header::imports_format.
1030};
1031
1032// Values for dyld_chained_fixups_header::symbols_format.
1033enum {
1036};
1037
1038// Values for dyld_chained_starts_in_segment::page_start.
1039enum {
1041 DYLD_CHAINED_PTR_START_MULTI = 0x8000, // page which has multiple starts
1042 DYLD_CHAINED_PTR_START_LAST = 0x8000, // last chain_start for a given page
1043};
1044
1045// Values for dyld_chained_starts_in_segment::pointer_format.
1046enum {
1059};
1060
1061/// Structs for dyld chained fixups.
1062/// dyld_chained_fixups_header is the data pointed to by LC_DYLD_CHAINED_FIXUPS
1063/// load command.
1066 uint32_t starts_offset; ///< Offset of dyld_chained_starts_in_image.
1067 uint32_t imports_offset; ///< Offset of imports table in chain_data.
1068 uint32_t symbols_offset; ///< Offset of symbol strings in chain_data.
1069 uint32_t imports_count; ///< Number of imported symbol names.
1070 uint32_t imports_format; ///< DYLD_CHAINED_IMPORT*
1071 uint32_t symbols_format; ///< 0 => uncompressed, 1 => zlib compressed
1072};
1073
1074/// dyld_chained_starts_in_image is embedded in LC_DYLD_CHAINED_FIXUPS payload.
1075/// Each seg_info_offset entry is the offset into this struct for that
1076/// segment followed by pool of dyld_chain_starts_in_segment data.
1080};
1081
1083 uint32_t size; ///< Size of this, including chain_starts entries
1084 uint16_t page_size; ///< Page size in bytes (0x1000 or 0x4000)
1085 uint16_t pointer_format; ///< DYLD_CHAINED_PTR*
1086 uint64_t segment_offset; ///< VM offset from the __TEXT segment
1087 uint32_t max_valid_pointer; ///< Values beyond this are not pointers on 32-bit
1088 uint16_t page_count; ///< Length of the page_start array
1089 uint16_t page_start[1]; ///< Page offset of first fixup on each page, or
1090 ///< DYLD_CHAINED_PTR_START_NONE if no fixups
1091};
1092
1093// DYLD_CHAINED_IMPORT
1098};
1099
1100// DYLD_CHAINED_IMPORT_ADDEND
1105 int32_t addend;
1106};
1107
1108// DYLD_CHAINED_IMPORT_ADDEND64
1115};
1116
1117// The `bind` field (most significant bit) of the encoded fixup determines
1118// whether it is dyld_chained_ptr_64_bind or dyld_chained_ptr_64_rebase.
1119
1120// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
1126 uint64_t bind : 1; // set to 1
1127};
1128
1129// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
1135 uint64_t bind : 1; // set to 0
1136};
1137
1138// Byte order swapping functions for MachO structs
1139
1140inline void swapStruct(fat_header &mh) {
1143}
1144
1145inline void swapStruct(fat_arch &mh) {
1151}
1152
1153inline void swapStruct(fat_arch_64 &mh) {
1160}
1161
1162inline void swapStruct(mach_header &mh) {
1170}
1171
1173 sys::swapByteOrder(H.magic);
1174 sys::swapByteOrder(H.cputype);
1175 sys::swapByteOrder(H.cpusubtype);
1176 sys::swapByteOrder(H.filetype);
1177 sys::swapByteOrder(H.ncmds);
1178 sys::swapByteOrder(H.sizeofcmds);
1179 sys::swapByteOrder(H.flags);
1180 sys::swapByteOrder(H.reserved);
1181}
1182
1183inline void swapStruct(load_command &lc) {
1186}
1187
1188inline void swapStruct(symtab_command &lc) {
1195}
1196
1208}
1209
1210inline void swapStruct(segment_command &seg) {
1221}
1222
1223inline void swapStruct(section_64 &sect) {
1233}
1234
1235inline void swapStruct(section &sect) {
1245}
1246
1249 sys::swapByteOrder(info.cmdsize);
1250 sys::swapByteOrder(info.rebase_off);
1251 sys::swapByteOrder(info.rebase_size);
1252 sys::swapByteOrder(info.bind_off);
1253 sys::swapByteOrder(info.bind_size);
1254 sys::swapByteOrder(info.weak_bind_off);
1255 sys::swapByteOrder(info.weak_bind_size);
1256 sys::swapByteOrder(info.lazy_bind_off);
1257 sys::swapByteOrder(info.lazy_bind_size);
1258 sys::swapByteOrder(info.export_off);
1259 sys::swapByteOrder(info.export_size);
1260}
1261
1262inline void swapStruct(dylib_command &d) {
1269}
1270
1275}
1276
1281}
1282
1287}
1288
1293}
1294
1306}
1307
1319}
1320
1324}
1325
1330}
1331
1332inline void swapStruct(uuid_command &u) {
1333 sys::swapByteOrder(u.cmd);
1334 sys::swapByteOrder(u.cmdsize);
1335}
1336
1337inline void swapStruct(rpath_command &r) {
1341}
1342
1347}
1348
1350 sys::swapByteOrder(e.cmd);
1351 sys::swapByteOrder(e.cmdsize);
1352 sys::swapByteOrder(e.entryoff);
1353 sys::swapByteOrder(e.stacksize);
1354}
1355
1357 sys::swapByteOrder(e.cmd);
1358 sys::swapByteOrder(e.cmdsize);
1359 sys::swapByteOrder(e.cryptoff);
1360 sys::swapByteOrder(e.cryptsize);
1361 sys::swapByteOrder(e.cryptid);
1362}
1363
1365 sys::swapByteOrder(e.cmd);
1366 sys::swapByteOrder(e.cmdsize);
1367 sys::swapByteOrder(e.cryptoff);
1368 sys::swapByteOrder(e.cryptsize);
1369 sys::swapByteOrder(e.cryptid);
1370 sys::swapByteOrder(e.pad);
1371}
1372
1373inline void swapStruct(dysymtab_command &dst) {
1394}
1395
1396inline void swapStruct(any_relocation_info &reloc) {
1399}
1400
1401inline void swapStruct(nlist_base &S) {
1404}
1405
1406inline void swapStruct(nlist &sym) {
1410}
1411
1412inline void swapStruct(nlist_64 &sym) {
1416}
1417
1419 sys::swapByteOrder(C.cmd);
1420 sys::swapByteOrder(C.cmdsize);
1421 sys::swapByteOrder(C.dataoff);
1422 sys::swapByteOrder(C.datasize);
1423}
1424
1426 sys::swapByteOrder(C.cmd);
1427 sys::swapByteOrder(C.cmdsize);
1428 sys::swapByteOrder(C.count);
1429}
1430
1432 sys::swapByteOrder(C.cmd);
1433 sys::swapByteOrder(C.cmdsize);
1434 sys::swapByteOrder(C.vmaddr);
1435 sys::swapByteOrder(C.fileoff);
1436 sys::swapByteOrder(C.entry_id.offset);
1437 sys::swapByteOrder(C.reserved);
1438}
1439
1441 sys::swapByteOrder(C.cmd);
1442 sys::swapByteOrder(C.cmdsize);
1443 sys::swapByteOrder(C.version);
1444 sys::swapByteOrder(C.sdk);
1445}
1446
1448 sys::swapByteOrder(C.cmd);
1449 sys::swapByteOrder(C.cmdsize);
1450 sys::swapByteOrder(C.offset);
1451 sys::swapByteOrder(C.size);
1452}
1453
1455 sys::swapByteOrder(C.cmd);
1456 sys::swapByteOrder(C.cmdsize);
1457 sys::swapByteOrder(C.platform);
1458 sys::swapByteOrder(C.minos);
1459 sys::swapByteOrder(C.sdk);
1460 sys::swapByteOrder(C.ntools);
1461}
1462
1464 sys::swapByteOrder(C.tool);
1465 sys::swapByteOrder(C.version);
1466}
1467
1469 sys::swapByteOrder(C.offset);
1470 sys::swapByteOrder(C.length);
1471 sys::swapByteOrder(C.kind);
1472}
1473
1475
1476// The prebind_cksum_command is obsolete and no longer supported.
1478 sys::swapByteOrder(C.cmd);
1479 sys::swapByteOrder(C.cmdsize);
1480 sys::swapByteOrder(C.cksum);
1481}
1482
1483// The twolevel_hints_command is obsolete and no longer supported.
1485 sys::swapByteOrder(C.cmd);
1486 sys::swapByteOrder(C.cmdsize);
1487 sys::swapByteOrder(C.offset);
1488 sys::swapByteOrder(C.nhints);
1489}
1490
1491// The prebound_dylib_command is obsolete and no longer supported.
1493 sys::swapByteOrder(C.cmd);
1494 sys::swapByteOrder(C.cmdsize);
1495 sys::swapByteOrder(C.name);
1496 sys::swapByteOrder(C.nmodules);
1497 sys::swapByteOrder(C.linked_modules);
1498}
1499
1500// The fvmfile_command is obsolete and no longer supported.
1502 sys::swapByteOrder(C.cmd);
1503 sys::swapByteOrder(C.cmdsize);
1504 sys::swapByteOrder(C.name);
1505 sys::swapByteOrder(C.header_addr);
1506}
1507
1508// The symseg_command is obsolete and no longer supported.
1510 sys::swapByteOrder(C.cmd);
1511 sys::swapByteOrder(C.cmdsize);
1512 sys::swapByteOrder(C.offset);
1513 sys::swapByteOrder(C.size);
1514}
1515
1516// The ident_command is obsolete and no longer supported.
1518 sys::swapByteOrder(C.cmd);
1519 sys::swapByteOrder(C.cmdsize);
1520}
1521
1522inline void swapStruct(fvmlib &C) {
1523 sys::swapByteOrder(C.name);
1524 sys::swapByteOrder(C.minor_version);
1525 sys::swapByteOrder(C.header_addr);
1526}
1527
1528// The fvmlib_command is obsolete and no longer supported.
1530 sys::swapByteOrder(C.cmd);
1531 sys::swapByteOrder(C.cmdsize);
1532 swapStruct(C.fvmlib);
1533}
1534
1535// Get/Set functions from <mach-o/nlist.h>
1536
1538 return (((n_desc) >> 8u) & 0xffu);
1539}
1540
1541inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) {
1542 n_desc = (((n_desc)&0x00ff) | (((ordinal)&0xff) << 8));
1543}
1544
1545inline uint8_t GET_COMM_ALIGN(uint16_t n_desc) {
1546 return (n_desc >> 8u) & 0x0fu;
1547}
1548
1549inline void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align) {
1550 n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
1551}
1552
1553// Enums from <mach/machine.h>
1554enum : uint32_t {
1555 // Capability bits used in the definition of cpu_type.
1556 CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits
1557 CPU_ARCH_ABI64 = 0x01000000, // 64 bit ABI
1558 CPU_ARCH_ABI64_32 = 0x02000000, // ILP32 ABI on 64-bit hardware
1559};
1560
1561// Constants for the cputype field.
1567 /* CPU_TYPE_MIPS = 8, */
1568 CPU_TYPE_MC98000 = 10, // Old Motorola PowerPC
1576
1577enum : uint32_t {
1578 // Capability bits used in the definition of cpusubtype.
1579 CPU_SUBTYPE_MASK = 0xff000000, // Mask for architecture bits
1580 CPU_SUBTYPE_LIB64 = 0x80000000, // 64 bit libraries
1581
1582 // Special CPU subtype constants.
1585
1586// Constants for the cpusubtype field.
1609
1615inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
1616 return Family | (Model << 4);
1617}
1619 return ((int)ST) & 0x0f;
1620}
1621inline int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST) { return ((int)ST) >> 4; }
1623
1632 // unused ARM_V7F = 10,
1639
1644};
1645
1647
1649
1664
1668
1671
1689};
1690
1713};
1714
1718 x86_FP_PREC_64B = 3
1720
1725 x86_FP_CHOP = 3
1727
1729 unsigned short invalid : 1, denorm : 1, zdiv : 1, ovrfl : 1, undfl : 1,
1730 precis : 1, : 2, pc : 2, rc : 2, : 1, : 3;
1731};
1732
1734 unsigned short invalid : 1, denorm : 1, zdiv : 1, ovrfl : 1, undfl : 1,
1735 precis : 1, stkflt : 1, errsumm : 1, c0 : 1, c1 : 1, c2 : 1, tos : 3,
1736 c3 : 1, busy : 1;
1737};
1738
1740 char mmst_reg[10];
1741 char mmst_rsrv[6];
1742};
1743
1745 char xmm_reg[16];
1746};
1747
1749 int32_t fpu_reserved[2];
1752 uint8_t fpu_ftw;
1753 uint8_t fpu_rsrv1;
1787 char fpu_rsrv4[6 * 16];
1789};
1790
1796};
1797
1799 sys::swapByteOrder(x.eax);
1800 sys::swapByteOrder(x.ebx);
1801 sys::swapByteOrder(x.ecx);
1802 sys::swapByteOrder(x.edx);
1803 sys::swapByteOrder(x.edi);
1804 sys::swapByteOrder(x.esi);
1805 sys::swapByteOrder(x.ebp);
1806 sys::swapByteOrder(x.esp);
1807 sys::swapByteOrder(x.ss);
1808 sys::swapByteOrder(x.eflags);
1809 sys::swapByteOrder(x.eip);
1810 sys::swapByteOrder(x.cs);
1811 sys::swapByteOrder(x.ds);
1812 sys::swapByteOrder(x.es);
1813 sys::swapByteOrder(x.fs);
1814 sys::swapByteOrder(x.gs);
1815}
1816
1818 sys::swapByteOrder(x.rax);
1819 sys::swapByteOrder(x.rbx);
1820 sys::swapByteOrder(x.rcx);
1821 sys::swapByteOrder(x.rdx);
1822 sys::swapByteOrder(x.rdi);
1823 sys::swapByteOrder(x.rsi);
1824 sys::swapByteOrder(x.rbp);
1825 sys::swapByteOrder(x.rsp);
1826 sys::swapByteOrder(x.r8);
1827 sys::swapByteOrder(x.r9);
1828 sys::swapByteOrder(x.r10);
1829 sys::swapByteOrder(x.r11);
1830 sys::swapByteOrder(x.r12);
1831 sys::swapByteOrder(x.r13);
1832 sys::swapByteOrder(x.r14);
1833 sys::swapByteOrder(x.r15);
1834 sys::swapByteOrder(x.rip);
1835 sys::swapByteOrder(x.rflags);
1836 sys::swapByteOrder(x.cs);
1837 sys::swapByteOrder(x.fs);
1838 sys::swapByteOrder(x.gs);
1839}
1840
1842 sys::swapByteOrder(x.fpu_reserved[0]);
1843 sys::swapByteOrder(x.fpu_reserved[1]);
1844 // TODO swap: fp_control_t fpu_fcw;
1845 // TODO swap: fp_status_t fpu_fsw;
1846 sys::swapByteOrder(x.fpu_fop);
1847 sys::swapByteOrder(x.fpu_ip);
1848 sys::swapByteOrder(x.fpu_cs);
1849 sys::swapByteOrder(x.fpu_rsrv2);
1850 sys::swapByteOrder(x.fpu_dp);
1851 sys::swapByteOrder(x.fpu_ds);
1852 sys::swapByteOrder(x.fpu_rsrv3);
1853 sys::swapByteOrder(x.fpu_mxcsr);
1854 sys::swapByteOrder(x.fpu_mxcsrmask);
1855 sys::swapByteOrder(x.fpu_reserved1);
1856}
1857
1859 sys::swapByteOrder(x.trapno);
1860 sys::swapByteOrder(x.cpu);
1861 sys::swapByteOrder(x.err);
1862 sys::swapByteOrder(x.faultvaddr);
1863}
1864
1868};
1869
1872 union {
1876};
1877
1880 union {
1883};
1884
1887 union {
1890};
1891
1893 sys::swapByteOrder(x.flavor);
1894 sys::swapByteOrder(x.count);
1895}
1896
1909 x86_DEBUG_STATE = 12
1911
1913 swapStruct(x.tsh);
1914 if (x.tsh.flavor == x86_THREAD_STATE64)
1915 swapStruct(x.uts.ts64);
1916}
1917
1919 swapStruct(x.fsh);
1920 if (x.fsh.flavor == x86_FLOAT_STATE64)
1921 swapStruct(x.ufs.fs64);
1922}
1923
1925 swapStruct(x.esh);
1926 if (x.esh.flavor == x86_EXCEPTION_STATE64)
1927 swapStruct(x.ues.es64);
1928}
1929
1931 sizeof(x86_thread_state32_t) / sizeof(uint32_t);
1932
1934 sizeof(x86_thread_state64_t) / sizeof(uint32_t);
1936 sizeof(x86_float_state64_t) / sizeof(uint32_t);
1938 sizeof(x86_exception_state64_t) / sizeof(uint32_t);
1939
1941 sizeof(x86_thread_state_t) / sizeof(uint32_t);
1943 sizeof(x86_float_state_t) / sizeof(uint32_t);
1945 sizeof(x86_exception_state_t) / sizeof(uint32_t);
1946
1953};
1954
1956 for (int i = 0; i < 13; i++)
1957 sys::swapByteOrder(x.r[i]);
1958 sys::swapByteOrder(x.sp);
1959 sys::swapByteOrder(x.lr);
1960 sys::swapByteOrder(x.pc);
1961 sys::swapByteOrder(x.cpsr);
1962}
1963
1972};
1973
1975 for (int i = 0; i < 29; i++)
1976 sys::swapByteOrder(x.x[i]);
1977 sys::swapByteOrder(x.fp);
1978 sys::swapByteOrder(x.lr);
1979 sys::swapByteOrder(x.sp);
1980 sys::swapByteOrder(x.pc);
1981 sys::swapByteOrder(x.cpsr);
1982}
1983
1987};
1988
1991 union {
1994};
1995
1997 sys::swapByteOrder(x.flavor);
1998 sys::swapByteOrder(x.count);
1999}
2000
2010
2012 swapStruct(x.tsh);
2013 if (x.tsh.flavor == ARM_THREAD_STATE)
2014 swapStruct(x.uts.ts32);
2015}
2016
2018 sizeof(arm_thread_state32_t) / sizeof(uint32_t);
2019
2021 sizeof(arm_thread_state64_t) / sizeof(uint32_t);
2022
2064};
2065
2067 sys::swapByteOrder(x.srr0);
2068 sys::swapByteOrder(x.srr1);
2069 sys::swapByteOrder(x.r0);
2070 sys::swapByteOrder(x.r1);
2071 sys::swapByteOrder(x.r2);
2072 sys::swapByteOrder(x.r3);
2073 sys::swapByteOrder(x.r4);
2074 sys::swapByteOrder(x.r5);
2075 sys::swapByteOrder(x.r6);
2076 sys::swapByteOrder(x.r7);
2077 sys::swapByteOrder(x.r8);
2078 sys::swapByteOrder(x.r9);
2079 sys::swapByteOrder(x.r10);
2080 sys::swapByteOrder(x.r11);
2081 sys::swapByteOrder(x.r12);
2082 sys::swapByteOrder(x.r13);
2083 sys::swapByteOrder(x.r14);
2084 sys::swapByteOrder(x.r15);
2085 sys::swapByteOrder(x.r16);
2086 sys::swapByteOrder(x.r17);
2087 sys::swapByteOrder(x.r18);
2088 sys::swapByteOrder(x.r19);
2089 sys::swapByteOrder(x.r20);
2090 sys::swapByteOrder(x.r21);
2091 sys::swapByteOrder(x.r22);
2092 sys::swapByteOrder(x.r23);
2093 sys::swapByteOrder(x.r24);
2094 sys::swapByteOrder(x.r25);
2095 sys::swapByteOrder(x.r26);
2096 sys::swapByteOrder(x.r27);
2097 sys::swapByteOrder(x.r28);
2098 sys::swapByteOrder(x.r29);
2099 sys::swapByteOrder(x.r30);
2100 sys::swapByteOrder(x.r31);
2101 sys::swapByteOrder(x.ct);
2102 sys::swapByteOrder(x.xer);
2103 sys::swapByteOrder(x.lr);
2104 sys::swapByteOrder(x.ctr);
2105 sys::swapByteOrder(x.mq);
2106 sys::swapByteOrder(x.vrsave);
2107}
2108
2112};
2113
2116 union {
2119};
2120
2122 sys::swapByteOrder(x.flavor);
2123 sys::swapByteOrder(x.count);
2124}
2125
2135
2137 swapStruct(x.tsh);
2138 if (x.tsh.flavor == PPC_THREAD_STATE)
2139 swapStruct(x.uts.ts32);
2140}
2141
2143 sizeof(ppc_thread_state32_t) / sizeof(uint32_t);
2144
2145// Define a union of all load command structs
2146#define LOAD_COMMAND_STRUCT(LCStruct) LCStruct LCStruct##_data;
2147
2149union alignas(4) macho_load_command {
2150#include "llvm/BinaryFormat/MachO.def"
2151};
2153
2155 sys::swapByteOrder(C.fixups_version);
2156 sys::swapByteOrder(C.starts_offset);
2157 sys::swapByteOrder(C.imports_offset);
2158 sys::swapByteOrder(C.symbols_offset);
2159 sys::swapByteOrder(C.imports_count);
2160 sys::swapByteOrder(C.imports_format);
2161 sys::swapByteOrder(C.symbols_format);
2162}
2163
2165 sys::swapByteOrder(C.seg_count);
2166 // getStructOrErr() cannot copy the variable-length seg_info_offset array.
2167 // Its elements must be byte swapped manually.
2168}
2169
2171 sys::swapByteOrder(C.size);
2172 sys::swapByteOrder(C.page_size);
2173 sys::swapByteOrder(C.pointer_format);
2174 sys::swapByteOrder(C.segment_offset);
2175 sys::swapByteOrder(C.max_valid_pointer);
2176 sys::swapByteOrder(C.page_count);
2177 // seg_info_offset entries must be byte swapped manually.
2178}
2179
2180/* code signing attributes of a process */
2181
2183 CS_VALID = 0x00000001, /* dynamically valid */
2184 CS_ADHOC = 0x00000002, /* ad hoc signed */
2185 CS_GET_TASK_ALLOW = 0x00000004, /* has get-task-allow entitlement */
2186 CS_INSTALLER = 0x00000008, /* has installer entitlement */
2187
2188 CS_FORCED_LV =
2189 0x00000010, /* Library Validation required by Hardened System Policy */
2190 CS_INVALID_ALLOWED = 0x00000020, /* (macOS Only) Page invalidation allowed by
2191 task port policy */
2192
2193 CS_HARD = 0x00000100, /* don't load invalid pages */
2194 CS_KILL = 0x00000200, /* kill process if it becomes invalid */
2195 CS_CHECK_EXPIRATION = 0x00000400, /* force expiration checking */
2196 CS_RESTRICT = 0x00000800, /* tell dyld to treat restricted */
2197
2198 CS_ENFORCEMENT = 0x00001000, /* require enforcement */
2199 CS_REQUIRE_LV = 0x00002000, /* require library validation */
2201 0x00004000, /* code signature permits restricted entitlements */
2203 0x00008000, /* has com.apple.rootless.restricted-nvram-variables.heritable
2204 entitlement */
2205
2206 CS_RUNTIME = 0x00010000, /* Apply hardened runtime policies */
2207 CS_LINKER_SIGNED = 0x00020000, /* Automatically signed by the linker */
2208
2212
2213 CS_EXEC_SET_HARD = 0x00100000, /* set CS_HARD on any exec'ed process */
2214 CS_EXEC_SET_KILL = 0x00200000, /* set CS_KILL on any exec'ed process */
2216 0x00400000, /* set CS_ENFORCEMENT on any exec'ed process */
2218 0x00800000, /* set CS_INSTALLER on any exec'ed process */
2219
2220 CS_KILLED = 0x01000000, /* was killed by kernel for invalidity */
2222 0x02000000, /* dyld used to load this is a platform binary */
2223 CS_PLATFORM_BINARY = 0x04000000, /* this is a platform binary */
2225 0x08000000, /* platform binary by the fact of path (osx only) */
2226
2227 CS_DEBUGGED = 0x10000000, /* process is currently or has previously been
2228 debugged and allowed to run with invalid pages */
2229 CS_SIGNED = 0x20000000, /* process has a signature (may have gone invalid) */
2230 CS_DEV_CODE =
2231 0x40000000, /* code is dev signed, cannot be loaded into prod signed code
2232 (will go away with rdar://problem/28322552) */
2234 0x80000000, /* has Data Vault controller entitlement */
2235
2238};
2239
2240/* executable segment flags */
2241
2243
2244 CS_EXECSEG_MAIN_BINARY = 0x1, /* executable segment denotes main binary */
2245 CS_EXECSEG_ALLOW_UNSIGNED = 0x10, /* allow unsigned pages (for debugging) */
2246 CS_EXECSEG_DEBUGGER = 0x20, /* main binary is debugger */
2247 CS_EXECSEG_JIT = 0x40, /* JIT enabled */
2248 CS_EXECSEG_SKIP_LV = 0x80, /* OBSOLETE: skip library validation */
2249 CS_EXECSEG_CAN_LOAD_CDHASH = 0x100, /* can bless cdhash for execution */
2250 CS_EXECSEG_CAN_EXEC_CDHASH = 0x200, /* can execute blessed cdhash */
2251
2252};
2253
2254/* Magic numbers used by Code Signing */
2255
2257 CSMAGIC_REQUIREMENT = 0xfade0c00, /* single Requirement blob */
2259 0xfade0c01, /* Requirements vector (internal requirements) */
2260 CSMAGIC_CODEDIRECTORY = 0xfade0c02, /* CodeDirectory blob */
2261 CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, /* embedded form of signature data */
2262 CSMAGIC_EMBEDDED_SIGNATURE_OLD = 0xfade0b02, /* XXX */
2263 CSMAGIC_EMBEDDED_ENTITLEMENTS = 0xfade7171, /* embedded entitlements */
2265 0xfade0cc1, /* multi-arch collection of embedded signatures */
2266 CSMAGIC_BLOBWRAPPER = 0xfade0b01, /* CMS Signature, among other things */
2267
2274
2275 CSSLOT_CODEDIRECTORY = 0, /* slot index for CodeDirectory */
2281
2283 0x1000, /* first alternate CodeDirectory, if any */
2284 CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5, /* max number of alternate CD slots */
2287 CSSLOT_ALTERNATE_CODEDIRECTORY_MAX, /* one past the last */
2288
2289 CSSLOT_SIGNATURESLOT = 0x10000, /* CMS Signature */
2292
2293 CSTYPE_INDEX_REQUIREMENTS = 0x00000002, /* compat with amfi */
2294 CSTYPE_INDEX_ENTITLEMENTS = 0x00000005, /* compat with amfi */
2295
2300
2304
2305 CS_CDHASH_LEN = 20, /* always - larger hashes are truncated */
2306 CS_HASH_MAX_SIZE = 48, /* max size of the hash we'll support */
2307
2308 /*
2309 * Currently only to support Legacy VPN plugins, and Mac App Store
2310 * but intended to replace all the various platform code, dev code etc. bits.
2311 */
2315
2319};
2320
2322 uint32_t magic; /* magic number (CSMAGIC_CODEDIRECTORY) */
2323 uint32_t length; /* total length of CodeDirectory blob */
2324 uint32_t version; /* compatibility version */
2325 uint32_t flags; /* setup and mode flags */
2326 uint32_t hashOffset; /* offset of hash slot element at index zero */
2327 uint32_t identOffset; /* offset of identifier string */
2328 uint32_t nSpecialSlots; /* number of special hash slots */
2329 uint32_t nCodeSlots; /* number of ordinary (code) hash slots */
2330 uint32_t codeLimit; /* limit to main image signature range */
2331 uint8_t hashSize; /* size of each hash in bytes */
2332 uint8_t hashType; /* type of hash (cdHashType* constants) */
2333 uint8_t platform; /* platform identifier; zero if not platform binary */
2334 uint8_t pageSize; /* log2(page size in bytes); 0 => infinite */
2335 uint32_t spare2; /* unused (must be zero) */
2336
2337 /* Version 0x20100 */
2338 uint32_t scatterOffset; /* offset of optional scatter vector */
2339
2340 /* Version 0x20200 */
2341 uint32_t teamOffset; /* offset of optional team identifier */
2342
2343 /* Version 0x20300 */
2344 uint32_t spare3; /* unused (must be zero) */
2345 uint64_t codeLimit64; /* limit to main image signature range, 64 bits */
2346
2347 /* Version 0x20400 */
2348 uint64_t execSegBase; /* offset of executable segment */
2349 uint64_t execSegLimit; /* limit of executable segment */
2350 uint64_t execSegFlags; /* executable segment flags */
2351};
2352
2353static_assert(sizeof(CS_CodeDirectory) == 88);
2354
2356 uint32_t type; /* type of entry */
2357 uint32_t offset; /* offset of entry */
2358};
2359
2361 uint32_t magic; /* magic number */
2362 uint32_t length; /* total length of SuperBlob */
2363 uint32_t count; /* number of index entries following */
2364 /* followed by Blobs in no particular order as indicated by index offsets */
2365};
2366
2368 kSecCodeSignatureNoHash = 0, /* null value */
2372 3, /* SHA-256 truncated to first 20 bytes */
2375};
2376
2386};
2387
2388} // end namespace MachO
2389} // end namespace llvm
2390
2391#endif
#define LLVM_PACKED_END
Definition: Compiler.h:431
#define LLVM_PACKED_START
Definition: Compiler.h:430
lazy value info
#define H(x, y, z)
Definition: MD5.cpp:57
Tagged union holding either a T or a Error.
Definition: Error.h:474
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
const uint32_t x86_FLOAT_STATE_COUNT
Definition: MachO.h:1942
ChainedImportFormat
Definition: MachO.h:1026
@ DYLD_CHAINED_IMPORT
Definition: MachO.h:1027
@ DYLD_CHAINED_IMPORT_ADDEND
Definition: MachO.h:1028
@ DYLD_CHAINED_IMPORT_ADDEND64
Definition: MachO.h:1029
@ REBASE_IMMEDIATE_MASK
Definition: MachO.h:240
@ REBASE_OPCODE_MASK
Definition: MachO.h:240
@ R_SCATTERED
Definition: MachO.h:402
const uint32_t ARM_THREAD_STATE64_COUNT
Definition: MachO.h:2020
@ N_OLEVEL
Definition: MachO.h:382
@ N_LCSYM
Definition: MachO.h:365
@ N_EINCL
Definition: MachO.h:384
@ N_LENG
Definition: MachO.h:392
@ N_BINCL
Definition: MachO.h:378
@ N_BCOMM
Definition: MachO.h:389
@ N_SLINE
Definition: MachO.h:371
@ N_ENSYM
Definition: MachO.h:372
@ N_ENTRY
Definition: MachO.h:385
@ N_PARAMS
Definition: MachO.h:380
@ N_ECOMM
Definition: MachO.h:390
@ N_ECOML
Definition: MachO.h:391
@ N_RBRAC
Definition: MachO.h:388
@ N_VERSION
Definition: MachO.h:381
@ N_SSYM
Definition: MachO.h:373
@ N_GSYM
Definition: MachO.h:361
@ N_LSYM
Definition: MachO.h:377
@ N_PSYM
Definition: MachO.h:383
@ N_LBRAC
Definition: MachO.h:386
@ N_EXCL
Definition: MachO.h:387
@ N_FNAME
Definition: MachO.h:362
@ N_RSYM
Definition: MachO.h:370
@ N_STSYM
Definition: MachO.h:364
@ N_BNSYM
Definition: MachO.h:366
ExportSymbolKind
Definition: MachO.h:298
@ EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE
Definition: MachO.h:301
@ EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL
Definition: MachO.h:300
@ EXPORT_SYMBOL_FLAGS_KIND_REGULAR
Definition: MachO.h:299
@ BIND_TYPE_TEXT_PCREL32
Definition: MachO.h:257
@ BIND_TYPE_POINTER
Definition: MachO.h:255
@ BIND_TYPE_TEXT_ABSOLUTE32
Definition: MachO.h:256
CodeSignExecSegFlags
Definition: MachO.h:2242
@ CS_EXECSEG_ALLOW_UNSIGNED
Definition: MachO.h:2245
@ CS_EXECSEG_MAIN_BINARY
Definition: MachO.h:2244
@ CS_EXECSEG_DEBUGGER
Definition: MachO.h:2246
@ CS_EXECSEG_CAN_LOAD_CDHASH
Definition: MachO.h:2249
@ CS_EXECSEG_JIT
Definition: MachO.h:2247
@ CS_EXECSEG_SKIP_LV
Definition: MachO.h:2248
@ CS_EXECSEG_CAN_EXEC_CDHASH
Definition: MachO.h:2250
const uint32_t x86_EXCEPTION_STATE_COUNT
Definition: MachO.h:1944
ARMThreadFlavors
Definition: MachO.h:2001
@ ARM_EXCEPTION_STATE64
Definition: MachO.h:2008
@ ARN_THREAD_STATE_NONE
Definition: MachO.h:2006
@ ARM_THREAD_STATE64
Definition: MachO.h:2007
@ ARM_VFP_STATE
Definition: MachO.h:2003
@ ARM_DEBUG_STATE
Definition: MachO.h:2005
@ ARM_THREAD_STATE
Definition: MachO.h:2002
@ ARM_EXCEPTION_STATE
Definition: MachO.h:2004
CPUSubTypeSPARC
Definition: MachO.h:1648
@ CPU_SUBTYPE_SPARC_ALL
Definition: MachO.h:1648
@ REBASE_TYPE_POINTER
Definition: MachO.h:235
@ REBASE_TYPE_TEXT_ABSOLUTE32
Definition: MachO.h:236
@ REBASE_TYPE_TEXT_PCREL32
Definition: MachO.h:237
CPUSubTypeARM64
Definition: MachO.h:1640
@ CPU_SUBTYPE_ARM64E
Definition: MachO.h:1643
@ CPU_SUBTYPE_ARM64_ALL
Definition: MachO.h:1641
@ CPU_SUBTYPE_ARM64_V8
Definition: MachO.h:1642
@ EXPORT_SYMBOL_FLAGS_REEXPORT
Definition: MachO.h:294
@ EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION
Definition: MachO.h:293
@ EXPORT_SYMBOL_FLAGS_KIND_MASK
Definition: MachO.h:292
@ EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER
Definition: MachO.h:295
x86_fp_control_precis
Definition: MachO.h:1715
@ x86_FP_PREC_64B
Definition: MachO.h:1718
@ x86_FP_PREC_53B
Definition: MachO.h:1717
@ x86_FP_PREC_24B
Definition: MachO.h:1716
@ LC_REQ_DYLD
Definition: MachO.h:93
int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST)
Definition: MachO.h:1621
bool isVirtualSection(uint8_t type)
Definition: MachO.h:595
@ VM_PROT_EXECUTE
Definition: MachO.h:497
@ VM_PROT_READ
Definition: MachO.h:497
@ VM_PROT_WRITE
Definition: MachO.h:497
const uint32_t x86_FLOAT_STATE64_COUNT
Definition: MachO.h:1935
PlatformType
Definition: MachO.h:500
Expected< uint32_t > getCPUSubType(const Triple &T)
Definition: MachO.cpp:95
SectionOrdinal
Definition: MachO.h:323
@ NO_SECT
Definition: MachO.h:326
@ MAX_SECT
Definition: MachO.h:327
HeaderFileType
Definition: MachO.h:40
@ MH_OBJECT
Definition: MachO.h:43
@ MH_DYLINKER
Definition: MachO.h:49
@ MH_CORE
Definition: MachO.h:46
@ MH_PRELOAD
Definition: MachO.h:47
@ MH_DSYM
Definition: MachO.h:52
@ MH_DYLIB
Definition: MachO.h:48
@ MH_DYLIB_STUB
Definition: MachO.h:51
@ MH_KEXT_BUNDLE
Definition: MachO.h:53
@ MH_FVMLIB
Definition: MachO.h:45
@ MH_BUNDLE
Definition: MachO.h:50
@ MH_FILESET
Definition: MachO.h:54
@ MH_EXECUTE
Definition: MachO.h:44
@ DYLD_CHAINED_PTR_32
Definition: MachO.h:1049
@ DYLD_CHAINED_PTR_ARM64E_USERLAND
Definition: MachO.h:1055
@ DYLD_CHAINED_PTR_ARM64E_USERLAND24
Definition: MachO.h:1058
@ DYLD_CHAINED_PTR_64_KERNEL_CACHE
Definition: MachO.h:1054
@ DYLD_CHAINED_PTR_32_CACHE
Definition: MachO.h:1050
@ DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE
Definition: MachO.h:1057
@ DYLD_CHAINED_PTR_64_OFFSET
Definition: MachO.h:1052
@ DYLD_CHAINED_PTR_ARM64E_FIRMWARE
Definition: MachO.h:1056
@ DYLD_CHAINED_PTR_ARM64E_KERNEL
Definition: MachO.h:1053
@ DYLD_CHAINED_PTR_32_FIRMWARE
Definition: MachO.h:1051
@ DYLD_CHAINED_PTR_64
Definition: MachO.h:1048
@ DYLD_CHAINED_PTR_ARM64E
Definition: MachO.h:1047
@ MH_MAGIC
Definition: MachO.h:30
@ MH_CIGAM_64
Definition: MachO.h:33
@ FAT_CIGAM_64
Definition: MachO.h:37
@ MH_CIGAM
Definition: MachO.h:31
@ FAT_CIGAM
Definition: MachO.h:35
@ FAT_MAGIC_64
Definition: MachO.h:36
@ FAT_MAGIC
Definition: MachO.h:34
@ MH_MAGIC_64
Definition: MachO.h:32
SectionType
These are the section type and attributes fields.
Definition: MachO.h:122
@ S_THREAD_LOCAL_VARIABLE_POINTERS
S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.
Definition: MachO.h:175
@ S_INTERPOSING
S_INTERPOSING - Section with only pairs of function pointers for interposing.
Definition: MachO.h:158
@ S_GB_ZEROFILL
S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4 gigabytes).
Definition: MachO.h:155
@ S_16BYTE_LITERALS
S_16BYTE_LITERALS - Section with only 16 byte literals.
Definition: MachO.h:160
@ S_THREAD_LOCAL_INIT_FUNCTION_POINTERS
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local variable initialization pointers to...
Definition: MachO.h:178
@ S_COALESCED
S_COALESCED - Section contains symbols that are to be coalesced.
Definition: MachO.h:152
@ S_THREAD_LOCAL_ZEROFILL
S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
Definition: MachO.h:169
@ S_LAZY_SYMBOL_POINTERS
S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
Definition: MachO.h:141
@ S_INIT_FUNC_OFFSETS
S_INIT_FUNC_OFFSETS - Section with 32-bit offsets to initializer functions.
Definition: MachO.h:181
@ S_MOD_TERM_FUNC_POINTERS
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
Definition: MachO.h:150
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
Definition: MachO.h:147
@ S_CSTRING_LITERALS
S_CSTRING_LITERALS - Section with literal C strings.
Definition: MachO.h:131
@ S_THREAD_LOCAL_REGULAR
S_THREAD_LOCAL_REGULAR - Thread local data section.
Definition: MachO.h:167
@ S_DTRACE_DOF
S_DTRACE_DOF - Section contains DTrace Object Format.
Definition: MachO.h:162
@ S_ZEROFILL
S_ZEROFILL - Zero fill on demand section.
Definition: MachO.h:129
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition: MachO.h:139
@ S_4BYTE_LITERALS
S_4BYTE_LITERALS - Section with 4 byte literals.
Definition: MachO.h:133
@ LAST_KNOWN_SECTION_TYPE
Definition: MachO.h:183
@ S_LITERAL_POINTERS
S_LITERAL_POINTERS - Section with pointers to literals.
Definition: MachO.h:137
@ S_8BYTE_LITERALS
S_8BYTE_LITERALS - Section with 8 byte literals.
Definition: MachO.h:135
@ S_LAZY_DYLIB_SYMBOL_POINTERS
S_LAZY_DYLIB_SYMBOL_POINTERS - Section with lazy symbol pointers to lazy loaded dylibs.
Definition: MachO.h:165
@ S_THREAD_LOCAL_VARIABLES
S_THREAD_LOCAL_VARIABLES - Section with thread local variable structure data.
Definition: MachO.h:172
@ S_SYMBOL_STUBS
S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in the Reserved2 field.
Definition: MachO.h:144
@ S_REGULAR
S_REGULAR - Regular section.
Definition: MachO.h:127
BindSpecialDylib
Definition: MachO.h:260
@ BIND_SPECIAL_DYLIB_SELF
Definition: MachO.h:261
@ BIND_SPECIAL_DYLIB_WEAK_LOOKUP
Definition: MachO.h:264
@ BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE
Definition: MachO.h:262
@ BIND_SPECIAL_DYLIB_FLAT_LOOKUP
Definition: MachO.h:263
@ CSMAGIC_EMBEDDED_ENTITLEMENTS
Definition: MachO.h:2263
@ CSSLOT_SIGNATURESLOT
Definition: MachO.h:2289
@ CS_HASHTYPE_SHA256
Definition: MachO.h:2297
@ CS_SIGNER_TYPE_UNKNOWN
Definition: MachO.h:2312
@ CS_SIGNER_TYPE_LEGACYVPN
Definition: MachO.h:2313
@ CSMAGIC_DETACHED_SIGNATURE
Definition: MachO.h:2264
@ CS_SIGNER_TYPE_MAC_APP_STORE
Definition: MachO.h:2314
@ CS_SUPPORTSRUNTIME
Definition: MachO.h:2272
@ CSSLOT_REQUIREMENTS
Definition: MachO.h:2277
@ CSTYPE_INDEX_ENTITLEMENTS
Definition: MachO.h:2294
@ CSMAGIC_REQUIREMENT
Definition: MachO.h:2257
@ CS_SUPPORTSLINKAGE
Definition: MachO.h:2273
@ CSMAGIC_BLOBWRAPPER
Definition: MachO.h:2266
@ CSSLOT_ENTITLEMENTS
Definition: MachO.h:2280
@ CSMAGIC_EMBEDDED_SIGNATURE
Definition: MachO.h:2261
@ CS_SUPPL_SIGNER_TYPE_TRUSTCACHE
Definition: MachO.h:2317
@ CS_SHA256_LEN
Definition: MachO.h:2302
@ CSSLOT_ALTERNATE_CODEDIRECTORIES
Definition: MachO.h:2282
@ CSSLOT_IDENTIFICATIONSLOT
Definition: MachO.h:2290
@ CS_HASHTYPE_SHA384
Definition: MachO.h:2299
@ CSMAGIC_CODEDIRECTORY
Definition: MachO.h:2260
@ CS_SHA256_TRUNCATED_LEN
Definition: MachO.h:2303
@ CSSLOT_RESOURCEDIR
Definition: MachO.h:2278
@ CSSLOT_APPLICATION
Definition: MachO.h:2279
@ CS_SHA1_LEN
Definition: MachO.h:2301
@ CSSLOT_TICKETSLOT
Definition: MachO.h:2291
@ CSMAGIC_EMBEDDED_SIGNATURE_OLD
Definition: MachO.h:2262
@ CS_HASHTYPE_SHA1
Definition: MachO.h:2296
@ CSTYPE_INDEX_REQUIREMENTS
Definition: MachO.h:2293
@ CSSLOT_ALTERNATE_CODEDIRECTORY_MAX
Definition: MachO.h:2284
@ CS_SUPPORTSTEAMID
Definition: MachO.h:2269
@ CS_SUPPL_SIGNER_TYPE_LOCAL
Definition: MachO.h:2318
@ CS_HASHTYPE_SHA256_TRUNCATED
Definition: MachO.h:2298
@ CS_SUPPORTSSCATTER
Definition: MachO.h:2268
@ CSMAGIC_REQUIREMENTS
Definition: MachO.h:2258
@ CSSLOT_INFOSLOT
Definition: MachO.h:2276
@ CS_SUPPORTSCODELIMIT64
Definition: MachO.h:2270
@ CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT
Definition: MachO.h:2285
@ CSSLOT_CODEDIRECTORY
Definition: MachO.h:2275
@ CS_HASH_MAX_SIZE
Definition: MachO.h:2306
@ CS_SUPPL_SIGNER_TYPE_UNKNOWN
Definition: MachO.h:2316
@ CS_SUPPORTSEXECSEG
Definition: MachO.h:2271
@ CS_CDHASH_LEN
Definition: MachO.h:2305
void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal)
Definition: MachO.h:1541
@ MH_DYLDLINK
Definition: MachO.h:62
@ MH_APP_EXTENSION_SAFE
Definition: MachO.h:85
@ MH_BINDS_TO_WEAK
Definition: MachO.h:76
@ MH_PREBINDABLE
Definition: MachO.h:71
@ MH_CANONICAL
Definition: MachO.h:74
@ MH_PREBOUND
Definition: MachO.h:64
@ MH_ROOT_SAFE
Definition: MachO.h:78
@ MH_BINDATLOAD
Definition: MachO.h:63
@ MH_NO_HEAP_EXECUTION
Definition: MachO.h:84
@ MH_ALLMODSBOUND
Definition: MachO.h:72
@ MH_LAZY_INIT
Definition: MachO.h:66
@ MH_SIM_SUPPORT
Definition: MachO.h:87
@ MH_ALLOW_STACK_EXECUTION
Definition: MachO.h:77
@ MH_INCRLINK
Definition: MachO.h:61
@ MH_PIE
Definition: MachO.h:81
@ MH_SETUID_SAFE
Definition: MachO.h:79
@ MH_FORCE_FLAT
Definition: MachO.h:68
@ MH_WEAK_DEFINES
Definition: MachO.h:75
@ MH_DEAD_STRIPPABLE_DYLIB
Definition: MachO.h:82
@ MH_SPLIT_SEGS
Definition: MachO.h:65
@ MH_NO_REEXPORTED_DYLIBS
Definition: MachO.h:80
@ MH_HAS_TLV_DESCRIPTORS
Definition: MachO.h:83
@ MH_TWOLEVEL
Definition: MachO.h:67
@ MH_NOFIXPREBINDING
Definition: MachO.h:70
@ MH_NOUNDEFS
Definition: MachO.h:60
@ MH_DYLIB_IN_CACHE
Definition: MachO.h:88
@ MH_NOMULTIDEFS
Definition: MachO.h:69
@ MH_SUBSECTIONS_VIA_SYMBOLS
Definition: MachO.h:73
@ MH_NLIST_OUTOFSYNC_WITH_DYLDINFO
Definition: MachO.h:86
int CPU_SUBTYPE_INTEL(int Family, int Model)
Definition: MachO.h:1615
SecCSDigestAlgorithm
Definition: MachO.h:2367
@ kSecCodeSignatureHashSHA1
Definition: MachO.h:2369
@ kSecCodeSignatureHashSHA256
Definition: MachO.h:2370
@ kSecCodeSignatureHashSHA384
Definition: MachO.h:2373
@ kSecCodeSignatureHashSHA256Truncated
Definition: MachO.h:2371
@ kSecCodeSignatureNoHash
Definition: MachO.h:2368
@ kSecCodeSignatureHashSHA512
Definition: MachO.h:2374
uint8_t GET_COMM_ALIGN(uint16_t n_desc)
Definition: MachO.h:1545
void swapStruct(fat_header &mh)
Definition: MachO.h:1140
const uint32_t x86_THREAD_STATE32_COUNT
Definition: MachO.h:1930
PPCThreadFlavors
Definition: MachO.h:2126
@ PPC_THREAD_STATE
Definition: MachO.h:2127
@ PPC_EXCEPTION_STATE
Definition: MachO.h:2129
@ PPC_VECTOR_STATE
Definition: MachO.h:2130
@ PPC_EXCEPTION_STATE64
Definition: MachO.h:2132
@ PPC_THREAD_STATE64
Definition: MachO.h:2131
@ PPC_FLOAT_STATE
Definition: MachO.h:2128
@ PPC_THREAD_STATE_NONE
Definition: MachO.h:2133
@ DYLD_CHAINED_PTR_START_LAST
Definition: MachO.h:1042
@ DYLD_CHAINED_PTR_START_NONE
Definition: MachO.h:1040
@ DYLD_CHAINED_PTR_START_MULTI
Definition: MachO.h:1041
CPUSubTypePowerPC
Definition: MachO.h:1650
@ CPU_SUBTYPE_POWERPC_970
Definition: MachO.h:1663
@ CPU_SUBTYPE_POWERPC_604e
Definition: MachO.h:1658
@ CPU_SUBTYPE_MC98601
Definition: MachO.h:1666
@ CPU_SUBTYPE_POWERPC_603e
Definition: MachO.h:1655
@ CPU_SUBTYPE_POWERPC_7400
Definition: MachO.h:1661
@ CPU_SUBTYPE_POWERPC_604
Definition: MachO.h:1657
@ CPU_SUBTYPE_MC980000_ALL
Definition: MachO.h:1665
@ CPU_SUBTYPE_POWERPC_750
Definition: MachO.h:1660
@ CPU_SUBTYPE_POWERPC_601
Definition: MachO.h:1652
@ CPU_SUBTYPE_POWERPC_620
Definition: MachO.h:1659
@ CPU_SUBTYPE_POWERPC_603ev
Definition: MachO.h:1656
@ CPU_SUBTYPE_POWERPC_ALL
Definition: MachO.h:1651
@ CPU_SUBTYPE_POWERPC_603
Definition: MachO.h:1654
@ CPU_SUBTYPE_POWERPC_7450
Definition: MachO.h:1662
@ CPU_SUBTYPE_POWERPC_602
Definition: MachO.h:1653
@ BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB
Definition: MachO.h:288
@ BIND_OPCODE_DONE
Definition: MachO.h:276
@ BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
Definition: MachO.h:286
@ BIND_OPCODE_SET_ADDEND_SLEB
Definition: MachO.h:282
@ BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB
Definition: MachO.h:278
@ BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
Definition: MachO.h:280
@ BIND_OPCODE_ADD_ADDR_ULEB
Definition: MachO.h:284
@ BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED
Definition: MachO.h:287
@ BIND_OPCODE_SET_DYLIB_SPECIAL_IMM
Definition: MachO.h:279
@ BIND_OPCODE_DO_BIND
Definition: MachO.h:285
@ BIND_OPCODE_SET_TYPE_IMM
Definition: MachO.h:281
@ BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
Definition: MachO.h:277
@ BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
Definition: MachO.h:283
X86ThreadFlavors
Definition: MachO.h:1897
@ x86_FLOAT_STATE32
Definition: MachO.h:1899
@ x86_DEBUG_STATE
Definition: MachO.h:1909
@ x86_THREAD_STATE
Definition: MachO.h:1904
@ x86_THREAD_STATE64
Definition: MachO.h:1901
@ x86_EXCEPTION_STATE64
Definition: MachO.h:1903
@ x86_FLOAT_STATE64
Definition: MachO.h:1902
@ x86_EXCEPTION_STATE
Definition: MachO.h:1906
@ x86_THREAD_STATE32
Definition: MachO.h:1898
@ x86_FLOAT_STATE
Definition: MachO.h:1905
@ x86_DEBUG_STATE64
Definition: MachO.h:1908
@ x86_DEBUG_STATE32
Definition: MachO.h:1907
@ x86_EXCEPTION_STATE32
Definition: MachO.h:1900
@ SG_READ_ONLY
Definition: MachO.h:110
@ SG_FVMLIB
Definition: MachO.h:107
@ SG_PROTECTED_VERSION_1
Definition: MachO.h:109
@ SG_HIGHVM
Definition: MachO.h:106
@ SECTION_ATTRIBUTES
Definition: MachO.h:115
@ SG_NORELOC
Definition: MachO.h:108
@ SECTION_ATTRIBUTES_USR
Definition: MachO.h:116
@ SECTION_ATTRIBUTES_SYS
Definition: MachO.h:117
@ SECTION_TYPE
Definition: MachO.h:114
@ BIND_SYMBOL_FLAGS_WEAK_IMPORT
Definition: MachO.h:268
@ BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION
Definition: MachO.h:269
@ BIND_OPCODE_MASK
Definition: MachO.h:271
@ BIND_IMMEDIATE_MASK
Definition: MachO.h:272
const uint32_t PPC_THREAD_STATE_COUNT
Definition: MachO.h:2142
const uint32_t ARM_THREAD_STATE_COUNT
Definition: MachO.h:2017
@ CPU_SUBTYPE_INTEL_FAMILY_MAX
Definition: MachO.h:1622
@ CPU_SUBTYPE_INTEL_MODEL_ALL
Definition: MachO.h:1622
RebaseOpcode
Definition: MachO.h:242
@ REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
Definition: MachO.h:245
@ REBASE_OPCODE_DO_REBASE_IMM_TIMES
Definition: MachO.h:248
@ REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB
Definition: MachO.h:250
@ REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
Definition: MachO.h:251
@ REBASE_OPCODE_DO_REBASE_ULEB_TIMES
Definition: MachO.h:249
@ REBASE_OPCODE_ADD_ADDR_ULEB
Definition: MachO.h:246
@ REBASE_OPCODE_SET_TYPE_IMM
Definition: MachO.h:244
@ REBASE_OPCODE_DONE
Definition: MachO.h:243
@ REBASE_OPCODE_ADD_ADDR_IMM_SCALED
Definition: MachO.h:247
@ N_SECT
Definition: MachO.h:318
@ N_PBUD
Definition: MachO.h:319
@ N_INDR
Definition: MachO.h:320
@ N_UNDF
Definition: MachO.h:316
@ CPU_ARCH_ABI64
Definition: MachO.h:1557
@ CPU_ARCH_ABI64_32
Definition: MachO.h:1558
@ CPU_ARCH_MASK
Definition: MachO.h:1556
int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST)
Definition: MachO.h:1618
LinkerOptimizationHintKind
Definition: MachO.h:2377
@ LOH_ARM64_ADRP_LDR_GOT_LDR
Definition: MachO.h:2381
@ LOH_ARM64_ADRP_ADRP
Definition: MachO.h:2378
@ LOH_ARM64_ADRP_LDR_GOT_STR
Definition: MachO.h:2383
@ LOH_ARM64_ADRP_ADD_LDR
Definition: MachO.h:2380
@ LOH_ARM64_ADRP_ADD
Definition: MachO.h:2384
@ LOH_ARM64_ADRP_LDR
Definition: MachO.h:2379
@ LOH_ARM64_ADRP_ADD_STR
Definition: MachO.h:2382
@ LOH_ARM64_ADRP_LDR_GOT
Definition: MachO.h:2385
@ TOOL_LLD
Definition: MachO.h:508
@ TOOL_LD
Definition: MachO.h:508
@ TOOL_SWIFT
Definition: MachO.h:508
@ TOOL_CLANG
Definition: MachO.h:508
void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align)
Definition: MachO.h:1549
@ CPU_SUBTYPE_ARM_V7
Definition: MachO.h:1631
@ CPU_SUBTYPE_ARM_V5TEJ
Definition: MachO.h:1629
@ CPU_SUBTYPE_ARM_ALL
Definition: MachO.h:1625
@ CPU_SUBTYPE_ARM_V7M
Definition: MachO.h:1636
@ CPU_SUBTYPE_ARM_V6
Definition: MachO.h:1627
@ CPU_SUBTYPE_ARM_XSCALE
Definition: MachO.h:1630
@ CPU_SUBTYPE_ARM_V7K
Definition: MachO.h:1634
@ CPU_SUBTYPE_ARM_V6M
Definition: MachO.h:1635
@ CPU_SUBTYPE_ARM_V5
Definition: MachO.h:1628
@ CPU_SUBTYPE_ARM_V7EM
Definition: MachO.h:1637
@ CPU_SUBTYPE_ARM_V7S
Definition: MachO.h:1633
@ CPU_SUBTYPE_ARM_V4T
Definition: MachO.h:1626
const uint32_t x86_THREAD_STATE_COUNT
Definition: MachO.h:1940
CPUSubTypeARM64_32
Definition: MachO.h:1646
@ CPU_SUBTYPE_ARM64_32_V8
Definition: MachO.h:1646
@ CS_ENTITLEMENT_FLAGS
Definition: MachO.h:2236
@ CS_CHECK_EXPIRATION
Definition: MachO.h:2195
@ CS_INSTALLER
Definition: MachO.h:2186
@ CS_REQUIRE_LV
Definition: MachO.h:2199
@ CS_LINKER_SIGNED
Definition: MachO.h:2207
@ CS_GET_TASK_ALLOW
Definition: MachO.h:2185
@ CS_VALID
Definition: MachO.h:2183
@ CS_DEBUGGED
Definition: MachO.h:2227
@ CS_PLATFORM_BINARY
Definition: MachO.h:2223
@ CS_DYLD_PLATFORM
Definition: MachO.h:2221
@ CS_ENFORCEMENT
Definition: MachO.h:2198
@ CS_KILLED
Definition: MachO.h:2220
@ CS_INVALID_ALLOWED
Definition: MachO.h:2190
@ CS_DATAVAULT_CONTROLLER
Definition: MachO.h:2233
@ CS_FORCED_LV
Definition: MachO.h:2188
@ CS_DEV_CODE
Definition: MachO.h:2230
@ CS_ADHOC
Definition: MachO.h:2184
@ CS_EXEC_SET_ENFORCEMENT
Definition: MachO.h:2215
@ CS_EXEC_SET_HARD
Definition: MachO.h:2213
@ CS_SIGNED
Definition: MachO.h:2229
@ CS_RESTRICT
Definition: MachO.h:2196
@ CS_EXEC_SET_KILL
Definition: MachO.h:2214
@ CS_RUNTIME
Definition: MachO.h:2206
@ CS_PLATFORM_PATH
Definition: MachO.h:2224
@ CS_EXEC_INHERIT_SIP
Definition: MachO.h:2217
@ CS_NVRAM_UNRESTRICTED
Definition: MachO.h:2202
@ CS_ENTITLEMENTS_VALIDATED
Definition: MachO.h:2200
@ CS_ALLOWED_MACHO
Definition: MachO.h:2209
DataRegionType
Definition: MachO.h:225
@ DICE_KIND_JUMP_TABLE8
Definition: MachO.h:228
@ DICE_KIND_ABS_JUMP_TABLE32
Definition: MachO.h:231
@ DICE_KIND_JUMP_TABLE16
Definition: MachO.h:229
@ DICE_KIND_JUMP_TABLE32
Definition: MachO.h:230
@ DICE_KIND_DATA
Definition: MachO.h:227
RelocationInfoType
Definition: MachO.h:405
@ X86_64_RELOC_UNSIGNED
Definition: MachO.h:483
@ X86_64_RELOC_SIGNED
Definition: MachO.h:484
@ X86_64_RELOC_GOT
Definition: MachO.h:487
@ ARM_RELOC_PAIR
Definition: MachO.h:441
@ GENERIC_RELOC_LOCAL_SECTDIFF
Definition: MachO.h:414
@ ARM_RELOC_BR24
Definition: MachO.h:445
@ PPC_RELOC_PAIR
Definition: MachO.h:421
@ ARM_THUMB_RELOC_BR22
Definition: MachO.h:446
@ PPC_RELOC_SECTDIFF
Definition: MachO.h:428
@ PPC_RELOC_HI16
Definition: MachO.h:424
@ PPC_RELOC_PB_LA_PTR
Definition: MachO.h:429
@ ARM_RELOC_PB_LA_PTR
Definition: MachO.h:444
@ ARM64_RELOC_PAGEOFF12
Definition: MachO.h:464
@ PPC_RELOC_HA16_SECTDIFF
Definition: MachO.h:432
@ ARM_RELOC_LOCAL_SECTDIFF
Definition: MachO.h:443
@ ARM64_RELOC_POINTER_TO_GOT
Definition: MachO.h:470
@ X86_64_RELOC_GOT_LOAD
Definition: MachO.h:486
@ ARM64_RELOC_AUTHENTICATED_POINTER
Definition: MachO.h:478
@ GENERIC_RELOC_PB_LA_PTR
Definition: MachO.h:413
@ X86_64_RELOC_BRANCH
Definition: MachO.h:485
@ X86_64_RELOC_SIGNED_2
Definition: MachO.h:490
@ GENERIC_RELOC_PAIR
Definition: MachO.h:411
@ GENERIC_RELOC_VANILLA
Definition: MachO.h:410
@ X86_64_RELOC_TLV
Definition: MachO.h:492
@ ARM64_RELOC_SUBTRACTOR
Definition: MachO.h:458
@ PPC_RELOC_LOCAL_SECTDIFF
Definition: MachO.h:435
@ ARM_THUMB_32BIT_BRANCH
Definition: MachO.h:447
@ ARM_RELOC_HALF_SECTDIFF
Definition: MachO.h:449
@ PPC_RELOC_JBSR
Definition: MachO.h:433
@ PPC_RELOC_LO14_SECTDIFF
Definition: MachO.h:434
@ GENERIC_RELOC_TLV
Definition: MachO.h:415
@ PPC_RELOC_LO16_SECTDIFF
Definition: MachO.h:431
@ ARM64_RELOC_ADDEND
Definition: MachO.h:476
@ ARM64_RELOC_UNSIGNED
Definition: MachO.h:456
@ ARM_RELOC_SECTDIFF
Definition: MachO.h:442
@ PPC_RELOC_BR24
Definition: MachO.h:423
@ PPC_RELOC_LO16
Definition: MachO.h:425
@ ARM64_RELOC_GOT_LOAD_PAGE21
Definition: MachO.h:466
@ X86_64_RELOC_SIGNED_4
Definition: MachO.h:491
@ GENERIC_RELOC_INVALID
Definition: MachO.h:409
@ PPC_RELOC_HA16
Definition: MachO.h:426
@ GENERIC_RELOC_SECTDIFF
Definition: MachO.h:412
@ X86_64_RELOC_SUBTRACTOR
Definition: MachO.h:488
@ ARM64_RELOC_TLVP_LOAD_PAGEOFF12
Definition: MachO.h:474
@ PPC_RELOC_BR14
Definition: MachO.h:422
@ X86_64_RELOC_SIGNED_1
Definition: MachO.h:489
@ ARM64_RELOC_PAGE21
Definition: MachO.h:462
@ PPC_RELOC_VANILLA
Definition: MachO.h:420
@ PPC_RELOC_HI16_SECTDIFF
Definition: MachO.h:430
@ ARM64_RELOC_GOT_LOAD_PAGEOFF12
Definition: MachO.h:468
@ PPC_RELOC_LO14
Definition: MachO.h:427
@ ARM_RELOC_HALF
Definition: MachO.h:448
@ ARM64_RELOC_TLVP_LOAD_PAGE21
Definition: MachO.h:472
@ ARM_RELOC_VANILLA
Definition: MachO.h:440
@ ARM64_RELOC_BRANCH26
Definition: MachO.h:460
x86_fp_control_rc
Definition: MachO.h:1721
@ x86_FP_RND_UP
Definition: MachO.h:1724
@ x86_FP_RND_DOWN
Definition: MachO.h:1723
@ x86_FP_RND_NEAR
Definition: MachO.h:1722
@ x86_FP_CHOP
Definition: MachO.h:1725
@ CPU_SUBTYPE_LIB64
Definition: MachO.h:1580
@ CPU_SUBTYPE_MULTIPLE
Definition: MachO.h:1583
@ CPU_SUBTYPE_MASK
Definition: MachO.h:1579
uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc)
Definition: MachO.h:1537
LoadCommandType
Definition: MachO.h:98
Expected< uint32_t > getCPUType(const Triple &T)
Definition: MachO.cpp:77
@ S_ATTR_SOME_INSTRUCTIONS
S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
Definition: MachO.h:213
@ S_ATTR_EXT_RELOC
S_ATTR_EXT_RELOC - Section has external relocation entries.
Definition: MachO.h:215
@ S_ATTR_DEBUG
S_ATTR_DEBUG - A debug section.
Definition: MachO.h:207
@ S_ATTR_NO_DEAD_STRIP
S_ATTR_NO_DEAD_STRIP - No dead stripping.
Definition: MachO.h:200
@ S_ATTR_LOC_RELOC
S_ATTR_LOC_RELOC - Section has local relocation entries.
Definition: MachO.h:217
@ S_ATTR_NO_TOC
S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be in a ranlib table of contents.
Definition: MachO.h:195
@ S_ATTR_LIVE_SUPPORT
S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
Definition: MachO.h:202
@ S_ATTR_PURE_INSTRUCTIONS
S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine instructions.
Definition: MachO.h:192
@ S_ATTR_SELF_MODIFYING_CODE
S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by dyld.
Definition: MachO.h:205
@ S_ATTR_STRIP_STATIC_SYMS
S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section in files with the MY_DYLDLINK f...
Definition: MachO.h:198
@ INDIRECT_SYMBOL_ABS
Definition: MachO.h:222
@ INDIRECT_SYMBOL_LOCAL
Definition: MachO.h:221
@ REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY
Definition: MachO.h:339
@ REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY
Definition: MachO.h:340
@ DYNAMIC_LOOKUP_ORDINAL
Definition: MachO.h:354
@ N_COLD_FUNC
Definition: MachO.h:349
@ REFERENCE_FLAG_UNDEFINED_LAZY
Definition: MachO.h:336
@ N_WEAK_DEF
Definition: MachO.h:346
@ EXECUTABLE_ORDINAL
Definition: MachO.h:355
@ REFERENCE_FLAG_UNDEFINED_NON_LAZY
Definition: MachO.h:335
@ REFERENCED_DYNAMICALLY
Definition: MachO.h:343
@ REFERENCE_FLAG_DEFINED
Definition: MachO.h:337
@ N_ARM_THUMB_DEF
Definition: MachO.h:342
@ MAX_LIBRARY_ORDINAL
Definition: MachO.h:353
@ SELF_LIBRARY_ORDINAL
Definition: MachO.h:352
@ N_NO_DEAD_STRIP
Definition: MachO.h:344
@ REFERENCE_TYPE
Definition: MachO.h:334
@ N_SYMBOL_RESOLVER
Definition: MachO.h:347
@ REFERENCE_FLAG_PRIVATE_DEFINED
Definition: MachO.h:338
@ N_ALT_ENTRY
Definition: MachO.h:348
@ N_WEAK_REF
Definition: MachO.h:345
const uint32_t x86_EXCEPTION_STATE64_COUNT
Definition: MachO.h:1937
@ CPU_SUBTYPE_386
Definition: MachO.h:1589
@ CPU_SUBTYPE_586
Definition: MachO.h:1592
@ CPU_SUBTYPE_X86_ALL
Definition: MachO.h:1610
@ CPU_SUBTYPE_CELERON_MOBILE
Definition: MachO.h:1598
@ CPU_SUBTYPE_PENTII_M3
Definition: MachO.h:1595
@ CPU_SUBTYPE_I386_ALL
Definition: MachO.h:1588
@ CPU_SUBTYPE_X86_ARCH1
Definition: MachO.h:1612
@ CPU_SUBTYPE_PENTIUM_3_XEON
Definition: MachO.h:1601
@ CPU_SUBTYPE_ITANIUM_2
Definition: MachO.h:1606
@ CPU_SUBTYPE_PENTII_M5
Definition: MachO.h:1596
@ CPU_SUBTYPE_X86_64_H
Definition: MachO.h:1613
@ CPU_SUBTYPE_PENTIUM_M
Definition: MachO.h:1602
@ CPU_SUBTYPE_PENTIUM_3_M
Definition: MachO.h:1600
@ CPU_SUBTYPE_PENTPRO
Definition: MachO.h:1594
@ CPU_SUBTYPE_486SX
Definition: MachO.h:1591
@ CPU_SUBTYPE_X86_64_ALL
Definition: MachO.h:1611
@ CPU_SUBTYPE_CELERON
Definition: MachO.h:1597
@ CPU_SUBTYPE_ITANIUM
Definition: MachO.h:1605
@ CPU_SUBTYPE_PENTIUM_4_M
Definition: MachO.h:1604
@ CPU_SUBTYPE_PENT
Definition: MachO.h:1593
@ CPU_SUBTYPE_486
Definition: MachO.h:1590
@ CPU_SUBTYPE_PENTIUM_3
Definition: MachO.h:1599
@ CPU_SUBTYPE_PENTIUM_4
Definition: MachO.h:1603
@ CPU_SUBTYPE_XEON
Definition: MachO.h:1607
@ CPU_SUBTYPE_XEON_MP
Definition: MachO.h:1608
const uint32_t x86_THREAD_STATE64_COUNT
Definition: MachO.h:1933
@ CPU_TYPE_ARM64_32
Definition: MachO.h:1571
@ CPU_TYPE_ARM64
Definition: MachO.h:1570
@ CPU_TYPE_ANY
Definition: MachO.h:1563
@ CPU_TYPE_POWERPC
Definition: MachO.h:1573
@ CPU_TYPE_X86_64
Definition: MachO.h:1566
@ CPU_TYPE_POWERPC64
Definition: MachO.h:1574
@ CPU_TYPE_X86
Definition: MachO.h:1564
@ CPU_TYPE_SPARC
Definition: MachO.h:1572
@ CPU_TYPE_I386
Definition: MachO.h:1565
@ CPU_TYPE_MC98000
Definition: MachO.h:1568
@ CPU_TYPE_ARM
Definition: MachO.h:1569
@ N_TYPE
Definition: MachO.h:309
@ N_PEXT
Definition: MachO.h:308
@ N_STAB
Definition: MachO.h:307
@ DYLD_CHAINED_SYMBOL_ZLIB
Definition: MachO.h:1035
@ DYLD_CHAINED_SYMBOL_UNCOMPRESSED
Definition: MachO.h:1034
void swapByteOrder(T &Value)
Definition: SwapByteOrder.h:61
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
union llvm::MachO::arm_thread_state_t::@158 uts
arm_thread_state32_t ts32
Definition: MachO.h:1992
Definition: MachO.h:808
uint16_t length
Definition: MachO.h:810
uint16_t kind
Definition: MachO.h:811
uint32_t offset
Definition: MachO.h:809
Structs for dyld chained fixups.
Definition: MachO.h:1064
uint32_t imports_count
Number of imported symbol names.
Definition: MachO.h:1069
uint32_t imports_format
DYLD_CHAINED_IMPORT*.
Definition: MachO.h:1070
uint32_t imports_offset
Offset of imports table in chain_data.
Definition: MachO.h:1067
uint32_t starts_offset
Offset of dyld_chained_starts_in_image.
Definition: MachO.h:1066
uint32_t symbols_offset
Offset of symbol strings in chain_data.
Definition: MachO.h:1068
uint32_t symbols_format
0 => uncompressed, 1 => zlib compressed
Definition: MachO.h:1071
dyld_chained_starts_in_image is embedded in LC_DYLD_CHAINED_FIXUPS payload.
Definition: MachO.h:1077
uint16_t page_count
Length of the page_start array.
Definition: MachO.h:1088
uint16_t page_size
Page size in bytes (0x1000 or 0x4000)
Definition: MachO.h:1084
uint16_t pointer_format
DYLD_CHAINED_PTR*.
Definition: MachO.h:1085
uint32_t max_valid_pointer
Values beyond this are not pointers on 32-bit.
Definition: MachO.h:1087
uint64_t segment_offset
VM offset from the __TEXT segment.
Definition: MachO.h:1086
uint32_t size
Size of this, including chain_starts entries.
Definition: MachO.h:1083
uint16_t page_start[1]
Page offset of first fixup on each page, or DYLD_CHAINED_PTR_START_NONE if no fixups.
Definition: MachO.h:1089
struct dylib dylib
Definition: MachO.h:623
uint64_t objc_module_info_addr
Definition: MachO.h:762
uint32_t objc_module_info_size
Definition: MachO.h:761
uint32_t objc_module_info_size
Definition: MachO.h:746
uint32_t objc_module_info_addr
Definition: MachO.h:745
uint32_t current_version
Definition: MachO.h:616
uint32_t name
Definition: MachO.h:614
uint32_t compatibility_version
Definition: MachO.h:617
uint32_t timestamp
Definition: MachO.h:615