Mach-O Reference
Load commandsLoad commands
After 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.
What they are
Immediately after the header, a Mach-O file is a
list of load commands — variable-length records, each starting with a
cmd (its type) and a cmdsize (its length in bytes). The header's ncmds
and sizeofcmds bound the list, so a parser can walk it by repeatedly reading
cmd/cmdsize and jumping forward.
Common commands
| Command | Purpose |
|---|---|
LC_SEGMENT_64 | Map a segment and its sections. |
LC_SYMTAB | Locate the symbol and string tables. |
LC_DYSYMTAB | Dynamic-linking symbol information. |
LC_LOAD_DYLIB | A dynamic library the image depends on. |
LC_MAIN | The entry point (file offset of main). |
LC_CODE_SIGNATURE | Offset/size of the embedded code signature. |
LC_UUID | A unique build identifier. |
LC_DYLD_INFO(_ONLY) | Rebase, bind and export tables for dyld. |
Why they matter
The load commands are the file's table of contents: everything a parser or the
dynamic linker needs — where code and data live, what to link, how to verify the
signature — is described here rather than inferred. Unknown commands are skipped
by cmdsize, which keeps the format forward-compatible.