Skip to main content

Module init

Module init 

Source
Expand description

Load-time initializers (S_MOD_INIT_FUNC_POINTERS / S_INIT_FUNC_OFFSETS).

After map + bind, dyld runs module constructors bottom-up (dependencies before dependents) before transferring to LC_MAIN. Phase 7 implements the same order for mapped images using kh_runtime::call_guest.

Modern Apple toolchains emit __TEXT,__init_offsets (S_INIT_FUNC_OFFSETS) with 32-bit image-relative offsets instead of classic pointer arrays. Real guests such as 7zz use that form; classic fixtures keep mod_init_func.

Structs§

InitFunc
One initializer to invoke (already slide-adjusted guest VA).

Constants§

SECTION_TYPE
Mask for Mach-O section type bits in flags.
S_INIT_FUNC_OFFSETS
Section type: 32-bit offsets to initializers (S_INIT_FUNC_OFFSETS).
S_MOD_INIT_FUNC_POINTERS
Section type: array of function pointers run at load (S_MOD_INIT_FUNC_POINTERS).

Functions§

collect_mod_init
Collects initializer VAs for one mapped image.
plan_initializers
Bottom-up initializer list: mapped dylibs in reverse map order, then main.
run_initializers
Runs all planned initializers on guest_sp (16-byte aligned).