Mach-O Reference
LC_LOAD_DYLIBLC_LOAD_DYLIB — linked dynamic libraries
Each 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.
What it is
A Mach-O image lists each shared library it links against with a dedicated
load command. The common one is
LC_LOAD_DYLIB; several variants share the exact same structure and differ
only in how dyld treats the dependency.
The dylib_command
| Field | Meaning |
|---|---|
cmd | The variant (see below). |
cmdsize | Command length, including the padded name. |
dylib.name | Offset to the install name string (e.g. /usr/lib/libSystem.B.dylib). |
dylib.timestamp | Build timestamp (usually 2, a placeholder, today). |
dylib.current_version | The library's version, packed as X.Y.Z in 16.8.8 bits. |
dylib.compatibility_version | The oldest version this image can run against. |
The name is stored as an lc_str: an offset, relative to the start of the
command, to a NUL-terminated string that fills the rest of cmdsize.
The variants
| Command | Meaning |
|---|---|
LC_LOAD_DYLIB | A normal, required dependency. |
LC_LOAD_WEAK_DYLIB | Weak: if the library is missing, undefined symbols become null instead of failing the load. |
LC_REEXPORT_DYLIB | The image re-exports the library's symbols as its own (umbrella frameworks). |
LC_LOAD_UPWARD_DYLIB | An upward dependency, used to break mutual-dependency cycles. |
LC_LAZY_LOAD_DYLIB | Loaded on first use rather than at launch. |
LC_ID_DYLIB | Not a dependency — a library's own install name and version. Present only in MH_DYLIB files. |
Versions
current_version and compatibility_version are 32-bit numbers decoded as
major.minor.patch using a 16-bit major and two 8-bit fields — so 0x054f2803
reads as 1359.40.3. The dynamic linker refuses to load a library whose
current_version is lower than the compatibility_version an image was built
against. Undefined symbols these libraries supply appear in the image's
symbol table as N_UNDF entries.