mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
Merge task/400-standard-output (with upstream main) into task/402-crt-files
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
This commit is contained in:
commit
5ae43a3cb8
21 files changed
+2803
-18
No files matched your search
@@ -48,6 +48,7 @@ either path. The [changelog](../CHANGELOG.md) records notable changes.
|
||||
- [Test inventory comparison](testing/test-inventory.md) — Detect missing or newly ignored Cargo tests across commits.
|
||||
- [Persistent resource and translated rendering acceptance](testing/x9-acceptance.md) — Pinned upstream tests, native ARM64 results and unsupported cases.
|
||||
- [Baseline acceptance](testing/phase-02-baseline.md), [Phase 01 assurance](testing/phase01-assurance.md), and [independent reviews](testing/review-log.md) — Candidate-specific results and release findings.
|
||||
- [Gate A: a compiled C program](testing/gate-a.md) — The two milestones, what the A1 test checks and what it does not show.
|
||||
- [Mutation testing](testing/mutation.md) and [benchmark protocol](testing/benchmarks.md) — Test sensitivity, benchmark inputs, and timing requirements.
|
||||
|
||||
## Research and engineering decisions
|
||||
|
||||
+28
-2
@@ -66,8 +66,34 @@ returns owned words after command completion or a stage-specific error.
|
||||
fixture, guest memory addresses, a service registry and an entry instruction
|
||||
budget. It maps and rebases the image, binds imports, initializes thread-local
|
||||
storage, invokes its callbacks and runs the entry point. The fixture entry point
|
||||
uses a Win64-aligned stack and terminates with HLT. The result includes the loaded
|
||||
guest memory and the entry execution outcome.
|
||||
uses a Win64-aligned stack. It may end with HLT, call `ExitProcess`, or return.
|
||||
The result includes the loaded guest memory and the entry execution outcome.
|
||||
|
||||
A guest ends its process through `kernel32.dll!ExitProcess`, also reachable as
|
||||
`api-ms-win-core-processthreads-l1-1-0.dll!ExitProcess`. Execution stops with
|
||||
`ExitReason::ProcessExit(status)`, where the status is the full 32-bit value
|
||||
the guest passed. Only the guest stops: the host process is not ended. A
|
||||
returning entry point does the same with EAX as the status, which matches
|
||||
Windows while the process has one thread. The exit closes every guest handle:
|
||||
kernel objects, Winsock sockets and task-queue handles, which
|
||||
`ServicesState::open_handle_count` counts together. Files stay on the synthetic `C:` drive, guest memory stays mapped so the host
|
||||
can inspect it, and `atexit` functions are not run: that belongs to the C
|
||||
runtime's `exit`, which is not implemented. `ServicesState::exit_status`
|
||||
reports the status. After an exit the `DbtEngine` that ran the guest executes
|
||||
no further guest instruction and answers every later `run` with the same
|
||||
`ProcessExit`. A service callback that was in progress is never resumed.
|
||||
|
||||
A TLS callback may end the process too. Startup then reports the exit as its
|
||||
outcome, with the status, and runs neither the remaining callbacks nor the
|
||||
entry point; `StartupResult::tls_callbacks` counts the callbacks that finished.
|
||||
Any other stop inside a TLS callback is still a startup error.
|
||||
|
||||
The engine recognises two return addresses, one under the entry point and one
|
||||
under a guest callback, before it executes anything at them. Both are in the
|
||||
4 KiB page at `imports::RETURN_SENTINEL_PAGE`, which startup reserves with no
|
||||
access. An image or layout that covers that page is refused, and a guest
|
||||
allocation there fails. The import trampolines above that page are intercepted
|
||||
in the same way and are not reserved.
|
||||
|
||||
Loading an image maps its headers as well as its sections. The first
|
||||
`SizeOfHeaders` bytes of the file are mapped read-only at the image base, in
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Gate A: a compiled C program
|
||||
|
||||
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 | Not started |
|
||||
|
||||
## A1
|
||||
|
||||
The program is [`tests/compat_fixtures/gate_a1.c`](../../tests/compat_fixtures/gate_a1.c).
|
||||
Its build configuration and provenance are in
|
||||
[`tests/compat_fixtures/README.md`](../../tests/compat_fixtures/README.md#gate-a1-a-c-program-with-no-c-library).
|
||||
The gate is `crates/loader/tests/gate_a1.rs`:
|
||||
|
||||
```sh
|
||||
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
|
||||
|
||||
Not started. It needs at least the C standard I/O functions, `exit` with
|
||||
`atexit` handlers, command-line and environment access, and a decision on
|
||||
which C runtime startup code may be linked and under what licence. None of
|
||||
those are registered today.
|
||||
Reference in new issue
Block a user