Skip to content

Mach-O Reference

LC_DYLD_INFO

LC_DYLD_INFO — rebase, bind and export

LC_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.

What it is

LC_DYLD_INFO (and its common form LC_DYLD_INFO_ONLY) tells dyld how to patch an image once it is mapped. Rather than a table, each kind of fix-up is a small bytecode stream that an interpreter runs. The command is a set of offset/size pairs pointing into __LINKEDIT.

FieldMeaning
rebase_off / rebase_sizeSlide fix-ups: adjust internal pointers for the image's actual load address (ASLR).
bind_off / bind_sizeBind imports to symbols in the dylibs at load time.
weak_bind_off / weak_bind_sizeResolve weak symbols shared across images so one definition wins.
lazy_bind_off / lazy_bind_sizeBind imported functions on first call instead of at launch.
export_off / export_sizeThe export trie: the symbols this image makes available.

LC_DYLD_INFO_ONLY is the same structure flagged LC_REQ_DYLD to mean the information is complete — there is no separate relocation table to fall back on.

Rebasing and binding

Rebase opcodes walk a list of locations and add the image's slide (the difference between its preferred and actual load address) to each pointer there. Bind opcodes name a library and a symbol and store the resolved address into a location — this is how an undefined symbol becomes a real pointer into libSystem or another dependency.

The export trie

Exports are stored as a trie keyed by symbol name: shared prefixes are walked once, and each terminal node carries the symbol's address (or a re-export pointing at another library). It is a compact way to answer "does this image export name X, and at what address".

Newer formats

Recent toolchains replace these streams with LC_DYLD_CHAINED_FIXUPS (chained fix-ups) and LC_DYLD_EXPORTS_TRIE, which store the same information more compactly. A parser should expect either form after the load commands.