Skip to content

Mach-O Reference

Load commands

Load 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

CommandPurpose
LC_SEGMENT_64Map a segment and its sections.
LC_SYMTABLocate the symbol and string tables.
LC_DYSYMTABDynamic-linking symbol information.
LC_LOAD_DYLIBA dynamic library the image depends on.
LC_MAINThe entry point (file offset of main).
LC_CODE_SIGNATUREOffset/size of the embedded code signature.
LC_UUIDA 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.