wire / wire-format / macho-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.
aka: Mach-O 64-bit header
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.
| field | size | meaning |
|---|---|---|
| magic | 4 bytes | 0xFEEDFACF (64-bit LE) or 0xCFFAEDFE (swapped). 32-bit: 0xFEEDFACE. |
| cputype | 4 bytes | CPU family: 7 x86, 12 ARM, 16808692 (0x01000007) x86_64, 16777228 (0x0100000C) ARM64. |
| cpusubtype | 4 bytes | CPU subtype (e.g. 3 for x86 ALL, 0 for ARM64 ALL). |
| filetype | 4 bytes | 1 object, 2 execute, 3 FVMLIB, 4 core, 5 preload, 6 dylib, 7 dylinker, 8 bundle, 9 dylib stub, 10 dSYM, 11 kext. |
| ncmds | 4 bytes | Number of load commands following the header. |
| sizeofcmds | 4 bytes | Total size in bytes of all load commands. |
| flags | 4 bytes | MH_NOUNDEFS, MH_DYLDLINK, MH_PIE, MH_ALLOW_STACK_EXECUTION, ... (e.g. 0x00200085 for a PIE executable). |
| reserved | 4 bytes | Reserved (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
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/macho-header
or /wire-format/macho-header.json