7.2 KiB
Gate A: a compiled C program
Historical native record. Plans and results below retain their original candidate scope. Native development is paused under ADR 0005; follow the hybrid architecture for active priorities.
Gate A asks for an independently compiled C program, exercising allocation, file operations, arithmetic, function calls and error handling, to run through Xenora. The maintainer split it into two milestones. Gate A is complete only when both pass.
| Milestone | What it is | Status |
|---|---|---|
| A1 | An original C program with no C library linked, importing documented kernel32.dll and ucrtbase.dll functions, run through the loader and the ARM64 DBT with proper process exit |
Passes locally; awaiting independent review |
| A2 | A hosted C program: a real C runtime startup, the standard C library, argc and argv, stdio and formatted output, normal exit and runtime cleanup |
Passes locally; awaiting independent review |
A1
The program is tests/compat_fixtures/gate_a1.c.
Its build configuration and provenance are in
tests/compat_fixtures/README.md.
The gate is crates/loader/tests/gate_a1.rs:
cargo test --locked -p xenora-loader --test gate_a1 -- --nocapture
The test builds the program from source, then runs each build through
run_synthetic_startup with register_standard_services, loaded away from its
preferred base. It checks, at -O0, -O1, -O2 and -Os:
- the 20 imports are bound and the 6 base relocations applied;
- the guest ends with
ExitReason::ProcessExit(0x00A1A1A1), all 32 bits; - it ran as translated code, with service calls;
- the text report it wrote matches a report recomputed in Rust;
- the data file holds the 64 sorted records, the file it looked for does not exist, and the handle it left open was closed by the exit;
- its result block in guest memory holds the expected values, the block it kept is readable and the block it freed is unmapped.
Three controls must fail in the stated way: a wrong expectation exits with the
number of the failed check, an import that no service provides is refused
before entry, and a step budget that is too small is not an exit. A variant
whose entry point returns its status gives the same result as ExitProcess.
What A1 does not show
- It is one program. Local runs used Homebrew clang 23.1.6 and Apple clang 17.0.0, each with LLD 23.1.5. Another compiler or a larger program can need instructions and services this one does not.
- Most services it calls are marked partial in the registry. They did what this program needs.
- It runs in the DBT only. The interpreter has no import dispatch.
- It reaches the guest through a test, not through
xenora run, which accepts only two built-in fixtures. - Nothing here concerns a commercial game or an Xbox launch environment.
A2
The program is tests/compat_fixtures/gate_a2.c.
Its build configuration and provenance are in
tests/compat_fixtures/README.md.
The gate is crates/loader/tests/gate_a2.rs:
cargo test --locked -p xenora-loader --test gate_a2 -- --nocapture
"Hosted" means the program is linked with a real C runtime, whose own startup
code runs before main. Here that runtime is mingw-w64's, in its UCRT
flavour: the startup objects and a little of GCC's support library are linked
into the executable, and the C library itself is imported by name from the
Universal C Runtime's API-set DLLs and from kernel32.dll. Xenora's services
answer those imports. Nothing from Windows is loaded.
The test builds the program from source with x86_64-w64-mingw32-gcc. It
fails, and does not skip, when that compiler is missing. It then runs each
build through run_synthetic_startup with register_standard_services,
loaded away from its preferred base, with the command line
gate-a2.exe 2026 xenora set through ServicesState::set_program_arguments.
It checks, at -O0, -O1, -O2 and -Os:
- every import is bound (50 at each level with the toolchain used locally; the test prints the count) and base relocations are applied;
- the guest ends with
ExitReason::ProcessExit(0):mainreturned and the runtime's startup code passed its result toexit; - captured standard output equals, byte for byte, text recomputed in Rust from the description of the program, including the line a function registered with
atexitprints aftermainhas returned; standard error is empty; - the report file the program wrote with
fprintfandfputsis on the in-memory drive with the recomputed contents, the file it looked for was not created, and no handle is left open; - it ran as translated code, with service calls.
The program checks its own results as well: it prints its arguments, fills
heap memory from a small generator, sorts it with qsort and a callback,
checksums it before and after, writes the report, reads it back with fgets,
strtoul and strtoull, and confirms that a missing file is reported. It
exits with the number of the first check that fails, and counts the checks
that passed; a complete run counts 76.
Seven more tests guard against a runtime that reports success for everything:
- another seed and label give another output and another report;
- four wrong command lines each fail the check that looks at them, with that check's number as the exit status and its message on standard error;
- a variant with one wrong expectation exits with 22;
- a variant that calls
exit(42)half way ends with 42, itsatexitfunction still runs, and the report is never written; - a variant that calls
abort()half way ends with 3 and itsatexitfunction does not run; - a step budget that is too small is not an exit;
- the Rust restatement of the program is itself checked not to be degenerate.
What A2 does not show
- It is one program and one C runtime: mingw-w64 14.0.0 with GCC 16.2.0 locally. A program built with Microsoft's compiler starts differently and imports other functions; none has been tried. A larger program can need instructions and services this one does not.
- The same source built natively with Apple clang prints the same text once carriage returns are removed. That comparison was made by hand and is not part of the test. Nothing was compared with Windows or with x86 hardware.
- No floating point is formatted and no input is read.
printfrefuses the floating-point and wide-character conversions, andstdinand thescanffamily do not exist. - Most services the program calls are marked partial in the registry. No locale exists, no signal handler or exception filter is ever called, the environment table is empty, and a C stream is unbuffered and has no seek. They did what this program needs.
VirtualProtect,VirtualQueryand__C_specific_handlerare stubs that stop the guest if called. The program imports them and never calls them.- It runs in the DBT only, on one guest thread.
- It reaches the guest through a test, not through
xenora run. - Nothing here concerns a commercial game or an Xbox launch environment.