wire / wire-format / macho-header

Mach-O 64-bit header

A Mach-O 64-bit file (macOS/iOS) begins with a 32-byte header: magic (0xFEEDFACF for 64-bit little-endian), CPU type/subtype, file type (object/executable/dylib/bundle/core), number of load commands, size of load commands, and flags.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Mach-O 64-bit header

wire format

spec: Apple Mach-O File Format Reference

A Mach-O 64-bit file (macOS/iOS) begins with a 32-byte header: magic (0xFEEDFACF for 64-bit little-endian), CPU type/subtype, file type (object/executable/dylib/bundle/core), number of load commands, size of load commands, and flags.

fieldsizemeaning
magic4 bytes0xFEEDFACF (64-bit LE) or 0xCFFAEDFE (swapped). 32-bit: 0xFEEDFACE.
cputype4 bytesCPU family: 7 x86, 12 ARM, 16808692 (0x01000007) x86_64, 16777228 (0x0100000C) ARM64.
cpusubtype4 bytesCPU subtype (e.g. 3 for x86 ALL, 0 for ARM64 ALL).
filetype4 bytes1 object, 2 execute, 3 FVMLIB, 4 core, 5 preload, 6 dylib, 7 dylinker, 8 bundle, 9 dylib stub, 10 dSYM, 11 kext.
ncmds4 bytesNumber of load commands following the header.
sizeofcmds4 bytesTotal size in bytes of all load commands.
flags4 bytesMH_NOUNDEFS, MH_DYLDLINK, MH_PIE, MH_ALLOW_STACK_EXECUTION, ... (e.g. 0x00200085 for a PIE executable).
reserved4 bytesReserved (must be 0) in 64-bit.

example:

cf fa ed fe 07 00 00 01 03 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Mach-O 64-bit little-endian magic + cputype 7 (x86) + subtype 3


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/macho-header or /wire-format/macho-header.json