Skip to content

Generate bionic thread-slot accesses in ARM64 rewrites - #3

Closed
thehobbit85 wants to merge 3 commits into
codex/port-01-rewrite-abifrom
codex/port-02-android-rewriter
Closed

thehobbit85 wants to merge 3 commits into
codex/port-01-rewrite-abifrom
codex/port-02-android-rewriter

Conversation

@thehobbit85

@thehobbit85 thehobbit85 commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

The offline rewriter can now generate the bionic thread-slot accesses used by the Android port. Pass --thread-slots android to dm/tools/patch_nso.py and use a separate output directory. Every generated slot lookup reads the host block through bionic's TLS slot. The fixups header identifies the layout to the loader.

The default remains the Apple ABI. The Android option is for offline module preparation. A runnable Android app also needs the host gates, per-thread initialization and signal handling.

Checked

  • A synthetic NSO exercises ordinary thread-slot operations, moves to and from virtual x18, and discarded reads to xzr on both targets. A review regression reproduced physical x18 being overwritten before the fix. The Android assertion failed on the parent and passed with this change. The final Python tool suite ran 907 tests, with 16 skips and no failures. The focused rewriter and documentation suite passed (38 tests). The pinned Python lint ratchet reports zero new findings.
  • Rewrote the retail SDK from Pokémon Legends: Z-A v393216 using the parent and both target options. All seven default Apple module output files were byte-identical to the parent. The Android output had TP_SLOT=2, a different image, the same site table and 15,086 generated slot references.
  • No Android device run. The Hollow Knight dump is unavailable locally. The project pins Metal 32023.922. With the installed 32023.921 compiler enabled for both revisions, the Z-A shader comparison passed. Its profile has no smoke route; the retail SDK rewrite above is a separate comparison.

Stacked on #2. Its base is the Apple loader guard. Retarget to the fork's main after that guard merges.

Regression report

regress.py check (full): PASS

Baseline codex/port-01-rewrite-abi 09472c2, candidate codex/port-02-android-rewriter 50086de; Apple M2 Max, macOS 26.6, Xcode 27.0; 105.4 s

game status shaders (base → cand) newly failing newly building changed MSL interface (new / known) boot fps p50 frame p99 ms peak MB prepare s new RED
LegendsZA 0100F43008C44000 PASS 28603/28603 → 28603/28603 0 0 0 0 / 0 – – – – – –

LegendsZA 0100F43008C44000: PASS

  • time: chain 104.9 s

seedds and others added 2 commits November 2, 2026 16:36
Adapt the bionic TLS_SLOT_APP convention from the Android port (joaquinsandoval2307/nxnative at 1b2fc7b). Select it explicitly for each offline rewrite.

Co-authored-by: Joaquin Sandoval <279042628+joaquinsandoval2307@users.noreply.github.com>
@thehobbit85 thehobbit85 closed this Nov 3, 2026
@thehobbit85
thehobbit85 deleted the codex/port-02-android-rewriter branch November 3, 2026 04:44
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.

2 participants