Skip to content

Recognize bit-test guarded masked jump tables - #2108

Open
thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/tbnz-masked-jump-table
Open

thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/tbnz-masked-jump-table

Conversation

@thehobbit85

Copy link
Copy Markdown
Contributor

What and why

Refs #960 (partial fix; the issue remains open).

Ultra Street Fighter II's main+0x590ee8 uses a bit-test guard followed by a masked table index, so the rewriter aborts despite the table having a provable extent. On the fall-through path of tbnz wS,#B,exit, bit B is clear; the following low-bit mask leaves exactly 2^B entries. Treating the mask plus one as the count would read unreachable words.

Add a final fallback for this exact adjacent dispatch, with a full-width ADRP/ADD base and verified incoming paths. It rejects clobbers, gaps, calls and branches that bypass the proof; module-wide checks also reject incoming branches and tables resolved later. Existing recognizers retain priority. Credit to PikaMan80 for the report and original pattern.

The separate dispatch at main+0x7d3000, SDK 1 audio support and full game compatibility remain outside this change. PR #1937 handles CMP-based masked dispatches across control flow, not this TBNZ form; #966/#967 cover other parts of #960. Current main and all-state PRs were rechecked before publishing.

Durable finding: bit-test bounded masked jump-table index.

Checked

Tested base: bbea4c90f136f478e25228bc3d4ab33c77420f2e; tested head: de0dfe2e2704b69d66d19ab98ad3d70c72fafa4e. Latest main 6d9edb079b2edfa5e8a85753b1740ef4275b383a adds unrelated texture-streaming changes; the tested head merges cleanly with it and its rewriter is unchanged. Environment: Apple M2 Max, macOS 26.6, native arm64 Python 3.14.6, Capstone 5.0.7.

The required scripts/regress.py check --games 010032E00E6E2000,0100698009C6E000,01006A800016E000,01006C300E9F0000,010067300059A000 was attempted but exits 2: REGRESS_ROOT/REGRESS_GAMES are not configured and no local game files are available. No gameplay, extracted-game rewrite comparison or iOS runtime validation is claimed. Selected regression targets:

Game Reason
Return of the Obra Dinn Complemented masked-index fallback
Blasphemous Forward table-base initializer
Super Smash Bros. Ultimate Far/copied table base
Dragon Quest XI S Index copied before guard
Mario + Rabbids Kingdom Battle Far index-copy chain

Ultra Street Fighter II has no repository profile or local assets here. Other games remain unchecked.

Docs

  • General finding added to docs/reference/rewriter.md; symptom index regenerated and developer documentation updated. No existing game note is available for this title.
  • No game files, keys, extracted game data or agent planning/journal files are included.
  • Shader chain unchanged; this is a rewriter change.

@github-actions github-actions Bot added rewriter The NSO rewriter and per-build patches tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation rewriter The NSO rewriter and per-build patches tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants