Skip to content

0.23.5: a part of fork the library does not export is not called - #51

Merged
Sunrisepeak merged 3 commits into
mainfrom
eco/0.23.5-parts-absent
Nov 18, 2026
Merged

Sunrisepeak merged 3 commits into
mainfrom
eco/0.23.5-parts-absent

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

The defect

kal_space_start (and a confined start) calls the parts of libSystem's own fork by their names — _dyld_atfork_*, _malloc_fork_*, _libc_fork_*, _pthread_atfork_*, _mach_fork_child — as ordinary imports. A system built from the same sources whose library does not export every one of them refuses the whole program at load:

dyld: Symbol not found: __pthread_atfork_prepare
  Referenced from: /private/tmp/t/./cmd.exe
  Expected in: /usr/lib/libSystem.B.dylib

Measured on PureDarwin 26.5 (xnu-12377, x86_64) with a program of x86_64-macos-musl.

The change

The thirteen names are weak imports, and each is called when it is bound. On macOS all of them are bound and the calls are the ones made before. A part that is absent is not called: the state it would have prepared belongs to a part the program cannot reach either.

Measured

The same program, rebuilt against this branch, starts on PureDarwin 26.5 and runs a batch script that makes, copies, renames, lists and removes files, with the output it gives on Linux. llvm-nm -m shows the thirteen names as weak external … (from libSystem).

@Sunrisepeak
Sunrisepeak merged commit 9dbc36f into main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant