Mach-O File Format

Mach-O is the executable format of macOS, iOS, watchOS, tvOS and visionOS: executables, dylibs, frameworks, bundles, kernel extensions, the kernel itself, and object files. This page describes the headers and load commands with their offsets, how chained fixups and code signatures are stored, and annotates every byte of a real arm64 executable.

Layout

File
mach_header_64
Load commands (LC_SEGMENT_64 + section_64, LC_MAIN, LC_LOAD_DYLIB...)
__TEXT segment data (starts at offset 0: includes the headers)
__DATA_CONST, __DATA
__LINKEDIT (fixups, exports, symbols, strings)
Code signature (end of __LINKEDIT)
Memory (sample)
__PAGEZERO ---0 – 4 GiB, no access: catches NULL and truncated pointers
__TEXT r-xheaders, code, stubs, constants
__DATA_CONST rw- → r--GOT, read-only after fixups
__DATA rw-writable data (absent in the sample)
__LINKEDIT r--raw data used by dyld and the kernel

Everything is described by load commands: there is no section header table and no program header table. Segments are mapped page by page (16 KiB on arm64), ASLR slides the whole image.

Annotated sample (33360 bytes, arm64)

A real executable built by clang -arch arm64 -Os from int main(void) { puts("Hello, Mach-O!"); return 0; }, linked against libSystem and ad-hoc signed. Every byte is described; zero padding is folded.

