Mach-O Reference
The structures that make up a Mach-O file — the header, each load command, segments and sections, and the code-signing data.
10 entries
Code signingCode signing and entitlementsHow a Mach-O code signature works: the CodeDirectory that hashes the image, the cdhash that identifies it, the entitlements that grant it privileges, and what ad-hoc versus CMS-signed means.
LC_CODE_SIGNATURELC_CODE_SIGNATURE — the embedded signatureLC_CODE_SIGNATURE points at the Code Signing SuperBlob stored at the end of a Mach-O file: the CodeDirectory, the entitlements, the requirements and the CMS signature that together sign the image.
LC_DYLD_INFOLC_DYLD_INFO — rebase, bind and exportLC_DYLD_INFO hands dyld compact bytecode streams that fix up an image at load time: rebasing pointers for ASLR, binding imports, and the export trie.
LC_LOAD_DYLIBLC_LOAD_DYLIB — linked dynamic librariesEach LC_LOAD_DYLIB records one dynamic library the image depends on, with its install name and version. Weak, re-export and upward variants change how the dependency is treated.
LC_MAINLC_MAIN and LC_UNIXTHREAD — the entry pointLC_MAIN gives an executable's entry point as a file offset; LC_UNIXTHREAD is the older form carrying a full initial register state. One of them starts the program.
LC_SYMTABLC_SYMTAB — the symbol and string tablesLC_SYMTAB is the load command that locates a Mach-O file's classic symbol table: an array of nlist entries plus the string table their names point into. It is what nm and a linker read.
LC_UUIDLC_UUID — the build's unique identifierLC_UUID stamps a Mach-O image with a 128-bit identifier unique to that exact build. It is what ties a crash report or dSYM back to the binary it came from.
LC_SEGMENT_64LC_SEGMENT_64 — segments and sectionsLC_SEGMENT_64 describes a region of the file to map into memory — __TEXT, __DATA, __LINKEDIT — together with the sections inside it and the protections the segment is mapped with.
Load commandsLoad commandsAfter the header, a Mach-O file is a sequence of load commands: variable-length records that tell the loader how to map segments, which libraries to link, where the entry point is, and more.
mach_header_64The Mach-O header (mach_header_64)Every Mach-O file starts with a header giving its magic number, CPU type, file type and the count and size of the load commands that follow. It's the first thing a parser reads.