Commit Graph
3 Commits
Author SHA1 Message Date
zachdoxsee 0a17f0cb73 loader: add the Gate A2 hosted C program and its test (#419)
An original C program, tests/compat_fixtures/gate_a2.c, is built from
source with the mingw-w64 C runtime (UCRT) and run through the loader, the
standard services and the ARM64 DBT. The runtime's own startup code runs
before main; the program uses argc and argv, the heap, qsort, printf, a file
written with fprintf and read back with fgets, atexit, and a return from
main. Expected output is recomputed in Rust, not read back from a run.
Control variants end in a failed check, in exit(42) and in abort().

The test fails, and does not skip, when the compiler is missing, so the CI
workflow installs mingw-w64. Nothing from mingw-w64 is stored in the
repository.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 02:25:26 +01:00
zachdoxsee d326e929a9 loader: add exit, _exit and abort for a hosted C program (#395)
A C program ends through the C runtime's exit, not ExitProcess, and a
program built with the mingw-w64 runtime imports exit, _exit and abort.
None resolved, so the loader refused the program before its entry point.

exit calls the functions registered with atexit and _crt_atexit, most
recently registered first, then ends the guest with ProcessExit(status).
_exit ends it with its status and abort with exit code 3; neither calls a
registered function. All three use the cleanup behind ExitProcess.

Built on the process exit from #329. Part of Gate A2.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-25 00:47:33 +01:00
zachdoxsee 47cb26ebdd loader: add process exit and the Gate A1 compiled C program (#329)
A guest can now end its process. kernel32.dll!ExitProcess stops execution
with the new ExitReason::ProcessExit(status), keeping all 32 bits of the
status, and never ends the host. A returning entry point does the same
with EAX: startup puts an exit address under the entry point. The exit
closes every guest handle, and the DbtEngine that ran the guest executes
no further guest instruction.

Gate A1 is an original C program with no C library linked. The test
builds it from source with clang and an LLD, runs it through
run_synthetic_startup, the standard services and the DBT at four
optimization levels, and checks its exit status, report, files and
memory against values recomputed in Rust. Three controls must fail in
the stated way. Gate A stays open until the hosted milestone, A2.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 17:42:09 +01:00