Segmentvmaddrvmsizefileofffilesizeinitprot
__PAGEZERO0x00x1000000000x00x0---
__TEXT0x1000000000x40000x00x4000r-x
__DATA_CONST0x1000040000x40000x40000x4000rw-
__LINKEDIT0x1000080000x40000x80000x250r--
0x0mach_header_64magic, cputype, ncmds32 B
0x20Load commands17 commands, segments and their sections1.0 KiB
0x438Paddingroom for more load commands40 B
0x460__TEXT sections__text, __stubs, __cstring, __unwind_info14.9 KiB
0x4000__DATA_CONST__got16.0 KiB
0x8000__LINKEDITfixups, exports, symbols, strings256 B
0x8100Code signatureSuperBlob, CodeDirectory, page hashes336 B
00000000cffaedfe0c0000010000000002000000................
0000001011000000180400008500200000000000.......... .....
0000002019000000480000005f5f504147455a45....H...__PAGEZE
00000030524f0000000000000000000000000000RO..............
0000004000000000010000000000000000000000................
0000005000000000000000000000000000000000................
0000006000000000000000001900000088010000................
000000705f5f5445585400000000000000000000__TEXT..........
0000008000000000010000000040000000000000.........@......
0000009000000000000000000040000000000000.........@......
000000a005000000050000000400000000000000................
000000b05f5f7465787400000000000000000000__text..........
000000c05f5f5445585400000000000000000000__TEXT..........
000000d060040000010000002000000000000000`....... .......
000000e060040000020000000000000000000000`...............
000000f000040080000000000000000000000000................
000001005f5f7374756273000000000000000000__stubs.........
000001105f5f5445585400000000000000000000__TEXT..........
0000012080040000010000000c00000000000000................
0000013080040000020000000000000000000000................
0000014008040080000000000c00000000000000................
000001505f5f63737472696e6700000000000000__cstring.......
000001605f5f5445585400000000000000000000__TEXT..........
000001708c040000010000000f00000000000000................
000001808c040000000000000000000000000000................
0000019002000000000000000000000000000000................
000001a05f5f756e77696e645f696e666f000000__unwind_info...
000001b05f5f5445585400000000000000000000__TEXT..........
000001c09c040000010000005800000000000000........X.......
000001d09c040000020000000000000000000000................
000001e000000000000000000000000000000000................
000001f019000000980000005f5f444154415f43........__DATA_C
000002004f4e5354000000000040000001000000ONST.....@......
0000021000400000000000000040000000000000.@.......@......
0000022000400000000000000300000003000000.@..............
0000023001000000100000005f5f676f74000000........__got...
0000024000000000000000005f5f444154415f43........__DATA_C
000002504f4e5354000000000040000001000000ONST.....@......
0000026008000000000000000040000003000000.........@......
0000027000000000000000000600000001000000................
0000028000000000000000001900000048000000............H...
000002905f5f4c494e4b45444954000000000000__LINKEDIT......
000002a000800000010000000040000000000000.........@......
000002b000800000000000005002000000000000........P.......
000002c001000000010000000000000000000000................
000002d0340000801000000000800000600000004...........`...
000002e0330000801000000060800000300000003.......`...0...
000002f002000000180000009880000003000000................
00000300d0800000280000000b00000050000000....(.......P...
0000031000000000000000000000000002000000................
0000032002000000010000000000000000000000................
0000033000000000000000000000000000000000................
00000340c8800000020000000000000000000000................
0000035000000000000000000e00000020000000............ ...
000003600c0000002f7573722f6c69622f64796c..../usr/lib/dyl
0000037064000000000000001b00000018000000d...............
00000380b2e757fca87032899510ad46484c798d..W..p2....FHLy.
000003902a000000100000000000000000000000*...............
000003a028000080180000006004000000000000(.......`.......
000003b000000000000000000c00000038000000............8...
000003c0180000000200000000004c0500000100..........L.....
000003d02f7573722f6c69622f6c696253797374/usr/lib/libSyst
000003e0656d2e422e64796c6962000000000000em.B.dylib......
000003f026000000100000009080000008000000&...............
0000040029000000100000009880000000000000)...............
000004101d000000100000000081000050010000............P...
0000042032000000180000000100000000000e002...............
0000043000051a00000000000000000000000000................
00000440… 0x20 zero bytes …
00000460fd7bbfa9fd0300910000009000301291.{...........0..
000004700400009400008052fd7bc1a8c0035fd6.......R.{...._.
0000048030000090100240f900021fd648656c6c0.....@.....Hell
000004906f2c204d6163682d4f21000001000000o, Mach-O!......
000004a01c000000000000001c00000000000000................
000004b01c000000020000006004000040000000........`...@...
000004c040000000810400000000000040000000@...........@...
000004d000000000000000000000000003000000................
000004e00c000100100001000000000000000004................
000004f000000000000000000000000000000000................
00000500… 0x3b00 zero bytes …
0000400000000000000000800000000000000000................
00004010… 0x3ff0 zero bytes …
0000800000000000200000005000000054000000.... ...P...T...
0000801001000000010000000000000000000000................
0000802004000000000000000000000018000000................
0000803000000000000000001800000000400600.............@..
0000804000400000000000000000000001000000.@..............
0000805001020000005f70757473000000000000....._puts......
0000806000015f001200000000020000000300e0.._.............
00008070080000025f6d685f657865637574655f...._mh_execute_
0000808068656164657200096d61696e000d0000header..main....
00008090e008000000000000020000000f011000................
000080a00000000001000000160000000f010000................
000080b060040000010000001c00000001000001`...............
000080c000000000000000000200000002000000................
000080d020005f5f6d685f657865637574655f68 .__mh_execute_h
000080e06561646572005f6d61696e005f707574eader._main._put
000080f073000000000000000000000000000000s...............
00008100fade0cc00000013c0000000300000000.......<........
0000811000000024000000020000012800010000...$.......(....
0000812000000134fade0c020000010400020400...4............
0000813000000002000000a40000005800000002...........X....
0000814000000003000081002002000e00000000........ .......
0000815000000000000000000000000000000000................
0000816000000000000000000000000000000000................
0000817000004000000000000000000168656c6c..@.........hell
000081806f2d61726d363400987920904eab650eo-arm64..y .N.e.
0000819075788c054aa0b0524e6a80bfc71aa32dux..J..RNj.....-
000081a0f8d237a61743f9860000000000000000..7..C..........
000081b000000000000000000000000000000000................
000081c00000000000000000f8be42393d9a93c3..........B9=...
000081d0918811685da155a4260d467123095684...h].U.&.Fq#.V.
000081e010a0494da4d0bcb41e3cfc661d24698c..IM.....<.f.$i.
000081f0a0cf3ab977bfd120b518e20f23488ddb..:.w.. ....#H..
0000820057eaabdaf790395b0126b7f76edb5e99W.....9[.&..n.^.
00008210dc0a654b9d549829398a5f12e16d94eb..eK.T.)9._..m..
00008220534d61a2ce1e3f41fade0c010000000cSMa...?A........
0000823000000000fade0b01000000082ca7ad7f............,...
00008240acb2586fc6e966c004d7d1d16b024f58..Xo..f.....k.OX

Hover a byte or a field to see what it is. Click to pin it.

mach_header_64 0x0
  • magicMH_MAGIC_64
  • cputypeCPU_TYPE_ARM64
  • cpusubtypeCPU_SUBTYPE_ARM64_ALL
  • filetypeMH_EXECUTE
  • ncmds0x11
  • sizeofcmds0x418
  • flagsMH_NOUNDEFS | MH_DYL…
  • reserved0
Load command 0: LC_SEGMENT_64 __PAGEZERO 0x20
  • cmdLC_SEGMENT_64
  • cmdsize0x48
  • segname"__PAGEZERO"
  • vmaddr0
  • vmsize0x100000000
  • fileoff0
  • filesize0
  • maxprot---
  • initprot---
  • nsects0
  • flags0
Load command 1: LC_SEGMENT_64 __TEXT 0x68
  • cmdLC_SEGMENT_64
  • cmdsize0x188
  • segname"__TEXT"
  • vmaddr0x100000000
  • vmsize0x4000
  • fileoff0
  • filesize0x4000
  • maxprotr-x
  • initprotr-x
  • nsects4
  • flags0
Load command 1: LC_SEGMENT_64 __TEXT / section_64 __text 0xb0
  • sectname"__text"
  • segname"__TEXT"
  • addr0x100000460
  • size0x20
  • offset0x460
  • align2^2
  • reloff0
  • nreloc0
  • flagsS_REGULAR | S_ATTR_P…
  • reserved10
  • reserved20
  • reserved30
Load command 1: LC_SEGMENT_64 __TEXT / section_64 __stubs 0x100
  • sectname"__stubs"
  • segname"__TEXT"
  • addr0x100000480
  • size0xc
  • offset0x480
  • align2^2
  • reloff0
  • nreloc0
  • flagsS_SYMBOL_STUBS | S_A…
  • reserved10
  • reserved20xc
  • reserved30
Load command 1: LC_SEGMENT_64 __TEXT / section_64 __cstring 0x150
  • sectname"__cstring"
  • segname"__TEXT"
  • addr0x10000048c
  • size0xf
  • offset0x48c
  • align2^0
  • reloff0
  • nreloc0
  • flagsS_CSTRING_LITERALS
  • reserved10
  • reserved20
  • reserved30
Load command 1: LC_SEGMENT_64 __TEXT / section_64 __unwind_info 0x1a0
  • sectname"__unwind_info"
  • segname"__TEXT"
  • addr0x10000049c
  • size0x58
  • offset0x49c
  • align2^2
  • reloff0
  • nreloc0
  • flagsS_REGULAR
  • reserved10
  • reserved20
  • reserved30
Load command 2: LC_SEGMENT_64 __DATA_CONST 0x1f0
  • cmdLC_SEGMENT_64
  • cmdsize0x98
  • segname"__DATA_CONST"
  • vmaddr0x100004000
  • vmsize0x4000
  • fileoff0x4000
  • filesize0x4000
  • maxprotrw-
  • initprotrw-
  • nsects1
  • flagsSG_READ_ONLY
Load command 2: LC_SEGMENT_64 __DATA_CONST / section_64 __got 0x238
  • sectname"__got"
  • segname"__DATA_CONST"
  • addr0x100004000
  • size8
  • offset0x4000
  • align2^3
  • reloff0
  • nreloc0
  • flagsS_NON_LAZY_SYMBOL_PO…
  • reserved11
  • reserved20
  • reserved30
Load command 3: LC_SEGMENT_64 __LINKEDIT 0x288
  • cmdLC_SEGMENT_64
  • cmdsize0x48
  • segname"__LINKEDIT"
  • vmaddr0x100008000
  • vmsize0x4000
  • fileoff0x8000
  • filesize0x250
  • maxprotr--
  • initprotr--
  • nsects0
  • flags0
Load command 4: LC_DYLD_CHAINED_FIXUPS 0x2d0
  • cmdLC_DYLD_CHAINED_FIXUPS
  • cmdsize0x10
  • dataoff0x8000
  • datasize0x60
Load command 5: LC_DYLD_EXPORTS_TRIE 0x2e0
  • cmdLC_DYLD_EXPORTS_TRIE
  • cmdsize0x10
  • dataoff0x8060
  • datasize0x30
Load command 6: LC_SYMTAB 0x2f0
  • cmdLC_SYMTAB
  • cmdsize0x18
  • symoff0x8098
  • nsyms3
  • stroff0x80d0
  • strsize0x28
Load command 7: LC_DYSYMTAB 0x308
  • cmdLC_DYSYMTAB
  • cmdsize0x50
  • ilocalsym0
  • nlocalsym0
  • iextdefsym0
  • nextdefsym2
  • iundefsym2
  • nundefsym1
  • tocoff0
  • ntoc0
  • modtaboff0
  • nmodtab0
  • extrefsymoff0
  • nextrefsyms0
  • indirectsymoff0x80c8
  • nindirectsyms2
  • extreloff0
  • nextrel0
  • locreloff0
  • nlocrel0
Load command 8: LC_LOAD_DYLINKER 0x358
  • cmdLC_LOAD_DYLINKER
  • cmdsize0x20
  • name0xc
  • path"/usr/lib/dyld"
Load command 9: LC_UUID 0x378
  • cmdLC_UUID
  • cmdsize0x18
  • uuidB2E757FCA87032899510…
Load command 10: LC_SOURCE_VERSION 0x390
  • cmdLC_SOURCE_VERSION
  • cmdsize0x10
  • version0
Load command 11: LC_MAIN 0x3a0
  • cmdLC_MAIN
  • cmdsize0x18
  • entryoff0x460
  • stacksize0
Load command 12: LC_LOAD_DYLIB 0x3b8
  • cmdLC_LOAD_DYLIB
  • cmdsize0x38
  • dylib.name0x18
  • dylib.timestamp2
  • dylib.current_version1356.0.0
  • dylib.compatibility_version1.0.0
  • path"/usr/lib/libSystem.…
Load command 13: LC_FUNCTION_STARTS 0x3f0
  • cmdLC_FUNCTION_STARTS
  • cmdsize0x10
  • dataoff0x8090
  • datasize8
Load command 14: LC_DATA_IN_CODE 0x400
  • cmdLC_DATA_IN_CODE
  • cmdsize0x10
  • dataoff0x8098
  • datasize0
Load command 15: LC_CODE_SIGNATURE 0x410
  • cmdLC_CODE_SIGNATURE
  • cmdsize0x10
  • dataoff0x8100
  • datasize0x150
Load command 16: LC_BUILD_VERSION 0x420
  • cmdLC_BUILD_VERSION
  • cmdsize0x18
  • platformPLATFORM_MACOS
  • minos14.0.0
  • sdk26.5.0
  • ntools0
Padding 0x438
  • paddingzeros
__TEXT,__text 0x460
  • stpstp x29, x30, [sp, #…
  • movmov x29, sp
  • adrpadrp x0, 0x100000000
  • addadd x0, x0, #0x48c
  • blbl 0x100000480
  • movmov w0, #0x0
  • ldpldp x29, x30, [sp], …
  • retret
__TEXT,__stubs 0x480
  • adrpadrp x16, 0x100004000
  • ldrldr x16, [x16]
  • brbr x16
__TEXT,__cstring 0x48c
  • string"Hello, Mach-O!"
Padding 0x49b
  • paddingzeros
__TEXT,__unwind_info 0x49c
  • __unwind_info
Padding 0x4f4
  • paddingzeros
__DATA_CONST,__got 0x4000
  • slot 0bind ordinal 0, next 0
Padding 0x4008
  • paddingzeros
Chained fixups: header 0x8000
  • fixups_version0
  • starts_offset0x20
  • imports_offset0x50
  • symbols_offset0x54
  • imports_count1
  • imports_format1
  • symbols_format0
Padding 0x801c
  • paddingzeros
Chained fixups: starts_in_image 0x8020
  • seg_count4
  • seg_info_offset[0]0 (__PAGEZERO)
  • seg_info_offset[1]0 (__TEXT)
  • seg_info_offset[2]24 (__DATA_CONST)
  • seg_info_offset[3]0 (__LINKEDIT)
Padding 0x8034
  • paddingzeros
Chained fixups: starts_in_segment __DATA_CONST 0x8038
  • size0x18
  • page_size0x4000
  • pointer_formatDYLD_CHAINED_PTR_64_…
  • segment_offset0x4000
  • max_valid_pointer0
  • page_count1
  • page_start[0]0x0
Chained fixups: imports 0x8050
  • import 0lib 1, weak 0, name …
Padding 0x8054
  • paddingzeros
Chained fixups: symbols 0x8055
  • name"_puts"
Padding 0x805b
  • paddingzeros
Exports trie 0x8060
  • trie
Function starts 0x8090
  • ULEB128 deltas
Symbol 0 __mh_execute_header 0x8098
  • n_strx2 → "__mh_execute_he…
  • n_typeN_SECT | N_EXT
  • n_sect1
  • n_desc0x10
  • n_value0x100000000
Symbol 1 _main 0x80a8
  • n_strx22 → "_main"
  • n_typeN_SECT | N_EXT
  • n_sect1
  • n_desc0
  • n_value0x100000460
Symbol 2 _puts 0x80b8
  • n_strx28 → "_puts"
  • n_typeN_UNDF | N_EXT
  • n_sect0
  • n_desclibrary ordinal 1
  • n_value0
Indirect symbol table 0x80c8
  • entry 02
  • entry 12
String table 0x80d0
  • strings[0]" "
Padding 0x80d1
  • paddingzeros
String table 0x80d2
  • name"__mh_execute_header"
  • name"_main"
  • name"_puts"
Padding 0x80f2
  • paddingzeros
Code signature: CS_SuperBlob 0x8100
  • magic0xfade0cc0
  • length0x13c
  • count0x3
Code signature: CS_BlobIndex 0 0x810c
  • typeCSSLOT_CODEDIRECTORY
  • offset0x24
Code signature: CS_BlobIndex 1 0x8114
  • typeCSSLOT_REQUIREMENTS
  • offset0x128
Code signature: CS_BlobIndex 2 0x811c
  • typeCSSLOT_SIGNATURESLOT
  • offset0x134
Code signature: CS_CodeDirectory 0x8124
  • magicCSMAGIC_CODEDIRECTORY
  • length0x104
  • version0x20400
  • flagsCS_ADHOC
  • hashOffset0xa4
  • identOffset0x58
  • nSpecialSlots2
  • nCodeSlots3
  • codeLimit0x8100
  • hashSize0x20
  • hashTypeSHA-256
  • platform0
  • pageSize0xe
  • spare20
  • scatterOffset0
  • teamOffset0
  • spare30
  • codeLimit640
  • execSegBase0
  • execSegLimit0x4000
  • execSegFlags1
  • identifier"hello-arm64"
Code signature: special slots 0x8188
  • slot -2987920904eab650e…
  • slot -10000000000000000…
Code signature: page hashes 0x81c8
  • page 0f8be42393d9a93c3…
  • page 11e3cfc661d24698c…
  • page 20126b7f76edb5e99…
Code signature: blob 0xfade0c01 0x8228
  • blob
Code signature: blob 0xfade0b01 0x8234
  • blob
Padding 0x823c
  • padding20 bytes

Universal (fat) binaries

A universal file starts with a fat_header and an array of fat_arch; each entry points to a complete thin Mach-O (x86_64, arm64, arm64e...). The kernel and dyld pick the best slice.

fat_header 8 (0x8) bytes

FieldOffsetSizeTypeMeaning
magic0x004uint32_tFAT_MAGIC 0xcafebabe or FAT_MAGIC_64 0xcafebabf.
nfat_arch0x044uint32_tNumber of architectures that follow.
All the fat structures are big endian. 0xcafebabe is also the magic of Java class files: tools tell them apart with nfat_arch, which is small for Mach-O.

fat_arch / fat_arch_64 20 (0x14) bytes / 32 (0x20) bytes

FieldOff. fat_archOff. fat_arch_64Size fat_archSize fat_arch_64TypeMeaning
cputype0x000x0044cpu_type_tCPU type of this slice.
cpusubtype0x040x0444cpu_subtype_tCPU subtype.
offset0x080x0848uint32_t / uint64_tFile offset of the thin Mach-O.
size0x0c0x1048uint32_t / uint64_tSize of the slice.
align0x100x1844uint32_tAlignment as a power of 2 (14 = 16 KiB).
reserved—0x1c—4uint32_tReserved.

Magic numbers

NameValueMeaning
MH_MAGIC0xfeedface32-bit, native byte order.
MH_CIGAM0xcefaedfe32-bit, swapped.
MH_MAGIC_640xfeedfacf64-bit, native byte order. Read as bytes cf fa ed fe in little-endian files.
MH_CIGAM_640xcffaedfe64-bit, swapped.
FAT_MAGIC0xcafebabeUniversal binary, 32-bit offsets.
FAT_CIGAM0xbebafecaUniversal, as read on a little-endian machine.
FAT_MAGIC_640xcafebabfUniversal binary, 64-bit offsets.

Header

mach_header / mach_header_64 28 (0x1c) bytes / 32 (0x20) bytes

FieldOff. 32Off. 64Size 32Size 64TypeMeaning
magic0x000x0044uint32_tMH_MAGIC 0xfeedface (32-bit) or MH_MAGIC_64 0xfeedfacf (64-bit), in the file's byte order.
cputype0x040x0444cpu_type_tCPU type: CPU_TYPE_ARM64, CPU_TYPE_X86_64...
cpusubtype0x080x0844cpu_subtype_tCPU subtype; the top byte holds capability bits such as CPU_SUBTYPE_PTRAUTH_ABI.
filetype0x0c0x0c44uint32_tFile type: MH_EXECUTE, MH_DYLIB, MH_BUNDLE, MH_OBJECT...
ncmds0x100x1044uint32_tNumber of load commands.
sizeofcmds0x140x1444uint32_tTotal size of the load commands, which follow the header.
flags0x180x1844uint32_tFlags (MH_PIE, MH_DYLDLINK, MH_TWOLEVEL...).
reserved—0x1c—4uint32_tReserved (64-bit only), 0.

cputype

NameValueMeaning
CPU_ARCH_ABI640x1000000Flag: 64-bit ABI.
CPU_ARCH_ABI64_320x2000000Flag: 64-bit hardware with 32-bit pointers (arm64_32, watchOS).
CPU_TYPE_X867i386.
CPU_TYPE_X86_640x1000007x86-64.
CPU_TYPE_ARM0xc32-bit ARM.
CPU_TYPE_ARM640x100000carm64.
CPU_TYPE_ARM64_320x200000carm64_32.
CPU_TYPE_POWERPC0x12PowerPC.
CPU_TYPE_POWERPC640x1000012PowerPC 64-bit.

cpusubtype

NameValueMeaning
CPU_SUBTYPE_X86_64_ALL3Any x86-64.
CPU_SUBTYPE_X86_64_H8x86-64h (Haswell and later).
CPU_SUBTYPE_ARM64_ALL0Any arm64.
CPU_SUBTYPE_ARM64_V81ARMv8.
CPU_SUBTYPE_ARM64E2arm64e: pointer authentication (system binaries).
CPU_SUBTYPE_PTRAUTH_ABI0x80000000Flag on arm64e: versioned pointer authentication ABI.
CPU_SUBTYPE_LIB640x80000000Flag: 64-bit library (old meaning of the same bit).

filetype

NameValueMeaning
MH_OBJECT1Relocatable object file (.o).
MH_EXECUTE2Executable.
MH_FVMLIB3Fixed VM shared library (obsolete).
MH_CORE4Core dump.
MH_PRELOAD5Preloaded executable (firmware).
MH_DYLIB6Dynamic library (.dylib, framework binary).
MH_DYLINKER7The dynamic linker (/usr/lib/dyld).
MH_BUNDLE8Plug-in loaded with dlopen (.bundle).
MH_DYLIB_STUB9Stub library (symbols only).
MH_DSYM0xaCompanion debug file (.dSYM).
MH_KEXT_BUNDLE0xbKernel extension.
MH_FILESET0xcSet of Mach-O files (kernel collections).

flags

NameValueMeaning
MH_NOUNDEFS1No undefined references.
MH_INCRLINK2Incremental link output.
MH_DYLDLINK4Input to dyld; cannot be statically linked again.
MH_BINDATLOAD8Bind undefined references at load.
MH_PREBOUND0x10Prebound (obsolete).
MH_TWOLEVEL0x80Two-level namespace: each import names its library.
MH_WEAK_DEFINES0x8000Contains weak definitions.
MH_BINDS_TO_WEAK0x10000Uses weak symbols.
MH_ALLOW_STACK_EXECUTION0x20000Executable stack.
MH_PIE0x200000Position independent: load at a random address (ASLR).
MH_HAS_TLV_DESCRIPTORS0x800000Has thread-local variables.
MH_NO_HEAP_EXECUTION0x1000000Non-executable heap.
MH_APP_EXTENSION_SAFE0x2000000Safe for app extensions.
MH_SIM_SUPPORT0x8000000Built for the simulator.
MH_DYLIB_IN_CACHE0x80000000Part of the dyld shared cache.

Load commands

ncmds commands follow the header, sizeofcmds bytes in total. All start with cmd and cmdsize; the next command is at cmd + cmdsize.

load_command 8 (0x8) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tCommand type (LC_*). Bit LC_REQ_DYLD (0x80000000) means dyld must understand it to load the file.
cmdsize0x044uint32_tSize of the command including its trailing data (strings, sections), multiple of 8 in 64-bit files.
CommandValueStructureMeaning
LC_REQ_DYLD0x80000000—Flag bit: dyld must understand the command or refuse to load the file.
LC_SEGMENT0x1segment_command32-bit segment.
LC_SYMTAB0x2symtab_commandSymbol table and string table.
LC_UNIXTHREAD0x5thread_commandInitial thread state (entry point of static executables and dyld).
LC_DYSYMTAB0xbdysymtab_commandSymbol table groups and indirect symbols.
LC_LOAD_DYLIB0xcdylib_commandLibrary to load.
LC_ID_DYLIB0xddylib_commandInstall name of this library.
LC_LOAD_DYLINKER0xedylinker_commandPath of the dynamic linker.
LC_ID_DYLINKER0xfdylinker_commandName of this dynamic linker.
LC_LOAD_WEAK_DYLIB0x80000018dylib_commandLibrary that may be missing.
LC_SEGMENT_640x19segment_command_6464-bit segment.
LC_UUID0x1buuid_commandBuild UUID.
LC_RPATH0x8000001crpath_commandRun-path search directory for @rpath.
LC_CODE_SIGNATURE0x1dlinkedit_data_commandCode signature.
LC_REEXPORT_DYLIB0x8000001fdylib_commandLibrary whose symbols are re-exported.
LC_ENCRYPTION_INFO_640x2cencryption_info_command_64Encrypted range (App Store FairPlay); cryptid != 0 when encrypted.
LC_DYLD_INFO_ONLY0x80000022dyld_info_commandCompressed rebase/bind opcodes (before chained fixups).
LC_FUNCTION_STARTS0x26linkedit_data_commandULEB128 deltas of function start addresses.
LC_MAIN0x80000028entry_point_commandEntry point (offset of main).
LC_DATA_IN_CODE0x29linkedit_data_commandData ranges inside code (jump tables).
LC_SOURCE_VERSION0x2asource_version_commandSource version.
LC_LINKER_OPTION0x2dlinker_option_commandLinker options in object files (auto-linking).
LC_BUILD_VERSION0x32build_version_commandPlatform, minimum OS and SDK versions.
LC_DYLD_EXPORTS_TRIE0x80000033linkedit_data_commandExported symbols as a trie.
LC_DYLD_CHAINED_FIXUPS0x80000034linkedit_data_commandRebases and binds as chains of pointers.
LC_FILESET_ENTRY0x80000035fileset_entry_commandMach-O embedded in an MH_FILESET.

segment_command / segment_command_64 56 (0x38) bytes / 72 (0x48) bytes

FieldOff. 32Off. 64Size 32Size 64TypeMeaning
cmd0x000x0044uint32_tLC_SEGMENT (0x1) / LC_SEGMENT_64 (0x19).
cmdsize0x040x0444uint32_tsizeof(segment_command_64) + nsects * sizeof(section_64).
segname0x080x081616char[16]Segment name: __TEXT, __DATA...
vmaddr0x180x1848ADDRVirtual address (before ASLR slide).
vmsize0x1c0x2048ADDRSize in memory; the excess over filesize is zero-filled.
fileoff0x200x2848ADDRFile offset of the content.
filesize0x240x3048ADDRBytes mapped from the file.
maxprot0x280x3844vm_prot_tMaximum protection (VM_PROT_READ 1, WRITE 2, EXECUTE 4).
initprot0x2c0x3c44vm_prot_tInitial protection.
nsects0x300x4044uint32_tNumber of section_64 structures that follow this command.
flags0x340x4444uint32_tFlags: SG_READ_ONLY (0x10) for __DATA_CONST, made read-only after fixups.
maxprot / initprot
NameValueMeaning
VM_PROT_NONE0No access.
VM_PROT_READ1Read.
VM_PROT_WRITE2Write.
VM_PROT_EXECUTE4Execute.
Segment flags
NameValueMeaning
SG_HIGHVM1Content is at the high end of the VM space.
SG_NORELOC4Nothing in the segment needs relocation.
SG_PROTECTED_VERSION_18Encrypted segment (old FairPlay).
SG_READ_ONLY0x10Made read-only by dyld after fixups (__DATA_CONST).

entry_point_command 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_MAIN (0x80000028).
cmdsize0x044uint32_t24.
entryoff0x088uint64_tOffset of main() from the start of __TEXT, which is also its file offset since __TEXT starts at offset 0. dyld calls it after initializing the process.
stacksize0x108uint64_tInitial stack size if not 0.
Replaced LC_UNIXTHREAD (a full register state with the entry address in pc/rip) in 10.8. Static executables, dyld itself and the kernel still use LC_UNIXTHREAD.

dylib_command 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_LOAD_DYLIB, LC_ID_DYLIB, LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB...
cmdsize0x044uint32_tIncludes the path string, padded to 8 bytes.
dylib.name0x084lc_strOffset of the path from the start of the command (24): /usr/lib/libSystem.B.dylib, @rpath/Foo.framework/Foo.
dylib.timestamp0x0c4uint32_tBuild timestamp (usually 2).
dylib.current_version0x104uint32_tVersion as xxxx.yy.zz (16.8.8 bits).
dylib.compatibility_version0x144uint32_tMinimum compatible version.
Libraries are referred to by ordinal: the first LC_LOAD_DYLIB is ordinal 1, as used by imports in the chained fixups and in n_desc of undefined symbols (two-level namespace).

dylinker_command 12 (0xc) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_LOAD_DYLINKER (0xe).
cmdsize0x044uint32_tIncludes the path string.
name0x084lc_strOffset of the path, normally /usr/lib/dyld.

linkedit_data_command 16 (0x10) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_DYLD_CHAINED_FIXUPS, LC_DYLD_EXPORTS_TRIE, LC_CODE_SIGNATURE, LC_FUNCTION_STARTS, LC_DATA_IN_CODE...
cmdsize0x044uint32_t16.
dataoff0x084uint32_tFile offset of the data in __LINKEDIT.
datasize0x0c4uint32_tSize of the data.

symtab_command 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_SYMTAB (0x2).
cmdsize0x044uint32_t24.
symoff0x084uint32_tFile offset of the nlist_64 array.
nsyms0x0c4uint32_tNumber of symbols.
stroff0x104uint32_tFile offset of the string table.
strsize0x144uint32_tSize of the string table.

dysymtab_command 80 (0x50) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_DYSYMTAB (0xb).
cmdsize0x044uint32_t80.
ilocalsym0x084uint32_tIndex of the first local symbol.
nlocalsym0x0c4uint32_tNumber of local symbols.
iextdefsym0x104uint32_tIndex of the first exported (defined external) symbol.
nextdefsym0x144uint32_tNumber of exported symbols.
iundefsym0x184uint32_tIndex of the first undefined (imported) symbol.
nundefsym0x1c4uint32_tNumber of undefined symbols.
tocoff0x204uint32_tTable of contents (legacy), 0.
ntoc0x244uint32_t
modtaboff0x284uint32_tModule table (legacy), 0.
nmodtab0x2c4uint32_t
extrefsymoff0x304uint32_tExternal reference table (legacy), 0.
nextrefsyms0x344uint32_t
indirectsymoff0x384uint32_tFile offset of the indirect symbol table: one uint32_t symbol index per stub and pointer slot.
nindirectsyms0x3c4uint32_tNumber of indirect symbol entries.
extreloff0x404uint32_tExternal relocations (legacy dyld info), 0 with chained fixups.
nextrel0x444uint32_t
locreloff0x484uint32_tLocal relocations, 0 with chained fixups.
nlocrel0x4c4uint32_t
The symbol table is sorted in three groups (local, exported, undefined); this command gives the boundaries.

uuid_command 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_UUID (0x1b).
cmdsize0x044uint32_t24.
uuid0x0816uint8_t[16]Unique build ID; matches the dSYM and crash reports.

build_version_command 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_BUILD_VERSION (0x32).
cmdsize0x044uint32_t24 + ntools * 8.
platform0x084uint32_tPlatform (PLATFORM_MACOS, PLATFORM_IOS...).
minos0x0c4uint32_tMinimum OS version, xxxx.yy.zz nibbles (0x000e0000 = 14.0).
sdk0x104uint32_tSDK version, same encoding.
ntools0x144uint32_tNumber of build_tool_version entries that follow.

build_tool_version 8 (0x8) bytes

FieldOffsetSizeTypeMeaning
tool0x004uint32_tTOOL_CLANG 1, TOOL_SWIFT 2, TOOL_LD 3, TOOL_LLD 4.
version0x044uint32_tTool version.
NameValueMeaning
TOOL_CLANG1clang
TOOL_SWIFT2swiftc
TOOL_LD3ld
TOOL_LLD4lld

Platforms

NameValueMeaning
PLATFORM_MACOS1macOS
PLATFORM_IOS2iOS
PLATFORM_TVOS3tvOS
PLATFORM_WATCHOS4watchOS
PLATFORM_BRIDGEOS5bridgeOS
PLATFORM_MACCATALYST6Mac Catalyst
PLATFORM_IOSSIMULATOR7iOS simulator
PLATFORM_TVOSSIMULATOR8tvOS simulator
PLATFORM_WATCHOSSIMULATOR9watchOS simulator
PLATFORM_DRIVERKIT0xaDriverKit
PLATFORM_VISIONOS0xbvisionOS
PLATFORM_VISIONOSSIMULATOR0xcvisionOS simulator

source_version_command 16 (0x10) bytes

FieldOffsetSizeTypeMeaning
cmd0x004uint32_tLC_SOURCE_VERSION (0x2a).
cmdsize0x044uint32_t16.
version0x088uint64_tA.B.C.D.E packed as 24.10.10.10.10 bits.

Segments and sections

section / section_64 68 (0x44) bytes / 80 (0x50) bytes

FieldOff. 32Off. 64Size 32Size 64TypeMeaning
sectname0x000x001616char[16]Section name (__text, __cstring...).
segname0x100x101616char[16]Segment it belongs to.
addr0x200x2048ADDRVirtual address.
size0x240x2848ADDRSize in bytes.
offset0x280x3044uint32_tFile offset (0 for zerofill sections).
align0x2c0x3444uint32_tAlignment as a power of 2.
reloff0x300x3844uint32_tFile offset of the relocation entries (object files).
nreloc0x340x3c44uint32_tNumber of relocation entries (object files).
flags0x380x4044uint32_tType (low 8 bits, S_*) and attributes (high 24 bits, S_ATTR_*).
reserved10x3c0x4444uint32_tFor symbol pointer and stub sections: index into the indirect symbol table.
reserved20x400x4844uint32_tFor S_SYMBOL_STUBS: size of one stub (12 on arm64).
reserved3—0x4c—4uint32_tReserved (64-bit only).
SegmentSectionContent
__PAGEZERO—No file content, no access. 4 GiB on 64-bit executables.
__TEXT__textCode.
__TEXT__stubs, __auth_stubs12-byte stubs that load an address from the GOT and branch to it (adrp; ldr; br).
__TEXT__cstring, __constString literals, read-only data.
__TEXT__objc_methname, __objc_classname, __objc_methtypeObjective-C names.
__TEXT__swift5_*Swift metadata (types, protocols, reflection).
__TEXT__unwind_info, __eh_frameCompact unwind tables, DWARF CFI.
__DATA_CONST__got, __auth_gotPointers to imported symbols, filled by dyld (non-lazy).
__DATA_CONST__const, __mod_init_func, __objc_classlistPointers that need fixups but never change afterwards.
__DATA__data, __bss, __commonWritable data, zero-fill.
__DATA__la_symbol_ptrLazy pointers (older binaries without chained fixups).
__DATA__objc_data, __objc_selrefs, __thread_varsObjective-C runtime data, TLV descriptors.
__LINKEDIT—No sections: the data of LC_SYMTAB, LC_DYSYMTAB, chained fixups, exports trie, function starts and code signature.

Section types (flags & 0xff)

NameValueMeaning
S_REGULAR0Regular section.
S_ZEROFILL1Zero-filled on demand, no file content (__bss, __common).
S_CSTRING_LITERALS2C strings, may be merged (__cstring).
S_4BYTE_LITERALS34-byte literals.
S_8BYTE_LITERALS48-byte literals.
S_LITERAL_POINTERS5Pointers to literals (__objc_selrefs).
S_NON_LAZY_SYMBOL_POINTERS6Pointers filled at load time (__got).
S_LAZY_SYMBOL_POINTERS7Pointers bound on first call (__la_symbol_ptr).
S_SYMBOL_STUBS8Stubs that jump through a pointer (__stubs).
S_MOD_INIT_FUNC_POINTERS9Constructor pointers (__mod_init_func).
S_MOD_TERM_FUNC_POINTERS0xaDestructor pointers.
S_COALESCED0xbWeak definitions coalesced by the linker.
S_THREAD_LOCAL_REGULAR0x11TLV initial values (__thread_data).
S_THREAD_LOCAL_ZEROFILL0x12TLV zero-fill (__thread_bss).
S_THREAD_LOCAL_VARIABLES0x13TLV descriptors (__thread_vars).
S_INIT_FUNC_OFFSETS0x1632-bit offsets of constructors (__init_offsets).

Section attributes (flags & 0xffffff00)

NameValueMeaning
S_ATTR_PURE_INSTRUCTIONS0x80000000Only instructions.
S_ATTR_NO_TOC0x40000000Coalesced symbols not in the table of contents.
S_ATTR_STRIP_STATIC_SYMS0x20000000Static symbols may be stripped.
S_ATTR_NO_DEAD_STRIP0x10000000Never dead-stripped.
S_ATTR_LIVE_SUPPORT0x8000000Kept if referenced items are kept.
S_ATTR_DEBUG0x2000000Debug information (__DWARF).
S_ATTR_SOME_INSTRUCTIONS0x400Contains some instructions.
S_ATTR_EXT_RELOC0x200Has external relocations.
S_ATTR_LOC_RELOC0x100Has local relocations.

Symbols

nlist / nlist_64 12 (0xc) bytes / 16 (0x10) bytes

FieldOff. 32Off. 64Size 32Size 64TypeMeaning
n_strx0x000x0044uint32_tOffset of the name in the string table.
n_type0x040x0411uint8_tType bits: N_STAB 0xe0 (debug), N_PEXT 0x10, N_TYPE 0x0e, N_EXT 0x01.
n_sect0x050x0511uint8_tSection number (1-based, across all segments) or NO_SECT (0).
n_desc0x060x0622int16_t / uint16_tFor undefined symbols: library ordinal in the high byte (GET_LIBRARY_ORDINAL); flags such as N_WEAK_REF, N_WEAK_DEF.
n_value0x080x0848ADDRAddress of the symbol (0 if undefined).

n_type

NameValueMeaning
N_STAB0xe0Mask: debugging symbol (stab) if any bit is set.
N_PEXT0x10Private external (was exported, made hidden).
N_TYPE0xeMask for the type:
N_UNDF0  undefined, n_sect == NO_SECT.
N_ABS2  absolute.
N_INDR0xa  indirect (alias).
N_PBUD0xc  prebound undefined.
N_SECT0xe  defined in section n_sect.
N_EXT1External (global) symbol.

Chained fixups

Since macOS 12 / iOS 15, rebases and binds are no longer opcodes in LC_DYLD_INFO: every pointer that needs a fixup is stored in place, already encoded with the information dyld needs and the distance to the next fixup in the same page. LC_DYLD_CHAINED_FIXUPS only gives where each chain starts and the list of imports. dyld walks the chains and replaces each slot with the final pointer.

dyld_chained_fixups_header 28 (0x1c) bytes

FieldOffsetSizeTypeMeaning
fixups_version0x004uint32_t0.
starts_offset0x044uint32_tOffset of dyld_chained_starts_in_image, from the start of this header.
imports_offset0x084uint32_tOffset of the imports table.
symbols_offset0x0c4uint32_tOffset of the imported symbol names.
imports_count0x104uint32_tNumber of imports.
imports_format0x144uint32_tDYLD_CHAINED_IMPORT 1, _ADDEND 2, _ADDEND64 3.
symbols_format0x184uint32_t0 = plain strings, 1 = zlib-compressed.

dyld_chained_starts_in_segment 24 (0x18) bytes

FieldOffsetSizeTypeMeaning
size0x004uint32_tSize of this structure.
page_size0x042uint16_t0x1000 or 0x4000.
pointer_format0x062uint16_tDYLD_CHAINED_PTR_*: how to decode each 64-bit slot.
segment_offset0x088uint64_tOffset of the segment from the start of the image (vmaddr - __TEXT vmaddr).
max_valid_pointer0x104uint32_tFor 32-bit formats.
page_count0x142uint16_tNumber of pages in the segment.
page_start0x162uint16_t[1]Per page: offset of the first fixup, or DYLD_CHAINED_PTR_START_NONE (0xffff).
dyld_chained_starts_in_image before it is uint32_t seg_count followed by one uint32_t seg_info_offset per segment (0 when the segment has no fixups).
NameValueMeaning
DYLD_CHAINED_IMPORT1imports_format: 32-bit dyld_chained_import.
DYLD_CHAINED_IMPORT_ADDEND2imports_format: import with a 32-bit addend.
DYLD_CHAINED_IMPORT_ADDEND643imports_format: import with a 64-bit addend.
DYLD_CHAINED_PTR_START_NONE0xffffpage_start value of a page without fixups.

Pointer formats

NameValueMeaning
DYLD_CHAINED_PTR_ARM64E1arm64e: authenticated pointers, stride 8, targets are vmaddrs.
DYLD_CHAINED_PTR_64264-bit, targets are vmaddrs.
DYLD_CHAINED_PTR_32332-bit.
DYLD_CHAINED_PTR_64_OFFSET664-bit, targets are offsets from the image start (arm64 and x86-64 apps).
DYLD_CHAINED_PTR_ARM64E_KERNEL7arm64e kernel, stride 4.
DYLD_CHAINED_PTR_ARM64E_USERLAND9arm64e user space, targets are offsets.
DYLD_CHAINED_PTR_ARM64E_USERLAND240xcSame with 24-bit bind ordinals.

DYLD_CHAINED_PTR_64 / 64_OFFSET slots

dyld_chained_ptr_64_bind
63bind=11
62–51next12
50–32reserved19
31–24addend8
23–0ordinal24
dyld_chained_ptr_64_rebase
63bind=01
62–51next12
50–44reserved7
43–36high88
35–0target36
dyld_chained_import (imports_format 1)
31–9name_offset23
8weak_import1
7–0lib_ordinal8
next counts 4-byte strides to the next fixup in the page (0 = end of chain). A bind's ordinal indexes the imports table; an import's lib_ordinal is the LC_LOAD_DYLIB number (0 = self, -1 = main executable, -2 = flat lookup, -3 = weak). In the sample, the single __got slot is a bind to import 0, _puts from library 1 (libSystem).

Code signature

LC_CODE_SIGNATURE points to a CS_SuperBlob at the end of __LINKEDIT. On Apple silicon every executable page must be signed, so the linker adds an ad-hoc signature by default. A developer or App Store signature adds requirements, entitlements and a CMS blob with the certificate chain.

CS_SuperBlob 12 (0xc) bytes

FieldOffsetSizeTypeMeaning
magic0x004uint32_tCSMAGIC_EMBEDDED_SIGNATURE 0xfade0cc0.
length0x044uint32_tTotal length of the signature.
count0x084uint32_tNumber of CS_BlobIndex entries that follow.
Code signature structures are big endian.

CS_BlobIndex 8 (0x8) bytes

FieldOffsetSizeTypeMeaning
type0x004uint32_tSlot: CSSLOT_CODEDIRECTORY 0, CSSLOT_REQUIREMENTS 2, CSSLOT_ENTITLEMENTS 5, CSSLOT_SIGNATURESLOT 0x10000 (CMS)...
offset0x044uint32_tOffset of the blob from the start of the SuperBlob.

CS_CodeDirectory 112 (0x70) bytes

FieldOffsetSizeTypeMeaning
magic0x004uint32_tCSMAGIC_CODEDIRECTORY 0xfade0c02.
length0x044uint32_tLength of this blob.
version0x084uint32_tFormat version: 0x20400 adds the exec segment fields, 0x20500 the hardened runtime version.
flags0x0c4uint32_tCS_ADHOC 0x2, CS_RUNTIME 0x10000 (hardened runtime), CS_LINKER_SIGNED 0x20000...
hashOffset0x104uint32_tOffset of code slot 0; special slots are stored before it, at negative indexes.
identOffset0x144uint32_tOffset of the identifier (bundle ID or file name).
nSpecialSlots0x184uint32_tNumber of special slots (hashes of Info.plist, requirements, entitlements...).
nCodeSlots0x1c4uint32_tNumber of page hashes.
codeLimit0x204uint32_tBytes covered by the page hashes (the file up to the signature).
hashSize0x241uint8_t32 for SHA-256.
hashType0x251uint8_tCS_HASHTYPE_SHA1 1, CS_HASHTYPE_SHA256 2.
platform0x261uint8_tNon-zero for platform binaries.
pageSize0x271uint8_tlog2 of the page size hashed (12 = 4 KiB).
spare20x284uint32_t0.
scatterOffset0x2c4uint32_tv 0x20100.
teamOffset0x304uint32_tv 0x20200: offset of the Team ID string.
spare30x344uint32_tv 0x20300.
codeLimit640x388uint64_tv 0x20300: 64-bit code limit.
execSegBase0x408uint64_tv 0x20400: file offset of the executable segment.
execSegLimit0x488uint64_tv 0x20400: size of the executable segment.
execSegFlags0x508uint64_tv 0x20400: CS_EXECSEG_MAIN_BINARY 1, CS_EXECSEG_ALLOW_UNSIGNED 0x10...
runtime0x584uint32_tv 0x20500: SDK version the hardened runtime was built against.
preEncryptOffset0x5c4uint32_tv 0x20500: offset of the hashes of the pages before encryption.
linkageHashType0x601uint8_tv 0x20600: linkage hash fields.
linkageApplicationType0x611uint8_tv 0x20600.
linkageApplicationSubType0x622uint16_tv 0x20600.
linkageOffset0x644uint32_tv 0x20600.
linkageSize0x684uint32_tv 0x20600.
The cdhash of a binary is the hash of this blob. Every 4 KiB page of the file up to codeLimit has its hash in a code slot, and the kernel checks pages when they are faulted in.
NameValueMeaning
CSMAGIC_EMBEDDED_SIGNATURE0xfade0cc0SuperBlob holding the whole signature.
CSMAGIC_CODEDIRECTORY0xfade0c02CodeDirectory: page hashes, identifier, flags.
CSMAGIC_REQUIREMENTS0xfade0c01Internal requirements (designated requirement).
CSMAGIC_EMBEDDED_ENTITLEMENTS0xfade7171Entitlements plist.
CSMAGIC_EMBEDDED_DER_ENTITLEMENTS0xfade7172Entitlements in DER.
CSMAGIC_BLOBWRAPPER0xfade0b01CMS signature (certificate chain). Absent in ad-hoc signatures.
CS_ADHOC2CodeDirectory flag: ad-hoc signed, no certificate.
CS_RUNTIME0x10000CodeDirectory flag: hardened runtime.
CS_LINKER_SIGNED0x20000CodeDirectory flag: ad-hoc signature added by the linker.

Slots and CodeDirectory values

NameValueMeaning
CSSLOT_CODEDIRECTORY0CodeDirectory.
CSSLOT_INFOSLOT1Hash of Info.plist (special slot -1).
CSSLOT_REQUIREMENTS2Requirements.
CSSLOT_RESOURCEDIR3Hash of _CodeSignature/CodeResources (bundles).
CSSLOT_APPLICATION4Application-specific.
CSSLOT_ENTITLEMENTS5Entitlements plist.
CSSLOT_DER_ENTITLEMENTS7DER entitlements.
CSSLOT_ALTERNATE_CODEDIRECTORIES0x1000Additional CodeDirectories (e.g. SHA-1 next to SHA-256).
CSSLOT_SIGNATURESLOT0x10000CMS signature.
CS_HASHTYPE_SHA11hashType: SHA-1.
CS_HASHTYPE_SHA2562hashType: SHA-256.
CS_EXECSEG_MAIN_BINARY1execSegFlags: main executable.
CS_EXECSEG_ALLOW_UNSIGNED0x10execSegFlags: may map unsigned pages (debugging, JIT).

Tools

TaskCommand
Headerotool -hv a.out
Load commandsotool -lv a.out
Linked librariesotool -L a.out
Chained fixups, imports, exportsdyld_info -fixups -imports -exports a.out
Symbolsnm -m a.out
Architectures of a universal binarylipo -info a.out   lipo -thin arm64 -output a.arm64 a.out
Platform and versionsvtool -show a.out
Code signature, entitlementscodesign -dvvv --entitlements - a.out
Disassembleotool -tV a.out   llvm-objdump -d a.out