Skip to main content

Module fixture

Module fixture 

Source
Expand description

Synthetic license-clean Mach-O arm64 fixtures (generated, not from Apple).

Used by unit tests and to produce checked-in binaries under tests/fixtures/.

Constants§

CALL_DYLIB_GOT_VA
Preferred GOT VA of call_dylib_exit (__DATA,__got).
CALL_LIBSYSTEM_GOT_VA
Preferred GOT VA of call_libsystem_exit (__DATA,__got).
KH_ADD_SYMBOL
Symbol name exported by arm64_dylib_add and imported by call_dylib_exit.
KH_BOTTLE_MARK_SYMBOL
Symbol exported by synthetic bottle libSystem and imported by call_libsystem_exit.
KH_BOTTLE_MARK_VALUE
Return value of _kh_bottle_mark / guest exit code of call_libsystem_exit.
LIBKH_ADD_INSTALL_NAME
Install name / sibling path for the synthetic add dylib.
LIBKH_ADD_TEXT_VA
Preferred TEXT VA of arm64_dylib_add (and _kh_add n_value).
LIBKH_CTOR_INSTALL_NAME
Install name for the constructor dylib fixture.
LIBKH_CTOR_TEXT_VA
Preferred TEXT base of arm64_dylib_ctor.
LIBSYSTEM_EXIT_SYMBOL
Darwin _exit(2) — C _exit → nlist __exit.
LIBSYSTEM_INSTALL_NAME
Absolute install name for the synthetic bottle libSystem stub.
LIBSYSTEM_PRINTF_SYMBOL
C printf → nlist _printf (host helper; no % conversions yet).
LIBSYSTEM_PUTS_SYMBOL
C puts → nlist _puts (host helper).
LIBSYSTEM_TEXT_VA
Preferred TEXT base of arm64_libsystem_stub.
LIBSYSTEM_WRITE_SYMBOL
Darwin write(2) — C write → nlist _write.
ROUNDTRIP_PAYLOAD
Payload bytes for memory_file_roundtrip (written next to the Mach-O).
ROUNDTRIP_PAYLOAD_PATH
Relative path embedded in memory_file_roundtrip (cwd = repo /app root).

Functions§

arm64_dylib_add
Synthetic MH_DYLIB: exports _kh_add as add w0,w0,w1; ret.
arm64_dylib_ctor
Synthetic MH_DYLIB with one S_MOD_INIT_FUNC_POINTERS entry.
arm64_execute_with_text
Builds a minimal little-endian MH_EXECUTE arm64 Mach-O with custom text.
arm64_libsystem_stub
Synthetic bottle libSystem.B.dylib with a growing C-ABI surface:
bsdthread_create_join
Micro program: bsdthread_register + bsdthread_create worker, join via flag, exit(0).
call_dylib_chained_exit
Same program as call_dylib_exit, but linking uses LC_DYLD_CHAINED_FIXUPS (DYLD_CHAINED_PTR_64 bind of _kh_add into __got) instead of classic bind opcodes.
call_dylib_exit
Synthetic MH_EXECUTE: load @executable_path/libkh_add.dylib, call _kh_add(20,22), exit with the sum (42). Also declares decorative /usr/lib/libSystem.B.dylib.
call_libsystem_exit
Synthetic MH_EXECUTE: load absolute /usr/lib/libSystem.B.dylib, call _kh_bottle_mark, exit with 77.
ctor_main_exit
Synthetic MH_EXECUTE that loads LIBKH_CTOR_INSTALL_NAME then exit(0).
errno_unknown_then_exit
Micro program: unknown syscall (x16=0xBEEF) then exit(0).
memory_file_roundtrip
Ultimate static fixture: open → fstat64 → file mmap → mutate → mprotect → msync → clock_gettime → sysctlbyname → munmap → close → exit(0).
minimal_arm64_execute
Micro program: write(1, "kh\\n", 3); exit(0).
mmap_touch_exit
Micro program: anonymous mmap + write byte + munmap + exit(0).
wrap_fat_arm64_only
Wraps a thin arm64 Mach-O in a single-arch fat container (big-endian fat header).