commit 0923ace04396499cebb5a831c76a4678276b5365
parent a3daf2745aee5bd7ea3e1f560d2bfeeaac255565
Author: anon <anon@example.com>
Date: Tue, 13 Oct 2026 01:03:36 +0000
Link and execute original AO code across rebased DLLs
Diffstat:
2 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -14,6 +14,7 @@ browser/native-render/src/generated.rs
browser/native-render/src/generated/
browser/native-render/data/
browser/native-render/report.html
+browser/native-render/linked-generated/
tools/*.json
tools/*.png
tools/*.jpg
diff --git a/docs/browser-porting.md b/docs/browser-porting.md
@@ -360,7 +360,7 @@ there were no warning/error console messages. Evidence is retained in
Reproduction instructions are in [browser/native-render/README.md](../browser/native-render/README.md).
This does not establish full AO startup, world rendering or usable performance.
-### Native DLL linkage remains necessary
+### Native DLL linkage
The inspected Theseus architecture currently describes one DOS or Windows
module per translation. Its CLI accepts EXE/COM filenames; its lower-level PE
@@ -380,9 +380,61 @@ also be accounted for. Code discovery must include indirect targets, exports
and runtime-observed missing addresses; translating only the EXE entry point
cannot establish complete coverage.
-The next bounded linking test should execute an original imported function
-across two game modules before attempting their complete startup. That isolates
-IAT resolution and guest calling conventions from unfinished Windows APIs.
+The local translator now adds a minimal PE linker around Theseus. It maps
+complete images at separate guest bases, applies native HIGHLOW relocations,
+indexes exports by exact decorated name and ordinal, and patches native IAT
+slots with guest addresses. The linked images use one generated block table.
+Native calls retain their original instructions and calling convention; they
+do not pass through a host stdcall wrapper or require C++ names to become Rust
+identifiers.
+
+A concrete AO 13.2 pair now executes natively and in WASM:
+
+| Property | Caller | Callee |
+| --- | --- | --- |
+| DLL | `ggr.dll` | `mr.dll` |
+| Export | `??0TileCollPoly_t@@QAE@XZ` | `??0Vector3_t@@QAE@XZ` |
+| Ordinal | 47 | 25 |
+| Original RVA / length | `0x6340` / 32 bytes | `0x1000` / 13 bytes |
+| Preferred image base | `0x10000000` | `0x10000000` |
+| Tested guest base | `0x100000` | `0x130000` |
+| Image size | `0x21000` | `0xa000` |
+
+The collision-polygon constructor initializes three consecutive 12-byte
+vectors. It loads ECX with each vector address and calls the vector constructor
+through IAT RVA `0x190dc`. A HIGHLOW relocation at caller RVA `0x6350` adjusts
+that instruction's absolute IAT operand. The callee zeros three dwords and
+returns its ECX input in EAX; it clears ECX, so the caller resets ECX each time.
+Both constructors take no stack arguments and need no initialized globals or
+Windows APIs. The caller returns the original polygon address in EAX.
+
+The tested `ggr.dll` SHA-256 is
+`516dfd54afc8e79dbdee8fae7a6eeebdf8081f29366f7adea1e51c8303ab0e96`;
+`mr.dll` is
+`f2057e6b18a6b2488d1bde3c63539a5e3ff1e3ce5388b57275028093abceced6`.
+Neither export table has forwarders. Both relocation tables contain only
+ABSOLUTE padding and HIGHLOW entries. Decoded instructions and PE metadata are
+retained in `tools/browser-reference/link-fixture.json` and `link-fixture-pe.json`.
+
+Generation verifies that the rebased IAT operand is `0x1190dc`, and that its
+resolved target is `0x131000`. Execution starts with a nonzero 36-byte object,
+guards and distinct saved-register values. The native test and browser both
+verify nine zero dwords, intact guards, EAX equal to the input object, preserved
+EBX/ESI/EDI/EBP and restored ESP. Browser console warning/error messages were
+empty. Evidence is `tools/browser-native-link-runtime.json` and
+`tools/browser-native-link.png`.
+
+This links 16 native imports from ggr to mr, but only the selected constructor
+pair is translated and executed. The fixture uses name imports; ordinal export
+aliases are checked, while an executed ordinal-import case remains untested.
+The other 41 ggr imports and 14 mr imports have no loaded implementation and
+are explicitly null in this bounded image. Calling those paths would fail.
+Forwarders are rejected. DLL initialization, TLS and full dependency loading
+remain unfinished; success here does not establish client startup.
+
+The next startup work needs to retain this native import path while connecting
+the remaining imports to Windows/CRT implementations, discover the required
+DLL initialization order, and register dynamically requested guest exports.
### Graphics and editable Rust boundaries