LLVM 24.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
118};
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
184};
185
186// Constant masks for the "flags[31:24]" field in llvm::MachO::section and
187// llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
188
189/// Section contains only true machine instructions.
190constexpr uint32_t S_ATTR_PURE_INSTRUCTIONS = 0x80000000u;
191/// Section contains coalesced symbols that are not to be in a ranlib table of
192/// contents.
193constexpr uint32_t S_ATTR_NO_TOC = 0x40000000u;
194/// Ok to strip static symbols in this section in files with the MY_DYLDLINK
195/// flag.
196constexpr uint32_t S_ATTR_STRIP_STATIC_SYMS = 0x20000000u;
197/// No dead stripping.
198constexpr uint32_t S_ATTR_NO_DEAD_STRIP = 0x10000000u;
199/// Blocks are live if they reference live blocks.
200constexpr uint32_t S_ATTR_LIVE_SUPPORT = 0x08000000u;
201/// Used with i386 code stubs written on by dyld.
202constexpr uint32_t S_ATTR_SELF_MODIFYING_CODE = 0x04000000u;
203/// A debug section.
204constexpr uint32_t S_ATTR_DEBUG = 0x02000000u;
205
206// Constant masks for the "flags[23:8]" field in llvm::MachO::section and
207// llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
208
209/// Section contains some machine instructions.
210constexpr uint32_t S_ATTR_SOME_INSTRUCTIONS = 0x00000400u;
211/// Section has external relocation entries.
212constexpr uint32_t S_ATTR_EXT_RELOC = 0x00000200u;
213/// Section has local relocation entries.
214constexpr uint32_t S_ATTR_LOC_RELOC = 0x00000100u;
215
216// Constant masks for the value of an indirect symbol in an indirect symbol
217// table.
218constexpr uint32_t INDIRECT_SYMBOL_LOCAL = 0x80000000u;
219constexpr uint32_t INDIRECT_SYMBOL_ABS = 0x40000000u;
220
222 // Constants for the "kind" field in a data_in_code_entry structure
228};
229
235
237
249
255
262
263enum {
266
269};
270
286
287enum {
292};
293
299
300enum {
301 // Constant masks for the "n_type" field in llvm::MachO::nlist and
302 // llvm::MachO::nlist_64
303 N_STAB = 0xe0,
304 N_PEXT = 0x10,
305 N_TYPE = 0x0e,
306 N_EXT = 0x01
307};
308
310 // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and
311 // llvm::MachO::nlist_64
312 N_UNDF = 0x0u,
313 N_ABS = 0x2u,
314 N_SECT = 0xeu,
315 N_PBUD = 0xcu,
316 N_INDR = 0xau
317};
318
320 // Constants for the "n_sect" field in llvm::MachO::nlist and
321 // llvm::MachO::nlist_64
323 MAX_SECT = 0xffu
324};
325
326enum {
327 // Constant masks for the "n_desc" field in llvm::MachO::nlist and
328 // llvm::MachO::nlist_64
329 // The low 3 bits are the for the REFERENCE_TYPE.
337 // Flag bits (some overlap with the library ordinal bits).
341 N_WEAK_REF = 0x0040u,
342 N_WEAK_DEF = 0x0080u,
344 N_ALT_ENTRY = 0x0200u,
345 N_COLD_FUNC = 0x0400u,
346 // For undefined symbols coming from libraries, see GET_LIBRARY_ORDINAL()
347 // as these are in the top 8 bits.
352};
353
355 // Constant values for the "n_type" field in llvm::MachO::nlist and
356 // llvm::MachO::nlist_64 when "(n_type & N_STAB) != 0"
357 N_GSYM = 0x20u,
358 N_FNAME = 0x22u,
359 N_FUN = 0x24u,
360 N_STSYM = 0x26u,
361 N_LCSYM = 0x28u,
362 N_BNSYM = 0x2Eu,
363 N_PC = 0x30u,
364 N_AST = 0x32u,
365 N_OPT = 0x3Cu,
366 N_RSYM = 0x40u,
367 N_SLINE = 0x44u,
368 N_ENSYM = 0x4Eu,
369 N_SSYM = 0x60u,
370 N_SO = 0x64u,
371 N_OSO = 0x66u,
372 N_LIB = 0x68u,
373 N_LSYM = 0x80u,
374 N_BINCL = 0x82u,
375 N_SOL = 0x84u,
376 N_PARAMS = 0x86u,
377 N_VERSION = 0x88u,
378 N_OLEVEL = 0x8Au,
379 N_PSYM = 0xA0u,
380 N_EINCL = 0xA2u,
381 N_ENTRY = 0xA4u,
382 N_LBRAC = 0xC0u,
383 N_EXCL = 0xC2u,
384 N_RBRAC = 0xE0u,
385 N_BCOMM = 0xE2u,
386 N_ECOMM = 0xE4u,
387 N_ECOML = 0xE8u,
388 N_LENG = 0xFEu
389};
390
391enum : uint32_t {
392 // Constant values for the r_symbolnum field in an
393 // llvm::MachO::relocation_info structure when r_extern is 0.
394 R_ABS = 0,
395
396 // Constant bits for the r_address field in an
397 // llvm::MachO::relocation_info structure.
398 R_SCATTERED = 0x80000000
399};
400
402 // Constant values for the r_type field in an
403 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
404 // structure.
412
413 // Constant values for the r_type field in a PowerPC architecture
414 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
415 // structure.
432
433 // Constant values for the r_type field in an ARM architecture
434 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
435 // structure.
443 ARM_THUMB_32BIT_BRANCH = 7, // obsolete
446
447 // Constant values for the r_type field in an ARM64 architecture
448 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
449 // structure.
450
451 // For pointers.
453 // Must be followed by an ARM64_RELOC_UNSIGNED
455 // A B/BL instruction with 26-bit displacement.
457 // PC-rel distance to page of target.
459 // Offset within page, scaled by r_length.
461 // PC-rel distance to page of GOT slot.
463 // Offset within page of GOT slot, scaled by r_length.
465 // For pointers to GOT slots.
467 // PC-rel distance to page of TLVP slot.
469 // Offset within page of TLVP slot, scaled by r_length.
471 // Must be followed by ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12.
473 // An authenticated pointer.
475
476 // For pointers. For example, for a .word directive in assembly
477 // representing a memory location where data is stored:
478 // .word: _bar
480 // Subtractor operand. Must be followed by a RISCV_RELOC_UNSIGNED,
481 // which is the pointer from which to subtract the subtractor. For
482 // example:
483 //
484 // .global _a
485 // .global _b
486 // _a: ...
487 // _b: ...
488 //
489 // .data_region
490 // .word _a - _b
491 // .end_data_region
493 // A jal/j instruction with 21-bit displacement. For example, a
494 // function call:
495 //
496 // _foo:
497 // jal _bar
499 // High 20 bits of pointer. r_pcrel=1 means this is paired with an
500 // AUIPC. r_pcrel=0 means this is paired with a LUI.
502 // An ADDI or LW/SW instruction that requires low 12 bits to be
503 // adjusted. r_pcrel=1 means this is paired with an AUIPC.
504 // r_pcrel=0 means this is paired with a LUI (llvm currently does
505 // not support no-PIC). Note: the compiler places the distance to
506 // the paired AUIPC in the imm12 (e.g. if previous instruction is
507 // the AUIPC, the imm12 is -4 or 0xFFC). NOTE: this mean that the
508 // separation between hi/lo has to fit in (signed) 12 bits. Beyond
509 // 12-bits, the pc-relative offset is not inlined in the imm12, but
510 // it is instead stored in the 24-bits of a RISCV_RELOC_ADDEND
511 // record.
513 // High 20 bits of GOT slot. r_pcrel=1 means this is paired with an
514 // AUIPC. r_pcrel=0 means this is paired with a LUI (the compiler
515 // may emit a @got reloc for a reference to anything outside the
516 // translation unit, then the linker elides the @got if the target
517 // is in range).
519 // Low 12 bits of GOT slot. r_pcrel=1 means this is paired with an
520 // AUIPC. r_pcrel=0 means this is paired with a LUI.
522 // For pointers to GOT slots. To be used by C++ exception handling,
523 // in the Language Specific Data Area (LSDA, __gcc_except_tab
524 // section). Not currently used, but added for completeness.
526 // Adds a static offset to a relocation. Must be followed by
527 // RISCV_RELOC_PCREL_HI, RISCV_RELOC_BRANCH21 or
528 // RISCV_RELOC_LO12. For example, the 16 bytes offset in:
529 //
530 // auipc a0, %pcrel_hi(var+16)
532
533 // Constant values for the r_type field in an x86_64 architecture
534 // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
535 // structure
546};
547
548// Values for segment_command.initprot.
549// From <mach/vm_prot.h>
550enum { VM_PROT_READ = 0x1, VM_PROT_WRITE = 0x2, VM_PROT_EXECUTE = 0x4 };
551
552// Values for platform field in build_version_command.
554#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
555 marketing) \
556 PLATFORM_##platform = id,
557#include "MachO.def"
558};
559
560// Values for tools enum in build_tool_version.
561enum {
567};
568
569// Structs from <mach-o/loader.h>
570
580
591
596
610
624
638
653
654inline bool isVirtualSection(uint8_t type) {
655 return (type == MachO::S_ZEROFILL || type == MachO::S_GB_ZEROFILL ||
657}
658
664
665// The fvmlib_command is obsolete and no longer supported.
671
678
684
690
696
702
708
709// The prebound_dylib_command is obsolete and no longer supported.
717
723
728
741
754
763
786
791
807
823
825 uint32_t isym : 24, flags : 8;
826};
827
828// The twolevel_hints_command is obsolete and no longer supported.
835
836// The twolevel_hints_command is obsolete and no longer supported.
839};
840
841// The prebind_cksum_command is obsolete and no longer supported.
847
853
859
866
872
878
886
895
897 uint32_t cmd; // LC_VERSION_MIN_MACOSX or
898 // LC_VERSION_MIN_IPHONEOS
899 uint32_t cmdsize; // sizeof(struct version_min_command)
900 uint32_t version; // X.Y.Z is encoded in nibbles xxxx.yy.zz
901 uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz
902};
903
905 uint32_t cmd; // LC_NOTE
906 uint32_t cmdsize; // sizeof(struct note_command)
907 char data_owner[16]; // owner name for this LC_NOTE
908 uint64_t offset; // file offset of this data
909 uint64_t size; // length of data region
910};
911
913 uint32_t tool; // enum for the tool
914 uint32_t version; // version of the tool
915};
916
918 uint32_t cmd; // LC_BUILD_VERSION
919 uint32_t cmdsize; // sizeof(struct build_version_command) +
920 // ntools * sizeof(struct build_tool_version)
921 uint32_t platform; // platform
922 uint32_t minos; // X.Y.Z is encoded in nibbles xxxx.yy.zz
923 uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz
924 uint32_t ntools; // number of tool entries following this
925};
926
928 uint32_t cmd; // LC_TARGET_TRIPLE
929 uint32_t cmdsize; // including string
930 uint32_t triple; // target triple string
931};
932
938
953
959
963
972
973// The symseg_command is obsolete and no longer supported.
980
981// The ident_command is obsolete and no longer supported.
986
987// The fvmfile_command is obsolete and no longer supported.
994
1000
1006
1012
1019
1020// Structs from <mach-o/fat.h>
1025
1033
1042
1043// Structs from <mach-o/reloc.h>
1049
1051#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
1052 uint32_t r_scattered : 1, r_pcrel : 1, r_length : 2, r_type : 4,
1053 r_address : 24;
1054#else
1057#endif
1058 int32_t r_value;
1059};
1060
1061// Structs NOT from <mach-o/reloc.h>, but that make LLVM's life easier
1065
1066// Structs from <mach-o/nlist.h>
1073
1081
1089
1090// Values for dyld_chained_fixups_header::imports_format.
1096
1097// Values for dyld_chained_fixups_header::symbols_format.
1098enum {
1101};
1102
1103// Values for dyld_chained_starts_in_segment::page_start.
1104enum {
1106 DYLD_CHAINED_PTR_START_MULTI = 0x8000, // page which has multiple starts
1107 DYLD_CHAINED_PTR_START_LAST = 0x8000, // last chain_start for a given page
1108};
1109
1110// Values for dyld_chained_starts_in_segment::pointer_format.
1111enum {
1124};
1125
1126/// Structs for dyld chained fixups.
1127/// dyld_chained_fixups_header is the data pointed to by LC_DYLD_CHAINED_FIXUPS
1128/// load command.
1131 uint32_t starts_offset; ///< Offset of dyld_chained_starts_in_image.
1132 uint32_t imports_offset; ///< Offset of imports table in chain_data.
1133 uint32_t symbols_offset; ///< Offset of symbol strings in chain_data.
1134 uint32_t imports_count; ///< Number of imported symbol names.
1135 uint32_t imports_format; ///< DYLD_CHAINED_IMPORT*
1136 uint32_t symbols_format; ///< 0 => uncompressed, 1 => zlib compressed
1137};
1138
1139/// dyld_chained_starts_in_image is embedded in LC_DYLD_CHAINED_FIXUPS payload.
1140/// Each seg_info_offset entry is the offset into this struct for that
1141/// segment followed by pool of dyld_chain_starts_in_segment data.
1146
1148 uint32_t size; ///< Size of this, including chain_starts entries
1149 uint16_t page_size; ///< Page size in bytes (0x1000 or 0x4000)
1150 uint16_t pointer_format; ///< DYLD_CHAINED_PTR*
1151 uint64_t segment_offset; ///< VM offset from the __TEXT segment
1152 uint32_t max_valid_pointer; ///< Values beyond this are not pointers on 32-bit
1153 uint16_t page_count; ///< Length of the page_start array
1154 uint16_t page_start[1]; ///< Page offset of first fixup on each page, or
1155 ///< DYLD_CHAINED_PTR_START_NONE if no fixups
1156};
1157
1158// DYLD_CHAINED_IMPORT
1164
1165// DYLD_CHAINED_IMPORT_ADDEND
1172
1173// DYLD_CHAINED_IMPORT_ADDEND64
1181
1182// The `bind` field (most significant bit) of the encoded fixup determines
1183// whether it is dyld_chained_ptr_64_bind or dyld_chained_ptr_64_rebase.
1184
1185// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
1193
1194// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
1202
1203// DYLD_CHAINED_PTR_ARM64E / DYLD_CHAINED_PTR_ARM64E_USERLAND
1207 uint64_t next : 11; // 4 or 8-byte stride
1208 uint64_t bind : 1; // == 0
1209 uint64_t auth : 1; // == 0
1210};
1211
1215 uint64_t addend : 19; // +/-256K
1216 uint64_t next : 11; // 4 or 8-byte stride
1217 uint64_t bind : 1; // == 1
1218 uint64_t auth : 1; // == 0
1219};
1220
1231
1233 uint64_t target : 32; // runtimeOffset
1237 uint64_t next : 11; // 4 or 8-byte stride
1238 uint64_t bind : 1; // == 0
1239 uint64_t auth : 1; // == 1
1240};
1241
1242// DYLD_CHAINED_PTR_ARM64E_USERLAND24: 24-bit ordinal (vs 16) for more imports.
1243// Rebase formats are shared with DYLD_CHAINED_PTR_ARM64E.
1247 uint64_t addend : 19; // +/-256K
1248 uint64_t next : 11; // 8-byte stride
1249 uint64_t bind : 1; // == 1
1250 uint64_t auth : 1; // == 0
1251};
1252
1253// DYLD_CHAINED_PTR_ARM64E_USERLAND24
1264
1265// Byte order swapping functions for MachO structs
1266
1267inline void swapStruct(fat_header &mh) {
1270}
1271
1279
1288
1298
1300 sys::swapByteOrder(H.magic);
1301 sys::swapByteOrder(H.cputype);
1302 sys::swapByteOrder(H.cpusubtype);
1303 sys::swapByteOrder(H.filetype);
1304 sys::swapByteOrder(H.ncmds);
1305 sys::swapByteOrder(H.sizeofcmds);
1306 sys::swapByteOrder(H.flags);
1307 sys::swapByteOrder(H.reserved);
1308}
1309
1310inline void swapStruct(load_command &lc) {
1313}
1314
1323
1336
1349
1361
1373
1376 sys::swapByteOrder(info.cmdsize);
1377 sys::swapByteOrder(info.rebase_off);
1378 sys::swapByteOrder(info.rebase_size);
1379 sys::swapByteOrder(info.bind_off);
1380 sys::swapByteOrder(info.bind_size);
1381 sys::swapByteOrder(info.weak_bind_off);
1382 sys::swapByteOrder(info.weak_bind_size);
1383 sys::swapByteOrder(info.lazy_bind_off);
1384 sys::swapByteOrder(info.lazy_bind_size);
1385 sys::swapByteOrder(info.export_off);
1386 sys::swapByteOrder(info.export_size);
1387}
1388
1397
1403
1409
1415
1421
1434
1447
1452
1458
1459inline void swapStruct(uuid_command &u) {
1460 sys::swapByteOrder(u.cmd);
1461 sys::swapByteOrder(u.cmdsize);
1462}
1463
1469
1475
1477 sys::swapByteOrder(e.cmd);
1478 sys::swapByteOrder(e.cmdsize);
1479 sys::swapByteOrder(e.entryoff);
1480 sys::swapByteOrder(e.stacksize);
1481}
1482
1484 sys::swapByteOrder(e.cmd);
1485 sys::swapByteOrder(e.cmdsize);
1486 sys::swapByteOrder(e.cryptoff);
1487 sys::swapByteOrder(e.cryptsize);
1488 sys::swapByteOrder(e.cryptid);
1489}
1490
1492 sys::swapByteOrder(e.cmd);
1493 sys::swapByteOrder(e.cmdsize);
1494 sys::swapByteOrder(e.cryptoff);
1495 sys::swapByteOrder(e.cryptsize);
1496 sys::swapByteOrder(e.cryptid);
1497 sys::swapByteOrder(e.pad);
1498}
1499
1522
1523inline void swapStruct(any_relocation_info &reloc) {
1526}
1527
1532
1533inline void swapStruct(nlist &sym) {
1537}
1538
1539inline void swapStruct(nlist_64 &sym) {
1543}
1544
1546 sys::swapByteOrder(C.cmd);
1547 sys::swapByteOrder(C.cmdsize);
1548 sys::swapByteOrder(C.dataoff);
1549 sys::swapByteOrder(C.datasize);
1550}
1551
1553 sys::swapByteOrder(C.cmd);
1554 sys::swapByteOrder(C.cmdsize);
1555 sys::swapByteOrder(C.count);
1556}
1557
1559 sys::swapByteOrder(C.cmd);
1560 sys::swapByteOrder(C.cmdsize);
1561 sys::swapByteOrder(C.vmaddr);
1562 sys::swapByteOrder(C.fileoff);
1563 sys::swapByteOrder(C.entry_id.offset);
1564 sys::swapByteOrder(C.reserved);
1565}
1566
1568 sys::swapByteOrder(C.cmd);
1569 sys::swapByteOrder(C.cmdsize);
1570 sys::swapByteOrder(C.version);
1571 sys::swapByteOrder(C.sdk);
1572}
1573
1575 sys::swapByteOrder(C.cmd);
1576 sys::swapByteOrder(C.cmdsize);
1577 sys::swapByteOrder(C.offset);
1578 sys::swapByteOrder(C.size);
1579}
1580
1582 sys::swapByteOrder(C.cmd);
1583 sys::swapByteOrder(C.cmdsize);
1584 sys::swapByteOrder(C.platform);
1585 sys::swapByteOrder(C.minos);
1586 sys::swapByteOrder(C.sdk);
1587 sys::swapByteOrder(C.ntools);
1588}
1589
1591 sys::swapByteOrder(C.cmd);
1592 sys::swapByteOrder(C.cmdsize);
1593 sys::swapByteOrder(C.triple);
1594}
1595
1597 sys::swapByteOrder(C.tool);
1598 sys::swapByteOrder(C.version);
1599}
1600
1602 sys::swapByteOrder(C.offset);
1603 sys::swapByteOrder(C.length);
1604 sys::swapByteOrder(C.kind);
1605}
1606
1608
1609// The prebind_cksum_command is obsolete and no longer supported.
1611 sys::swapByteOrder(C.cmd);
1612 sys::swapByteOrder(C.cmdsize);
1613 sys::swapByteOrder(C.cksum);
1614}
1615
1616// The twolevel_hints_command is obsolete and no longer supported.
1618 sys::swapByteOrder(C.cmd);
1619 sys::swapByteOrder(C.cmdsize);
1620 sys::swapByteOrder(C.offset);
1621 sys::swapByteOrder(C.nhints);
1622}
1623
1624// The prebound_dylib_command is obsolete and no longer supported.
1626 sys::swapByteOrder(C.cmd);
1627 sys::swapByteOrder(C.cmdsize);
1628 sys::swapByteOrder(C.name);
1629 sys::swapByteOrder(C.nmodules);
1630 sys::swapByteOrder(C.linked_modules);
1631}
1632
1633// The fvmfile_command is obsolete and no longer supported.
1635 sys::swapByteOrder(C.cmd);
1636 sys::swapByteOrder(C.cmdsize);
1637 sys::swapByteOrder(C.name);
1638 sys::swapByteOrder(C.header_addr);
1639}
1640
1641// The symseg_command is obsolete and no longer supported.
1643 sys::swapByteOrder(C.cmd);
1644 sys::swapByteOrder(C.cmdsize);
1645 sys::swapByteOrder(C.offset);
1646 sys::swapByteOrder(C.size);
1647}
1648
1649// The ident_command is obsolete and no longer supported.
1651 sys::swapByteOrder(C.cmd);
1652 sys::swapByteOrder(C.cmdsize);
1653}
1654
1655inline void swapStruct(fvmlib &C) {
1656 sys::swapByteOrder(C.name);
1657 sys::swapByteOrder(C.minor_version);
1658 sys::swapByteOrder(C.header_addr);
1659}
1660
1661// The fvmlib_command is obsolete and no longer supported.
1663 sys::swapByteOrder(C.cmd);
1664 sys::swapByteOrder(C.cmdsize);
1665 swapStruct(C.fvmlib);
1666}
1667
1668// Get/Set functions from <mach-o/nlist.h>
1669
1671 return (((n_desc) >> 8u) & 0xffu);
1672}
1673
1674inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) {
1675 n_desc = (((n_desc)&0x00ff) | (((ordinal)&0xff) << 8));
1676}
1677
1679 return (n_desc >> 8u) & 0x0fu;
1680}
1681
1682inline void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align) {
1683 n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
1684}
1685
1686// Enums from <mach/machine.h>
1687enum : uint32_t {
1688 // Capability bits used in the definition of cpu_type.
1689 CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits
1690 CPU_ARCH_ABI64 = 0x01000000, // 64 bit ABI
1691 CPU_ARCH_ABI64_32 = 0x02000000, // ILP32 ABI on 64-bit hardware
1692};
1693
1694// Constants for the cputype field.
1711
1712enum : uint32_t {
1713 // Capability bits used in the definition of cpusubtype.
1714 CPU_SUBTYPE_MASK = 0xff000000, // Mask for architecture bits
1715 CPU_SUBTYPE_LIB64 = 0x80000000, // 64 bit libraries
1716
1717 // Special CPU subtype constants.
1719};
1720
1721// Constants for the cpusubtype field.
1750inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
1751 return Family | (Model << 4);
1752}
1754 return ((int)ST) & 0x0f;
1755}
1756inline int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST) { return ((int)ST) >> 4; }
1758
1777
1783
1784 // arm64e uses the capability bits to encode ptrauth ABI information.
1785 // Bit 63 marks the binary as Versioned.
1787 // Bit 62 marks the binary as using a kernel ABI.
1789 // Bits [59:56] hold the 4-bit ptrauth ABI version.
1791};
1792
1794 return (ST & CPU_SUBTYPE_ARM64E_PTRAUTH_MASK) >> 24;
1795}
1796
1797inline uint32_t
1799 bool PtrAuthKernelABIVersion) {
1800 assert((PtrAuthABIVersion <= 0xF) &&
1801 "ptrauth abi version must fit in 4 bits");
1803 (PtrAuthKernelABIVersion
1805 : 0) |
1806 (PtrAuthABIVersion << 24);
1807}
1808
1812
1816
1818
1820
1839
1843
1847 unsigned PtrAuthABIVersion,
1848 bool PtrAuthKernelABIVersion);
1849
1868
1892
1898
1905
1907 unsigned short invalid : 1, denorm : 1, zdiv : 1, ovrfl : 1, undfl : 1,
1908 precis : 1, : 2, pc : 2, rc : 2, : 1, : 3;
1909};
1910
1912 unsigned short invalid : 1, denorm : 1, zdiv : 1, ovrfl : 1, undfl : 1,
1913 precis : 1, stkflt : 1, errsumm : 1, c0 : 1, c1 : 1, c2 : 1, tos : 3,
1914 c3 : 1, busy : 1;
1915};
1916
1918 char mmst_reg[10];
1919 char mmst_rsrv[6];
1920};
1921
1923 char xmm_reg[16];
1924};
1925
1968
1975
1977 sys::swapByteOrder(x.eax);
1978 sys::swapByteOrder(x.ebx);
1979 sys::swapByteOrder(x.ecx);
1980 sys::swapByteOrder(x.edx);
1981 sys::swapByteOrder(x.edi);
1982 sys::swapByteOrder(x.esi);
1983 sys::swapByteOrder(x.ebp);
1984 sys::swapByteOrder(x.esp);
1985 sys::swapByteOrder(x.ss);
1986 sys::swapByteOrder(x.eflags);
1987 sys::swapByteOrder(x.eip);
1988 sys::swapByteOrder(x.cs);
1989 sys::swapByteOrder(x.ds);
1990 sys::swapByteOrder(x.es);
1991 sys::swapByteOrder(x.fs);
1992 sys::swapByteOrder(x.gs);
1993}
1994
1996 sys::swapByteOrder(x.rax);
1997 sys::swapByteOrder(x.rbx);
1998 sys::swapByteOrder(x.rcx);
1999 sys::swapByteOrder(x.rdx);
2000 sys::swapByteOrder(x.rdi);
2001 sys::swapByteOrder(x.rsi);
2002 sys::swapByteOrder(x.rbp);
2003 sys::swapByteOrder(x.rsp);
2004 sys::swapByteOrder(x.r8);
2005 sys::swapByteOrder(x.r9);
2006 sys::swapByteOrder(x.r10);
2007 sys::swapByteOrder(x.r11);
2008 sys::swapByteOrder(x.r12);
2009 sys::swapByteOrder(x.r13);
2010 sys::swapByteOrder(x.r14);
2011 sys::swapByteOrder(x.r15);
2012 sys::swapByteOrder(x.rip);
2013 sys::swapByteOrder(x.rflags);
2014 sys::swapByteOrder(x.cs);
2015 sys::swapByteOrder(x.fs);
2016 sys::swapByteOrder(x.gs);
2017}
2018
2020 sys::swapByteOrder(x.fpu_reserved[0]);
2021 sys::swapByteOrder(x.fpu_reserved[1]);
2022 // TODO swap: fp_control_t fpu_fcw;
2023 // TODO swap: fp_status_t fpu_fsw;
2024 sys::swapByteOrder(x.fpu_fop);
2025 sys::swapByteOrder(x.fpu_ip);
2026 sys::swapByteOrder(x.fpu_cs);
2027 sys::swapByteOrder(x.fpu_rsrv2);
2028 sys::swapByteOrder(x.fpu_dp);
2029 sys::swapByteOrder(x.fpu_ds);
2030 sys::swapByteOrder(x.fpu_rsrv3);
2031 sys::swapByteOrder(x.fpu_mxcsr);
2032 sys::swapByteOrder(x.fpu_mxcsrmask);
2033 sys::swapByteOrder(x.fpu_reserved1);
2034}
2035
2037 sys::swapByteOrder(x.trapno);
2038 sys::swapByteOrder(x.cpu);
2039 sys::swapByteOrder(x.err);
2040 sys::swapByteOrder(x.faultvaddr);
2041}
2042
2047
2055
2062
2069
2071 sys::swapByteOrder(x.flavor);
2072 sys::swapByteOrder(x.count);
2073}
2074
2089
2091 swapStruct(x.tsh);
2092 if (x.tsh.flavor == x86_THREAD_STATE64)
2093 swapStruct(x.uts.ts64);
2094}
2095
2097 swapStruct(x.fsh);
2098 if (x.fsh.flavor == x86_FLOAT_STATE64)
2099 swapStruct(x.ufs.fs64);
2100}
2101
2103 swapStruct(x.esh);
2104 if (x.esh.flavor == x86_EXCEPTION_STATE64)
2105 swapStruct(x.ues.es64);
2106}
2107
2109 sizeof(x86_thread_state32_t) / sizeof(uint32_t);
2110
2112 sizeof(x86_thread_state64_t) / sizeof(uint32_t);
2114 sizeof(x86_float_state64_t) / sizeof(uint32_t);
2116 sizeof(x86_exception_state64_t) / sizeof(uint32_t);
2117
2119 sizeof(x86_thread_state_t) / sizeof(uint32_t);
2121 sizeof(x86_float_state_t) / sizeof(uint32_t);
2123 sizeof(x86_exception_state_t) / sizeof(uint32_t);
2124
2132
2134 for (int i = 0; i < 13; i++)
2135 sys::swapByteOrder(x.r[i]);
2136 sys::swapByteOrder(x.sp);
2137 sys::swapByteOrder(x.lr);
2138 sys::swapByteOrder(x.pc);
2139 sys::swapByteOrder(x.cpsr);
2140}
2141
2151
2153 for (int i = 0; i < 29; i++)
2154 sys::swapByteOrder(x.x[i]);
2155 sys::swapByteOrder(x.fp);
2156 sys::swapByteOrder(x.lr);
2157 sys::swapByteOrder(x.sp);
2158 sys::swapByteOrder(x.pc);
2159 sys::swapByteOrder(x.cpsr);
2160}
2161
2166
2173
2175 sys::swapByteOrder(x.flavor);
2176 sys::swapByteOrder(x.count);
2177}
2178
2188
2190 swapStruct(x.tsh);
2191 if (x.tsh.flavor == ARM_THREAD_STATE)
2192 swapStruct(x.uts.ts32);
2193}
2194
2196 sizeof(arm_thread_state32_t) / sizeof(uint32_t);
2197
2199 sizeof(arm_thread_state64_t) / sizeof(uint32_t);
2200
2243
2245 sys::swapByteOrder(x.srr0);
2246 sys::swapByteOrder(x.srr1);
2247 sys::swapByteOrder(x.r0);
2248 sys::swapByteOrder(x.r1);
2249 sys::swapByteOrder(x.r2);
2250 sys::swapByteOrder(x.r3);
2251 sys::swapByteOrder(x.r4);
2252 sys::swapByteOrder(x.r5);
2253 sys::swapByteOrder(x.r6);
2254 sys::swapByteOrder(x.r7);
2255 sys::swapByteOrder(x.r8);
2256 sys::swapByteOrder(x.r9);
2257 sys::swapByteOrder(x.r10);
2258 sys::swapByteOrder(x.r11);
2259 sys::swapByteOrder(x.r12);
2260 sys::swapByteOrder(x.r13);
2261 sys::swapByteOrder(x.r14);
2262 sys::swapByteOrder(x.r15);
2263 sys::swapByteOrder(x.r16);
2264 sys::swapByteOrder(x.r17);
2265 sys::swapByteOrder(x.r18);
2266 sys::swapByteOrder(x.r19);
2267 sys::swapByteOrder(x.r20);
2268 sys::swapByteOrder(x.r21);
2269 sys::swapByteOrder(x.r22);
2270 sys::swapByteOrder(x.r23);
2271 sys::swapByteOrder(x.r24);
2272 sys::swapByteOrder(x.r25);
2273 sys::swapByteOrder(x.r26);
2274 sys::swapByteOrder(x.r27);
2275 sys::swapByteOrder(x.r28);
2276 sys::swapByteOrder(x.r29);
2277 sys::swapByteOrder(x.r30);
2278 sys::swapByteOrder(x.r31);
2279 sys::swapByteOrder(x.ct);
2280 sys::swapByteOrder(x.xer);
2281 sys::swapByteOrder(x.lr);
2282 sys::swapByteOrder(x.ctr);
2283 sys::swapByteOrder(x.mq);
2284 sys::swapByteOrder(x.vrsave);
2285}
2286
2291
2298
2300 sys::swapByteOrder(x.flavor);
2301 sys::swapByteOrder(x.count);
2302}
2303
2313
2315 swapStruct(x.tsh);
2316 if (x.tsh.flavor == PPC_THREAD_STATE)
2317 swapStruct(x.uts.ts32);
2318}
2319
2321 sizeof(ppc_thread_state32_t) / sizeof(uint32_t);
2322
2323// Define a union of all load command structs
2324#define LOAD_COMMAND_STRUCT(LCStruct) LCStruct LCStruct##_data;
2325
2327union alignas(4) macho_load_command {
2328#include "llvm/BinaryFormat/MachO.def"
2329};
2331
2333 sys::swapByteOrder(C.fixups_version);
2334 sys::swapByteOrder(C.starts_offset);
2335 sys::swapByteOrder(C.imports_offset);
2336 sys::swapByteOrder(C.symbols_offset);
2337 sys::swapByteOrder(C.imports_count);
2338 sys::swapByteOrder(C.imports_format);
2339 sys::swapByteOrder(C.symbols_format);
2340}
2341
2343 sys::swapByteOrder(C.seg_count);
2344 // getStructOrErr() cannot copy the variable-length seg_info_offset array.
2345 // Its elements must be byte swapped manually.
2346}
2347
2349 sys::swapByteOrder(C.size);
2350 sys::swapByteOrder(C.page_size);
2351 sys::swapByteOrder(C.pointer_format);
2352 sys::swapByteOrder(C.segment_offset);
2353 sys::swapByteOrder(C.max_valid_pointer);
2354 sys::swapByteOrder(C.page_count);
2355 // seg_info_offset entries must be byte swapped manually.
2356}
2357
2358/* code signing attributes of a process */
2359
2361 CS_VALID = 0x00000001, /* dynamically valid */
2362 CS_ADHOC = 0x00000002, /* ad hoc signed */
2363 CS_GET_TASK_ALLOW = 0x00000004, /* has get-task-allow entitlement */
2364 CS_INSTALLER = 0x00000008, /* has installer entitlement */
2365
2367 0x00000010, /* Library Validation required by Hardened System Policy */
2368 CS_INVALID_ALLOWED = 0x00000020, /* (macOS Only) Page invalidation allowed by
2369 task port policy */
2370
2371 CS_HARD = 0x00000100, /* don't load invalid pages */
2372 CS_KILL = 0x00000200, /* kill process if it becomes invalid */
2373 CS_CHECK_EXPIRATION = 0x00000400, /* force expiration checking */
2374 CS_RESTRICT = 0x00000800, /* tell dyld to treat restricted */
2375
2376 CS_ENFORCEMENT = 0x00001000, /* require enforcement */
2377 CS_REQUIRE_LV = 0x00002000, /* require library validation */
2379 0x00004000, /* code signature permits restricted entitlements */
2381 0x00008000, /* has com.apple.rootless.restricted-nvram-variables.heritable
2382 entitlement */
2383
2384 CS_RUNTIME = 0x00010000, /* Apply hardened runtime policies */
2385 CS_LINKER_SIGNED = 0x00020000, /* Automatically signed by the linker */
2386
2390
2391 CS_EXEC_SET_HARD = 0x00100000, /* set CS_HARD on any exec'ed process */
2392 CS_EXEC_SET_KILL = 0x00200000, /* set CS_KILL on any exec'ed process */
2394 0x00400000, /* set CS_ENFORCEMENT on any exec'ed process */
2396 0x00800000, /* set CS_INSTALLER on any exec'ed process */
2397
2398 CS_KILLED = 0x01000000, /* was killed by kernel for invalidity */
2400 0x02000000, /* dyld used to load this is a platform binary */
2401 CS_PLATFORM_BINARY = 0x04000000, /* this is a platform binary */
2403 0x08000000, /* platform binary by the fact of path (osx only) */
2404
2405 CS_DEBUGGED = 0x10000000, /* process is currently or has previously been
2406 debugged and allowed to run with invalid pages */
2407 CS_SIGNED = 0x20000000, /* process has a signature (may have gone invalid) */
2409 0x40000000, /* code is dev signed, cannot be loaded into prod signed code
2410 (will go away with rdar://problem/28322552) */
2412 0x80000000, /* has Data Vault controller entitlement */
2413
2416};
2417
2418/* executable segment flags */
2419
2421
2422 CS_EXECSEG_MAIN_BINARY = 0x1, /* executable segment denotes main binary */
2423 CS_EXECSEG_ALLOW_UNSIGNED = 0x10, /* allow unsigned pages (for debugging) */
2424 CS_EXECSEG_DEBUGGER = 0x20, /* main binary is debugger */
2425 CS_EXECSEG_JIT = 0x40, /* JIT enabled */
2426 CS_EXECSEG_SKIP_LV = 0x80, /* OBSOLETE: skip library validation */
2427 CS_EXECSEG_CAN_LOAD_CDHASH = 0x100, /* can bless cdhash for execution */
2428 CS_EXECSEG_CAN_EXEC_CDHASH = 0x200, /* can execute blessed cdhash */
2429
2430};
2431
2432/* Magic numbers used by Code Signing */
2433
2435 CSMAGIC_REQUIREMENT = 0xfade0c00, /* single Requirement blob */
2437 0xfade0c01, /* Requirements vector (internal requirements) */
2438 CSMAGIC_CODEDIRECTORY = 0xfade0c02, /* CodeDirectory blob */
2439 CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, /* embedded form of signature data */
2440 CSMAGIC_EMBEDDED_SIGNATURE_OLD = 0xfade0b02, /* XXX */
2441 CSMAGIC_EMBEDDED_ENTITLEMENTS = 0xfade7171, /* embedded entitlements */
2443 0xfade0cc1, /* multi-arch collection of embedded signatures */
2444 CSMAGIC_BLOBWRAPPER = 0xfade0b01, /* CMS Signature, among other things */
2445
2452
2453 CSSLOT_CODEDIRECTORY = 0, /* slot index for CodeDirectory */
2459
2461 0x1000, /* first alternate CodeDirectory, if any */
2462 CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5, /* max number of alternate CD slots */
2465 CSSLOT_ALTERNATE_CODEDIRECTORY_MAX, /* one past the last */
2466
2467 CSSLOT_SIGNATURESLOT = 0x10000, /* CMS Signature */
2470
2471 CSTYPE_INDEX_REQUIREMENTS = 0x00000002, /* compat with amfi */
2472 CSTYPE_INDEX_ENTITLEMENTS = 0x00000005, /* compat with amfi */
2473
2478
2482
2483 CS_CDHASH_LEN = 20, /* always - larger hashes are truncated */
2484 CS_HASH_MAX_SIZE = 48, /* max size of the hash we'll support */
2485
2486 /*
2487 * Currently only to support Legacy VPN plugins, and Mac App Store
2488 * but intended to replace all the various platform code, dev code etc. bits.
2489 */
2493
2497};
2498
2500 uint32_t magic; /* magic number (CSMAGIC_CODEDIRECTORY) */
2501 uint32_t length; /* total length of CodeDirectory blob */
2502 uint32_t version; /* compatibility version */
2503 uint32_t flags; /* setup and mode flags */
2504 uint32_t hashOffset; /* offset of hash slot element at index zero */
2505 uint32_t identOffset; /* offset of identifier string */
2506 uint32_t nSpecialSlots; /* number of special hash slots */
2507 uint32_t nCodeSlots; /* number of ordinary (code) hash slots */
2508 uint32_t codeLimit; /* limit to main image signature range */
2509 uint8_t hashSize; /* size of each hash in bytes */
2510 uint8_t hashType; /* type of hash (cdHashType* constants) */
2511 uint8_t platform; /* platform identifier; zero if not platform binary */
2512 uint8_t pageSize; /* log2(page size in bytes); 0 => infinite */
2513 uint32_t spare2; /* unused (must be zero) */
2514
2515 /* Version 0x20100 */
2516 uint32_t scatterOffset; /* offset of optional scatter vector */
2517
2518 /* Version 0x20200 */
2519 uint32_t teamOffset; /* offset of optional team identifier */
2520
2521 /* Version 0x20300 */
2522 uint32_t spare3; /* unused (must be zero) */
2523 uint64_t codeLimit64; /* limit to main image signature range, 64 bits */
2524
2525 /* Version 0x20400 */
2526 uint64_t execSegBase; /* offset of executable segment */
2527 uint64_t execSegLimit; /* limit of executable segment */
2528 uint64_t execSegFlags; /* executable segment flags */
2529};
2530
2531static_assert(sizeof(CS_CodeDirectory) == 88);
2532
2534 uint32_t type; /* type of entry */
2535 uint32_t offset; /* offset of entry */
2536};
2537
2539 uint32_t magic; /* magic number */
2540 uint32_t length; /* total length of SuperBlob */
2541 uint32_t count; /* number of index entries following */
2542 /* followed by Blobs in no particular order as indicated by index offsets */
2543};
2544
2546 kSecCodeSignatureNoHash = 0, /* null value */
2550 3, /* SHA-256 truncated to first 20 bytes */
2553};
2554
2565
2566} // end namespace MachO
2567} // end namespace llvm
2568
2569#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:211
#define LLVM_PACKED_START
Definition Compiler.h:583
static uint64_t align(uint64_t Size)
lazy value info
#define H(x, y, z)
Definition MD5.cpp:56
#define T
Tagged union holding either a T or a Error.
Definition Error.h:485
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
const uint32_t x86_FLOAT_STATE_COUNT
Definition MachO.h:2120
@ 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
ChainedImportFormat
Definition MachO.h:1091
@ DYLD_CHAINED_IMPORT
Definition MachO.h:1092
@ DYLD_CHAINED_IMPORT_ADDEND
Definition MachO.h:1093
@ DYLD_CHAINED_IMPORT_ADDEND64
Definition MachO.h:1094
@ R_SCATTERED
Definition MachO.h:398
@ TOOL_DSYMUTIL
Definition MachO.h:566
@ TOOL_SWIFT
Definition MachO.h:563
@ TOOL_CLANG
Definition MachO.h:562
const uint32_t ARM_THREAD_STATE64_COUNT
Definition MachO.h:2198
@ N_VERSION
Definition MachO.h:377
ExportSymbolKind
Definition MachO.h:294
@ EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE
Definition MachO.h:297
@ EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL
Definition MachO.h:296
@ EXPORT_SYMBOL_FLAGS_KIND_REGULAR
Definition MachO.h:295
constexpr uint32_t S_ATTR_EXT_RELOC
Section has external relocation entries.
Definition MachO.h:212
@ BIND_TYPE_TEXT_PCREL32
Definition MachO.h:253
@ BIND_TYPE_POINTER
Definition MachO.h:251
@ BIND_TYPE_TEXT_ABSOLUTE32
Definition MachO.h:252
CodeSignExecSegFlags
Definition MachO.h:2420
@ CS_EXECSEG_ALLOW_UNSIGNED
Definition MachO.h:2423
@ CS_EXECSEG_MAIN_BINARY
Definition MachO.h:2422
@ CS_EXECSEG_DEBUGGER
Definition MachO.h:2424
@ CS_EXECSEG_CAN_LOAD_CDHASH
Definition MachO.h:2427
@ CS_EXECSEG_JIT
Definition MachO.h:2425
@ CS_EXECSEG_SKIP_LV
Definition MachO.h:2426
@ CS_EXECSEG_CAN_EXEC_CDHASH
Definition MachO.h:2428
const uint32_t x86_EXCEPTION_STATE_COUNT
Definition MachO.h:2122
@ ARM_EXCEPTION_STATE64
Definition MachO.h:2186
@ ARN_THREAD_STATE_NONE
Definition MachO.h:2184
@ ARM_THREAD_STATE64
Definition MachO.h:2185
@ ARM_VFP_STATE
Definition MachO.h:2181
@ ARM_DEBUG_STATE
Definition MachO.h:2183
@ ARM_THREAD_STATE
Definition MachO.h:2180
@ ARM_EXCEPTION_STATE
Definition MachO.h:2182
@ CPU_SUBTYPE_SPARC_ALL
Definition MachO.h:1819
@ REBASE_TYPE_POINTER
Definition MachO.h:231
@ REBASE_TYPE_TEXT_ABSOLUTE32
Definition MachO.h:232
@ REBASE_TYPE_TEXT_PCREL32
Definition MachO.h:233
x86_fp_control_precis
Definition MachO.h:1893
@ x86_FP_PREC_64B
Definition MachO.h:1896
@ x86_FP_PREC_53B
Definition MachO.h:1895
@ x86_FP_PREC_24B
Definition MachO.h:1894
int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST)
Definition MachO.h:1756
bool isVirtualSection(uint8_t type)
Definition MachO.h:654
constexpr uint32_t S_ATTR_NO_DEAD_STRIP
No dead stripping.
Definition MachO.h:198
const uint32_t x86_FLOAT_STATE64_COUNT
Definition MachO.h:2113
LLVM_ABI Expected< uint32_t > getCPUSubType(const Triple &T)
Definition MachO.cpp:109
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
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:256
@ BIND_SPECIAL_DYLIB_SELF
Definition MachO.h:257
@ BIND_SPECIAL_DYLIB_WEAK_LOOKUP
Definition MachO.h:260
@ BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE
Definition MachO.h:258
@ BIND_SPECIAL_DYLIB_FLAT_LOOKUP
Definition MachO.h:259
@ 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_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
constexpr uint32_t S_ATTR_SOME_INSTRUCTIONS
Section contains some machine instructions.
Definition MachO.h:210
@ CSMAGIC_EMBEDDED_ENTITLEMENTS
Definition MachO.h:2441
@ CSSLOT_SIGNATURESLOT
Definition MachO.h:2467
@ CS_HASHTYPE_SHA256
Definition MachO.h:2475
@ CS_SIGNER_TYPE_UNKNOWN
Definition MachO.h:2490
@ CS_SIGNER_TYPE_LEGACYVPN
Definition MachO.h:2491
@ CSMAGIC_DETACHED_SIGNATURE
Definition MachO.h:2442
@ CS_SIGNER_TYPE_MAC_APP_STORE
Definition MachO.h:2492
@ CS_SUPPORTSRUNTIME
Definition MachO.h:2450
@ CSSLOT_REQUIREMENTS
Definition MachO.h:2455
@ CSTYPE_INDEX_ENTITLEMENTS
Definition MachO.h:2472
@ CSMAGIC_REQUIREMENT
Definition MachO.h:2435
@ CS_SUPPORTSLINKAGE
Definition MachO.h:2451
@ CSMAGIC_BLOBWRAPPER
Definition MachO.h:2444
@ CSSLOT_ENTITLEMENTS
Definition MachO.h:2458
@ CSMAGIC_EMBEDDED_SIGNATURE
Definition MachO.h:2439
@ CS_SUPPL_SIGNER_TYPE_TRUSTCACHE
Definition MachO.h:2495
@ CS_SHA256_LEN
Definition MachO.h:2480
@ CSSLOT_ALTERNATE_CODEDIRECTORIES
Definition MachO.h:2460
@ CSSLOT_IDENTIFICATIONSLOT
Definition MachO.h:2468
@ CS_HASHTYPE_SHA384
Definition MachO.h:2477
@ CSMAGIC_CODEDIRECTORY
Definition MachO.h:2438
@ CS_SHA256_TRUNCATED_LEN
Definition MachO.h:2481
@ CSSLOT_RESOURCEDIR
Definition MachO.h:2456
@ CSSLOT_APPLICATION
Definition MachO.h:2457
@ CS_SHA1_LEN
Definition MachO.h:2479
@ CSSLOT_TICKETSLOT
Definition MachO.h:2469
@ CSMAGIC_EMBEDDED_SIGNATURE_OLD
Definition MachO.h:2440
@ CS_HASHTYPE_SHA1
Definition MachO.h:2474
@ CSTYPE_INDEX_REQUIREMENTS
Definition MachO.h:2471
@ CSSLOT_ALTERNATE_CODEDIRECTORY_MAX
Definition MachO.h:2462
@ CS_SUPPORTSTEAMID
Definition MachO.h:2447
@ CS_SUPPL_SIGNER_TYPE_LOCAL
Definition MachO.h:2496
@ CS_HASHTYPE_SHA256_TRUNCATED
Definition MachO.h:2476
@ CS_SUPPORTSSCATTER
Definition MachO.h:2446
@ CSMAGIC_REQUIREMENTS
Definition MachO.h:2436
@ CSSLOT_INFOSLOT
Definition MachO.h:2454
@ CS_SUPPORTSCODELIMIT64
Definition MachO.h:2448
@ CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT
Definition MachO.h:2463
@ CSSLOT_CODEDIRECTORY
Definition MachO.h:2453
@ CS_HASH_MAX_SIZE
Definition MachO.h:2484
@ CS_SUPPL_SIGNER_TYPE_UNKNOWN
Definition MachO.h:2494
@ CS_SUPPORTSEXECSEG
Definition MachO.h:2449
@ CS_CDHASH_LEN
Definition MachO.h:2483
void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal)
Definition MachO.h:1674
int CPU_SUBTYPE_INTEL(int Family, int Model)
Definition MachO.h:1750
@ BIND_SYMBOL_FLAGS_WEAK_IMPORT
Definition MachO.h:264
@ BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION
Definition MachO.h:265
@ BIND_OPCODE_MASK
Definition MachO.h:267
@ BIND_IMMEDIATE_MASK
Definition MachO.h:268
SecCSDigestAlgorithm
Definition MachO.h:2545
@ kSecCodeSignatureHashSHA1
Definition MachO.h:2547
@ kSecCodeSignatureHashSHA256
Definition MachO.h:2548
@ kSecCodeSignatureHashSHA384
Definition MachO.h:2551
@ kSecCodeSignatureHashSHA256Truncated
Definition MachO.h:2549
@ kSecCodeSignatureNoHash
Definition MachO.h:2546
@ kSecCodeSignatureHashSHA512
Definition MachO.h:2552
@ DYLD_CHAINED_PTR_32
Definition MachO.h:1114
@ DYLD_CHAINED_PTR_ARM64E_USERLAND
Definition MachO.h:1120
@ DYLD_CHAINED_PTR_ARM64E_USERLAND24
Definition MachO.h:1123
@ DYLD_CHAINED_PTR_64_KERNEL_CACHE
Definition MachO.h:1119
@ DYLD_CHAINED_PTR_32_CACHE
Definition MachO.h:1115
@ DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE
Definition MachO.h:1122
@ DYLD_CHAINED_PTR_64_OFFSET
Definition MachO.h:1117
@ DYLD_CHAINED_PTR_ARM64E_FIRMWARE
Definition MachO.h:1121
@ DYLD_CHAINED_PTR_ARM64E_KERNEL
Definition MachO.h:1118
@ DYLD_CHAINED_PTR_32_FIRMWARE
Definition MachO.h:1116
@ DYLD_CHAINED_PTR_64
Definition MachO.h:1113
@ DYLD_CHAINED_PTR_ARM64E
Definition MachO.h:1112
uint8_t GET_COMM_ALIGN(uint16_t n_desc)
Definition MachO.h:1678
void swapStruct(fat_header &mh)
Definition MachO.h:1267
@ REBASE_IMMEDIATE_MASK
Definition MachO.h:236
@ REBASE_OPCODE_MASK
Definition MachO.h:236
@ LC_REQ_DYLD
Definition MachO.h:93
const uint32_t x86_THREAD_STATE32_COUNT
Definition MachO.h:2108
constexpr uint32_t INDIRECT_SYMBOL_ABS
Definition MachO.h:219
@ EXPORT_SYMBOL_FLAGS_REEXPORT
Definition MachO.h:290
@ EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION
Definition MachO.h:289
@ EXPORT_SYMBOL_FLAGS_KIND_MASK
Definition MachO.h:288
@ EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER
Definition MachO.h:291
@ PPC_THREAD_STATE
Definition MachO.h:2305
@ PPC_EXCEPTION_STATE
Definition MachO.h:2307
@ PPC_VECTOR_STATE
Definition MachO.h:2308
@ PPC_EXCEPTION_STATE64
Definition MachO.h:2310
@ PPC_THREAD_STATE64
Definition MachO.h:2309
@ PPC_FLOAT_STATE
Definition MachO.h:2306
@ PPC_THREAD_STATE_NONE
Definition MachO.h:2311
bool CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(uint32_t ST)
Definition MachO.h:1813
@ DYLD_CHAINED_PTR_START_LAST
Definition MachO.h:1107
@ DYLD_CHAINED_PTR_START_NONE
Definition MachO.h:1105
@ DYLD_CHAINED_PTR_START_MULTI
Definition MachO.h:1106
CPUSubTypePowerPC
Definition MachO.h:1821
@ CPU_SUBTYPE_POWERPC_970
Definition MachO.h:1834
@ CPU_SUBTYPE_POWERPC_604e
Definition MachO.h:1829
@ CPU_SUBTYPE_MC98601
Definition MachO.h:1837
@ CPU_SUBTYPE_POWERPC_603e
Definition MachO.h:1826
@ CPU_SUBTYPE_POWERPC_7400
Definition MachO.h:1832
@ CPU_SUBTYPE_POWERPC_604
Definition MachO.h:1828
@ CPU_SUBTYPE_MC980000_ALL
Definition MachO.h:1836
@ CPU_SUBTYPE_POWERPC_750
Definition MachO.h:1831
@ CPU_SUBTYPE_POWERPC_601
Definition MachO.h:1823
@ CPU_SUBTYPE_POWERPC_620
Definition MachO.h:1830
@ CPU_SUBTYPE_POWERPC_603ev
Definition MachO.h:1827
@ CPU_SUBTYPE_POWERPC_ALL
Definition MachO.h:1822
@ CPU_SUBTYPE_POWERPC_603
Definition MachO.h:1825
@ CPU_SUBTYPE_POWERPC_7450
Definition MachO.h:1833
@ CPU_SUBTYPE_POWERPC_602
Definition MachO.h:1824
@ BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB
Definition MachO.h:284
@ BIND_OPCODE_DONE
Definition MachO.h:272
@ BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
Definition MachO.h:282
@ BIND_OPCODE_SET_ADDEND_SLEB
Definition MachO.h:278
@ BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB
Definition MachO.h:274
@ BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
Definition MachO.h:276
@ BIND_OPCODE_ADD_ADDR_ULEB
Definition MachO.h:280
@ BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED
Definition MachO.h:283
@ BIND_OPCODE_SET_DYLIB_SPECIAL_IMM
Definition MachO.h:275
@ BIND_OPCODE_DO_BIND
Definition MachO.h:281
@ BIND_OPCODE_SET_TYPE_IMM
Definition MachO.h:277
@ BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
Definition MachO.h:273
@ BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
Definition MachO.h:279
@ x86_FLOAT_STATE32
Definition MachO.h:2077
@ x86_DEBUG_STATE
Definition MachO.h:2087
@ x86_THREAD_STATE
Definition MachO.h:2082
@ x86_THREAD_STATE64
Definition MachO.h:2079
@ x86_EXCEPTION_STATE64
Definition MachO.h:2081
@ x86_FLOAT_STATE64
Definition MachO.h:2080
@ x86_EXCEPTION_STATE
Definition MachO.h:2084
@ x86_THREAD_STATE32
Definition MachO.h:2076
@ x86_FLOAT_STATE
Definition MachO.h:2083
@ x86_DEBUG_STATE64
Definition MachO.h:2086
@ x86_DEBUG_STATE32
Definition MachO.h:2085
@ x86_EXCEPTION_STATE32
Definition MachO.h:2078
constexpr uint32_t S_ATTR_STRIP_STATIC_SYMS
Ok to strip static symbols in this section in files with the MY_DYLDLINK flag.
Definition MachO.h:196
@ DYLD_CHAINED_SYMBOL_ZLIB
Definition MachO.h:1100
@ DYLD_CHAINED_SYMBOL_UNCOMPRESSED
Definition MachO.h:1099
const uint32_t PPC_THREAD_STATE_COUNT
Definition MachO.h:2320
@ 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
unsigned CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(uint32_t ST)
Definition MachO.h:1793
constexpr uint32_t S_ATTR_DEBUG
A debug section.
Definition MachO.h:204
constexpr uint32_t INDIRECT_SYMBOL_LOCAL
Definition MachO.h:218
const uint32_t ARM_THREAD_STATE_COUNT
Definition MachO.h:2195
@ REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
Definition MachO.h:241
@ REBASE_OPCODE_DO_REBASE_IMM_TIMES
Definition MachO.h:244
@ REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB
Definition MachO.h:246
@ REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
Definition MachO.h:247
@ REBASE_OPCODE_DO_REBASE_ULEB_TIMES
Definition MachO.h:245
@ REBASE_OPCODE_ADD_ADDR_ULEB
Definition MachO.h:242
@ REBASE_OPCODE_SET_TYPE_IMM
Definition MachO.h:240
@ REBASE_OPCODE_DONE
Definition MachO.h:239
@ REBASE_OPCODE_ADD_ADDR_IMM_SCALED
Definition MachO.h:243
constexpr uint32_t S_ATTR_PURE_INSTRUCTIONS
Section contains only true machine instructions.
Definition MachO.h:190
@ CPU_SUBTYPE_LIB64
Definition MachO.h:1715
@ CPU_SUBTYPE_MULTIPLE
Definition MachO.h:1718
@ CPU_SUBTYPE_MASK
Definition MachO.h:1714
@ CPU_SUBTYPE_RISCV_ALL
Definition MachO.h:1841
bool CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(uint32_t ST)
Definition MachO.h:1809
int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST)
Definition MachO.h:1753
LinkerOptimizationHintKind
Definition MachO.h:2555
@ LOH_ARM64_ADRP_LDR_GOT_LDR
Definition MachO.h:2559
@ LOH_ARM64_ADRP_ADRP
Definition MachO.h:2556
@ LOH_ARM64_ADRP_LDR_GOT_STR
Definition MachO.h:2561
@ LOH_ARM64_ADRP_ADD_LDR
Definition MachO.h:2558
@ LOH_ARM64_ADRP_ADD
Definition MachO.h:2562
@ LOH_ARM64_ADRP_LDR
Definition MachO.h:2557
@ LOH_ARM64_ADRP_ADD_STR
Definition MachO.h:2560
@ LOH_ARM64_ADRP_LDR_GOT
Definition MachO.h:2563
@ VM_PROT_EXECUTE
Definition MachO.h:550
@ VM_PROT_READ
Definition MachO.h:550
@ VM_PROT_WRITE
Definition MachO.h:550
constexpr uint32_t S_ATTR_LIVE_SUPPORT
Blocks are live if they reference live blocks.
Definition MachO.h:200
constexpr uint32_t S_ATTR_NO_TOC
Section contains coalesced symbols that are not to be in a ranlib table of contents.
Definition MachO.h:193
void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align)
Definition MachO.h:1682
@ CPU_SUBTYPE_ARM_V7
Definition MachO.h:1766
@ CPU_SUBTYPE_ARM_V8M_BASE
Definition MachO.h:1774
@ CPU_SUBTYPE_ARM_V5TEJ
Definition MachO.h:1764
@ CPU_SUBTYPE_ARM_ALL
Definition MachO.h:1760
@ CPU_SUBTYPE_ARM_V7M
Definition MachO.h:1771
@ CPU_SUBTYPE_ARM_V6
Definition MachO.h:1762
@ CPU_SUBTYPE_ARM_V8M_MAIN
Definition MachO.h:1773
@ CPU_SUBTYPE_ARM_XSCALE
Definition MachO.h:1765
@ CPU_SUBTYPE_ARM_V7K
Definition MachO.h:1769
@ CPU_SUBTYPE_ARM_V6M
Definition MachO.h:1770
@ CPU_SUBTYPE_ARM_V5
Definition MachO.h:1763
@ CPU_SUBTYPE_ARM_V7EM
Definition MachO.h:1772
@ CPU_SUBTYPE_ARM_V8_1M_MAIN
Definition MachO.h:1775
@ CPU_SUBTYPE_ARM_V7S
Definition MachO.h:1768
@ CPU_SUBTYPE_ARM_V4T
Definition MachO.h:1761
@ CPU_SUBTYPE_ARM64E
Definition MachO.h:1781
@ CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK
Definition MachO.h:1786
@ CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK
Definition MachO.h:1788
@ CPU_SUBTYPE_ARM64_ALL
Definition MachO.h:1779
@ CPU_SUBTYPE_ARM64E_PTRAUTH_MASK
Definition MachO.h:1790
@ CPU_SUBTYPE_ARM64E_X1
Definition MachO.h:1782
@ CPU_SUBTYPE_ARM64_V8
Definition MachO.h:1780
const uint32_t x86_THREAD_STATE_COUNT
Definition MachO.h:2118
CPUSubTypeARM64_32
Definition MachO.h:1817
@ CPU_SUBTYPE_ARM64_32_V8
Definition MachO.h:1817
@ CS_ENTITLEMENT_FLAGS
Definition MachO.h:2414
@ CS_CHECK_EXPIRATION
Definition MachO.h:2373
@ CS_INSTALLER
Definition MachO.h:2364
@ CS_REQUIRE_LV
Definition MachO.h:2377
@ CS_LINKER_SIGNED
Definition MachO.h:2385
@ CS_GET_TASK_ALLOW
Definition MachO.h:2363
@ CS_DEBUGGED
Definition MachO.h:2405
@ CS_PLATFORM_BINARY
Definition MachO.h:2401
@ CS_DYLD_PLATFORM
Definition MachO.h:2399
@ CS_ENFORCEMENT
Definition MachO.h:2376
@ CS_INVALID_ALLOWED
Definition MachO.h:2368
@ CS_DATAVAULT_CONTROLLER
Definition MachO.h:2411
@ CS_FORCED_LV
Definition MachO.h:2366
@ CS_DEV_CODE
Definition MachO.h:2408
@ CS_EXEC_SET_ENFORCEMENT
Definition MachO.h:2393
@ CS_EXEC_SET_HARD
Definition MachO.h:2391
@ CS_RESTRICT
Definition MachO.h:2374
@ CS_EXEC_SET_KILL
Definition MachO.h:2392
@ CS_PLATFORM_PATH
Definition MachO.h:2402
@ CS_EXEC_INHERIT_SIP
Definition MachO.h:2395
@ CS_NVRAM_UNRESTRICTED
Definition MachO.h:2380
@ CS_ENTITLEMENTS_VALIDATED
Definition MachO.h:2378
@ CS_ALLOWED_MACHO
Definition MachO.h:2387
@ DICE_KIND_JUMP_TABLE8
Definition MachO.h:224
@ DICE_KIND_ABS_JUMP_TABLE32
Definition MachO.h:227
@ DICE_KIND_JUMP_TABLE16
Definition MachO.h:225
@ DICE_KIND_JUMP_TABLE32
Definition MachO.h:226
@ DICE_KIND_DATA
Definition MachO.h:223
@ CPU_SUBTYPE_INTEL_FAMILY_MAX
Definition MachO.h:1757
@ CPU_SUBTYPE_INTEL_MODEL_ALL
Definition MachO.h:1757
@ REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY
Definition MachO.h:335
@ REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY
Definition MachO.h:336
@ DYNAMIC_LOOKUP_ORDINAL
Definition MachO.h:350
@ N_COLD_FUNC
Definition MachO.h:345
@ REFERENCE_FLAG_UNDEFINED_LAZY
Definition MachO.h:332
@ N_WEAK_DEF
Definition MachO.h:342
@ EXECUTABLE_ORDINAL
Definition MachO.h:351
@ REFERENCE_FLAG_UNDEFINED_NON_LAZY
Definition MachO.h:331
@ REFERENCED_DYNAMICALLY
Definition MachO.h:339
@ REFERENCE_FLAG_DEFINED
Definition MachO.h:333
@ N_ARM_THUMB_DEF
Definition MachO.h:338
@ MAX_LIBRARY_ORDINAL
Definition MachO.h:349
@ SELF_LIBRARY_ORDINAL
Definition MachO.h:348
@ N_NO_DEAD_STRIP
Definition MachO.h:340
@ REFERENCE_TYPE
Definition MachO.h:330
@ N_SYMBOL_RESOLVER
Definition MachO.h:343
@ REFERENCE_FLAG_PRIVATE_DEFINED
Definition MachO.h:334
@ N_ALT_ENTRY
Definition MachO.h:344
@ N_WEAK_REF
Definition MachO.h:341
RelocationInfoType
Definition MachO.h:401
@ X86_64_RELOC_UNSIGNED
Definition MachO.h:536
@ X86_64_RELOC_SIGNED
Definition MachO.h:537
@ X86_64_RELOC_GOT
Definition MachO.h:540
@ ARM_RELOC_PAIR
Definition MachO.h:437
@ GENERIC_RELOC_LOCAL_SECTDIFF
Definition MachO.h:410
@ ARM_RELOC_BR24
Definition MachO.h:441
@ PPC_RELOC_PAIR
Definition MachO.h:417
@ RISCV_RELOC_GOT_HI20
Definition MachO.h:518
@ ARM_THUMB_RELOC_BR22
Definition MachO.h:442
@ PPC_RELOC_SECTDIFF
Definition MachO.h:424
@ PPC_RELOC_HI16
Definition MachO.h:420
@ PPC_RELOC_PB_LA_PTR
Definition MachO.h:425
@ ARM_RELOC_PB_LA_PTR
Definition MachO.h:440
@ ARM64_RELOC_PAGEOFF12
Definition MachO.h:460
@ PPC_RELOC_HA16_SECTDIFF
Definition MachO.h:428
@ ARM_RELOC_LOCAL_SECTDIFF
Definition MachO.h:439
@ ARM64_RELOC_POINTER_TO_GOT
Definition MachO.h:466
@ RISCV_RELOC_HI20
Definition MachO.h:501
@ X86_64_RELOC_GOT_LOAD
Definition MachO.h:539
@ RISCV_RELOC_POINTER_TO_GOT
Definition MachO.h:525
@ ARM64_RELOC_AUTHENTICATED_POINTER
Definition MachO.h:474
@ GENERIC_RELOC_PB_LA_PTR
Definition MachO.h:409
@ X86_64_RELOC_BRANCH
Definition MachO.h:538
@ X86_64_RELOC_SIGNED_2
Definition MachO.h:543
@ RISCV_RELOC_GOT_LO12
Definition MachO.h:521
@ GENERIC_RELOC_PAIR
Definition MachO.h:407
@ RISCV_RELOC_BRANCH21
Definition MachO.h:498
@ GENERIC_RELOC_VANILLA
Definition MachO.h:406
@ X86_64_RELOC_TLV
Definition MachO.h:545
@ ARM64_RELOC_SUBTRACTOR
Definition MachO.h:454
@ PPC_RELOC_LOCAL_SECTDIFF
Definition MachO.h:431
@ ARM_THUMB_32BIT_BRANCH
Definition MachO.h:443
@ ARM_RELOC_HALF_SECTDIFF
Definition MachO.h:445
@ PPC_RELOC_JBSR
Definition MachO.h:429
@ RISCV_RELOC_UNSIGNED
Definition MachO.h:479
@ PPC_RELOC_LO14_SECTDIFF
Definition MachO.h:430
@ RISCV_RELOC_SUBTRACTOR
Definition MachO.h:492
@ GENERIC_RELOC_TLV
Definition MachO.h:411
@ PPC_RELOC_LO16_SECTDIFF
Definition MachO.h:427
@ ARM64_RELOC_ADDEND
Definition MachO.h:472
@ ARM64_RELOC_UNSIGNED
Definition MachO.h:452
@ ARM_RELOC_SECTDIFF
Definition MachO.h:438
@ PPC_RELOC_BR24
Definition MachO.h:419
@ PPC_RELOC_LO16
Definition MachO.h:421
@ ARM64_RELOC_GOT_LOAD_PAGE21
Definition MachO.h:462
@ X86_64_RELOC_SIGNED_4
Definition MachO.h:544
@ GENERIC_RELOC_INVALID
Definition MachO.h:405
@ PPC_RELOC_HA16
Definition MachO.h:422
@ RISCV_RELOC_LO12
Definition MachO.h:512
@ GENERIC_RELOC_SECTDIFF
Definition MachO.h:408
@ X86_64_RELOC_SUBTRACTOR
Definition MachO.h:541
@ ARM64_RELOC_TLVP_LOAD_PAGEOFF12
Definition MachO.h:470
@ RISCV_RELOC_ADDEND
Definition MachO.h:531
@ PPC_RELOC_BR14
Definition MachO.h:418
@ X86_64_RELOC_SIGNED_1
Definition MachO.h:542
@ ARM64_RELOC_PAGE21
Definition MachO.h:458
@ PPC_RELOC_VANILLA
Definition MachO.h:416
@ PPC_RELOC_HI16_SECTDIFF
Definition MachO.h:426
@ ARM64_RELOC_GOT_LOAD_PAGEOFF12
Definition MachO.h:464
@ PPC_RELOC_LO14
Definition MachO.h:423
@ ARM_RELOC_HALF
Definition MachO.h:444
@ ARM64_RELOC_TLVP_LOAD_PAGE21
Definition MachO.h:468
@ ARM_RELOC_VANILLA
Definition MachO.h:436
@ ARM64_RELOC_BRANCH26
Definition MachO.h:456
x86_fp_control_rc
Definition MachO.h:1899
@ x86_FP_RND_UP
Definition MachO.h:1902
@ x86_FP_RND_DOWN
Definition MachO.h:1901
@ x86_FP_RND_NEAR
Definition MachO.h:1900
@ x86_FP_CHOP
Definition MachO.h:1903
uint32_t CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion, bool PtrAuthKernelABIVersion)
Definition MachO.h:1798
uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc)
Definition MachO.h:1670
LoadCommandType
Definition MachO.h:98
constexpr uint32_t S_ATTR_LOC_RELOC
Section has local relocation entries.
Definition MachO.h:214
LLVM_ABI Expected< uint32_t > getCPUType(const Triple &T)
Definition MachO.cpp:89
@ CPU_ARCH_ABI64
Definition MachO.h:1690
@ CPU_ARCH_ABI64_32
Definition MachO.h:1691
@ CPU_ARCH_MASK
Definition MachO.h:1689
constexpr uint32_t S_ATTR_SELF_MODIFYING_CODE
Used with i386 code stubs written on by dyld.
Definition MachO.h:202
const uint32_t x86_EXCEPTION_STATE64_COUNT
Definition MachO.h:2115
@ CPU_SUBTYPE_386
Definition MachO.h:1724
@ CPU_SUBTYPE_586
Definition MachO.h:1727
@ CPU_SUBTYPE_X86_ALL
Definition MachO.h:1745
@ CPU_SUBTYPE_CELERON_MOBILE
Definition MachO.h:1733
@ CPU_SUBTYPE_PENTII_M3
Definition MachO.h:1730
@ CPU_SUBTYPE_I386_ALL
Definition MachO.h:1723
@ CPU_SUBTYPE_X86_ARCH1
Definition MachO.h:1747
@ CPU_SUBTYPE_PENTIUM_3_XEON
Definition MachO.h:1736
@ CPU_SUBTYPE_ITANIUM_2
Definition MachO.h:1741
@ CPU_SUBTYPE_PENTII_M5
Definition MachO.h:1731
@ CPU_SUBTYPE_X86_64_H
Definition MachO.h:1748
@ CPU_SUBTYPE_PENTIUM_M
Definition MachO.h:1737
@ CPU_SUBTYPE_PENTIUM_3_M
Definition MachO.h:1735
@ CPU_SUBTYPE_PENTPRO
Definition MachO.h:1729
@ CPU_SUBTYPE_486SX
Definition MachO.h:1726
@ CPU_SUBTYPE_X86_64_ALL
Definition MachO.h:1746
@ CPU_SUBTYPE_CELERON
Definition MachO.h:1732
@ CPU_SUBTYPE_ITANIUM
Definition MachO.h:1740
@ CPU_SUBTYPE_PENTIUM_4_M
Definition MachO.h:1739
@ CPU_SUBTYPE_PENT
Definition MachO.h:1728
@ CPU_SUBTYPE_486
Definition MachO.h:1725
@ CPU_SUBTYPE_PENTIUM_3
Definition MachO.h:1734
@ CPU_SUBTYPE_PENTIUM_4
Definition MachO.h:1738
@ CPU_SUBTYPE_XEON
Definition MachO.h:1742
@ CPU_SUBTYPE_XEON_MP
Definition MachO.h:1743
const uint32_t x86_THREAD_STATE64_COUNT
Definition MachO.h:2111
@ CPU_TYPE_ARM64_32
Definition MachO.h:1704
@ CPU_TYPE_ARM64
Definition MachO.h:1703
@ CPU_TYPE_ANY
Definition MachO.h:1696
@ CPU_TYPE_POWERPC
Definition MachO.h:1706
@ CPU_TYPE_X86_64
Definition MachO.h:1699
@ CPU_TYPE_POWERPC64
Definition MachO.h:1707
@ CPU_TYPE_X86
Definition MachO.h:1697
@ CPU_TYPE_RISCV
Definition MachO.h:1709
@ CPU_TYPE_SPARC
Definition MachO.h:1705
@ CPU_TYPE_I386
Definition MachO.h:1698
@ CPU_TYPE_MC98000
Definition MachO.h:1701
@ CPU_TYPE_ARM
Definition MachO.h:1702
void swapByteOrder(T &Value)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_PACKED_END
Definition VPlan.h:1087
arm_thread_state32_t ts32
Definition MachO.h:2170
union llvm::MachO::arm_thread_state_t::@050043077327255314063252313156247224257021205374 uts
Definition MachO.h:867
uint16_t length
Definition MachO.h:869
uint16_t kind
Definition MachO.h:870
uint32_t offset
Definition MachO.h:868
Structs for dyld chained fixups.
Definition MachO.h:1129
uint32_t imports_count
Number of imported symbol names.
Definition MachO.h:1134
uint32_t imports_format
DYLD_CHAINED_IMPORT*.
Definition MachO.h:1135
uint32_t imports_offset
Offset of imports table in chain_data.
Definition MachO.h:1132
uint32_t starts_offset
Offset of dyld_chained_starts_in_image.
Definition MachO.h:1131
uint32_t symbols_offset
Offset of symbol strings in chain_data.
Definition MachO.h:1133
uint32_t symbols_format
0 => uncompressed, 1 => zlib compressed
Definition MachO.h:1136
dyld_chained_starts_in_image is embedded in LC_DYLD_CHAINED_FIXUPS payload.
Definition MachO.h:1142
uint16_t page_count
Length of the page_start array.
Definition MachO.h:1153
uint16_t page_size
Page size in bytes (0x1000 or 0x4000)
Definition MachO.h:1149
uint16_t pointer_format
DYLD_CHAINED_PTR*.
Definition MachO.h:1150
uint32_t max_valid_pointer
Values beyond this are not pointers on 32-bit.
Definition MachO.h:1152
uint64_t segment_offset
VM offset from the __TEXT segment.
Definition MachO.h:1151
uint32_t size
Size of this, including chain_starts entries.
Definition MachO.h:1148
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:1154
uint32_t objc_module_info_size
Definition MachO.h:805
uint32_t objc_module_info_addr
Definition MachO.h:804
uint32_t current_version
Definition MachO.h:675
uint32_t name
Definition MachO.h:673
uint32_t compatibility_version
Definition MachO.h:676
uint32_t timestamp
Definition MachO.h:674
uint32_t cpusubtype
Definition MachO.h:1028
Definition MachO.h:964
uint64_t vmaddr
Definition MachO.h:967
union lc_str entry_id
Definition MachO.h:969
uint32_t cmd
Definition MachO.h:965
uint32_t cmdsize
Definition MachO.h:966
uint64_t fileoff
Definition MachO.h:968
uint32_t reserved
Definition MachO.h:970
unsigned short denorm
Definition MachO.h:1907
unsigned short undfl
Definition MachO.h:1907
unsigned short ovrfl
Definition MachO.h:1907
unsigned short rc
Definition MachO.h:1908
unsigned short pc
Definition MachO.h:1908
unsigned short zdiv
Definition MachO.h:1907
unsigned short precis
Definition MachO.h:1908
unsigned short invalid
Definition MachO.h:1907
unsigned short c2
Definition MachO.h:1913
unsigned short errsumm
Definition MachO.h:1913
unsigned short precis
Definition MachO.h:1913
unsigned short invalid
Definition MachO.h:1912
unsigned short c1
Definition MachO.h:1913
unsigned short busy
Definition MachO.h:1914
unsigned short denorm
Definition MachO.h:1912
unsigned short c3
Definition MachO.h:1914
unsigned short zdiv
Definition MachO.h:1912
unsigned short c0
Definition MachO.h:1913
unsigned short stkflt
Definition MachO.h:1913
unsigned short tos
Definition MachO.h:1913
unsigned short undfl
Definition MachO.h:1912
unsigned short ovrfl
Definition MachO.h:1912
struct fvmlib fvmlib
Definition MachO.h:669
uint32_t header_addr
Definition MachO.h:662
uint32_t name
Definition MachO.h:660
uint32_t minor_version
Definition MachO.h:661
uint32_t n_strx
Definition MachO.h:1075
uint32_t n_value
Definition MachO.h:1079
ppc_thread_state32_t ts32
Definition MachO.h:2295
union llvm::MachO::ppc_thread_state_t::@303126343162322332223050011263367006216164356124 uts
uint32_t reserved2
Definition MachO.h:636
uint32_t reloff
Definition MachO.h:632
char sectname[16]
Definition MachO.h:626
uint32_t reserved1
Definition MachO.h:635
char segname[16]
Definition MachO.h:627
uint32_t offset
Definition MachO.h:630
uint32_t nreloc
Definition MachO.h:633
union llvm::MachO::x86_exception_state_t::@252203374302256000206214376342322154037210364120 ues
x86_exception_state64_t es64
Definition MachO.h:2066
x86_float_state64_t fs64
Definition MachO.h:2059
union llvm::MachO::x86_float_state_t::@001173320355100273222071151033237015104146215062 ufs
union llvm::MachO::x86_thread_state_t::@223274061160147304306274265337232361204150056013 uts
x86_thread_state64_t ts64
Definition MachO.h:2051
x86_thread_state32_t ts32
Definition MachO.h:2052
uint32_t offset
Definition MachO.h:961