Repository navigation
Conversation
The `br x18` offset-table recognizer in `jump_offsets` only accepted the
form whose temporary and index register are both x18:
cmp w18, #N
ldrsw x18, [Rb, x18, lsl seedds#2]
add x18, x18, Rb
br x18
Unity / IL2CPP builds use the same table shape with other registers. A
new title (Cuphead, Unity 2017.4.9f1, SDK 5.5.0.0) has three, and every
one of them aborted the rewriter with `AssertionError: jump table <addr>`:
main+0x2bceb0: cmp w9,seedds#9 ; ldrsw x18,[x12,x9,lsl seedds#2] ; add x18,x18,x12 ; br x18
sdk +0x248e28: cmp w0,seedds#5 ; ldrsw x18,[x9,x0,lsl seedds#2] ; add x18,x18,x9 ; br x18
main+0x1bb872c: cmp w17,seedds#7 ; ldrsw x17,[x15,x17,lsl seedds#2]; add x18,x17,x15 ; br x18
This change recognises the family: the temporary `t` and the index `i` of
`add x18, t, Rb` / `ldrsw t, [Rb, i, lsl seedds#2]` / `cmp w<i>, #N` are no
longer required to be x18. With all three shapes handled, Cuphead's
main/sdk/subsdk0/rtld rewrite cleanly (main: 15265 plain, the 3 tables).
It is a strict superset of the old patterns, so for a site the old code
accepted the new code derives the same table base, the same N and the
same targets -- Mario's and Engage's output should stay byte-identical
(please confirm against your game files; a deeper check would also verify
that every newly accepted site is really an offset table).
--
patch_nso:偏移表跳转识别扩到全家族,不再只认 x18
`jump_offsets` 里 `br x18` 的偏移表识别原先只接受「临时寄存器与索引寄存器
都是 x18」的形式。Unity / IL2CPP 的构建会用别的寄存器写同一种表,新作
(Cuphead,Unity 2017.4.9f1,SDK 5.5.0.0)有三处,全部以
`AssertionError: jump table <addr>` 中止改写器。改法是放开临时寄存器与
索引寄存器;三种形状都能过,且是旧模式的严格超集,旧模式接受过的点取值
不变(马里奥 / Engage 的产物应保持一致,请在你们的游戏文件上确认)。
seedds
pushed a commit
that referenced
this pull request
Oct 18, 2026
…ster Cuphead (Unity 2017.4) main+0x1bb872c loads the table entry into x17 and only the add writes x18: cmp w17,#7; ldrsw x17,[x15,x17,lsl #2]; add x18,x17,x15; br x18. jump_offsets now takes the loaded register from the add; the walk from the index back to the bounds check is unchanged. Ported from GitHub pull request #1 onto the current jump_offsets (the PR's other two shapes already pass since Link's Awakening's subsdk work). All 35 rewritable modules of the 9 extracted titles give byte-identical output. Co-authored-by: Jeffrey Wang <11900676+armyja@users.noreply.github.com>
Owner
|
感谢!Cuphead 的这几处跳转表确实存在,排查也很到位。 不过这个 PR 基于较旧的 734a286。之后为了《塞尔达传说 织梦岛》的 subsdk, 真正新的是第三处( 验证:
所以这个 PR 先关掉。Cuphead 上如果还有别的形状,欢迎再提。 |
seedds
added a commit
that referenced
this pull request
Oct 21, 2026
…ster Cuphead (Unity 2017.4) main+0x1bb872c loads the table entry into x17 and only the add writes x18: cmp w17,#7; ldrsw x17,[x15,x17,lsl #2]; add x18,x17,x15; br x18. jump_offsets now takes the loaded register from the add; the walk from the index back to the bounds check is unchanged. Ported from GitHub pull request #1 onto the current jump_offsets (the PR's other two shapes already pass since Link's Awakening's subsdk work). All 35 rewritable modules of the 9 extracted titles give byte-identical output. Co-authored-by: Jeffrey Wang <11900676+armyja@users.noreply.github.com>
MeNass89
pushed a commit
to MeNass89/nxnative
that referenced
this pull request
Oct 23, 2026
…P_UP, DM_MEM_RESERVE / DM_APP_POOL Work in progress, everything off by default. patch_nso.py DM_DSR_RES=2160 now also sets the TV scale of the game's 1280x720 base to 3.0 instead of 1.5 (four fmov seedds#1.5 before the target create calls; this is what sizes the main MSAA scene targets) and enlarges the allocator partition carved from the main heap (mov w19,#0x68000000 -> #0xe8000000, it ran out with 4K targets). DM_MEM_RESERVE / DM_APP_POOL override the profile's address-space block and application pool (the main heap grows with the pool). DM_VP_UP=WxH doubles the game's viewport and scissor in passes whose target belongs to the doubled chain (2W x 2H down to W/4 x H/4) when the viewport covers exactly the top-left half. State: boots and holds 60 fps at 3840x2160 (GPU p95 9-10 ms at Firelink); the G-buffer is right, but several lighting and post-processing passes still use 1080p screen constants (a quarter of the picture, black areas). Not usable yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MeNass89
pushed a commit
to MeNass89/nxnative
that referenced
this pull request
Oct 23, 2026
…e at x3.0 With these four more fmov seedds#1.5 -> seedds#3.0 sites (DM_DSR_RES=2160), every pass of the frame renders at 3840x2160 without the host's DM_VP_UP. 20-bonfire sweep: all areas load, frame p50 16.7 ms, p95 17.0-17.4 ms, GPU p95 7-13 ms; 10/10 boots reach the game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MeNass89
pushed a commit
to MeNass89/nxnative
that referenced
this pull request
Oct 23, 2026
Three fmov seedds#1.5 sites (main+0x1d4518, 0x1d4564, 0x1d45b0) build the full and half screen size whose reciprocals go to screen-space shaders. Left at 1.5 they kept 1/1920, 1/1080, 1/960, 1/540 while the targets grew, and the effect drew a scaled ghost of the scene (stairs repeated on a wall). Found by Codex (Sol). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
seedds
added a commit
that referenced
this pull request
Nov 2, 2026
The walk from the load back to the bounds check noticed copies and masks but no other write: cmp w18,#4; b.hi; add w18,w18,#1; ldrsw x18,[x4,x18,lsl #2] read entries 0 to 4 while the code uses 1 to 5, so one case's target was missing with no sign of it. A site with a write of the index after its check, or a call with a caller-saved index, is now refused, as jump_adr_offsets and half_count already refuse a write. A refusal goes on to the other recognizers and ends in the jump table assertion. Writes before the check do not count, which keeps the sites check_before_copy takes. A write that keeps the value, such as sxtw x0,w0, is refused too; no module on the drive has one. Checked: test_jump_copies.py (the new cases fail on the previous rewriter). Of the 345 unique modules on the drive, old and new recognition are the same on 281, and 60 more mains were scanned on the previous code with no site this refuses. That includes Smash 13.0.5, EA SPORTS FC 27 and Well Dweller. Four could not be checked: New Super Mario Bros. U Deluxe's main, sdk and rtld fail alike (no profile), and Smash 1.0.0's main stops at a table the game's note already lists. No regress.py run: nothing changes in the modules checked.
Jhoisaac
added a commit
to Jhoisaac/nxnative
that referenced
this pull request
Nov 3, 2026
…usion, a rewriter cut of the cutscene player's own scale (56% to 90% in the one stretch found), and a survey of the 19 reachable story nodes. (1) ue_quality.tsv, max: r.AmbientOcclusion.HalfResolution 0 to 1. The full-resolution pass cost chapter 1 node 0's tatami room 2,501 of 10,510 frames over 16.6 ms; with half resolution 75 of 10,449 (84 of 11,012 with the previous preset). (2) patches.py, new for this game, build 68e3a0ea176a79f403b859d4addad8c3: AAPKDemoPlayer loads a per-object scale (0.8) and in docked mode multiplies it by APK2.SceneCapture.ScreenPercentageMultiply (0.7), then sets r.ScreenPercentage: 56% in the stretch that uses it. No ini reaches the per-object scale, so the load at main+0x5ef2300 becomes fmov s8,seedds#1.0, a deliberate change of the game's code for picture quality; nothing is wrong on the Switch. ue_quality.tsv sets the cvar to 0.9 at Maximum: frames over 16.6 ms 32 to 83 of 14,501, GPU p99 15.48 to 15.32 ms (100% gave 681 and 17.95 ms). Other presets keep the game's cvar and so get 70% in place of 56%. Shadow cvars gave no visible gain in the same scenes: r.Shadow.MaxResolution 4096 changed nothing, r.Shadow.TexelsPerPixel 2.546 doubled the fight's shadow viewport with GPU p99 16.15 against 15.83 ms: left out. Docs: the game note ("Story scenes at Maximum", with a row per node), docs/agents/07-quality.md, docs/agents/game-patches.md (regenerated). Checked: test_patches, test_docs, test_ue_quality, test_lint_python, test_env_switches, test_nsp_mac_app. 19 nodes (chapters 1 to 3, interlude 1) at Maximum, headless, on a copy of the player's save, fresh boot per node: no crash, 59.1 to 59.9 fps, GPU p50 13.8 to 15.9 ms, peak footprint up to 8.89 GB; the only [RED] lines are the route's DM_KEYS truncation (a 4,096-byte buffer), which the bot's DM_CTL input replaced. The official app (32.9 GB; its rewritten main and container byte-identical to the ones measured), chapter 3 node 3: no [RED] line, no crash, 59.3 fps at 3840 and 59.9 fps at 3456, peak 8.58 GB, a 4K shot looked at. regress.py check --games 0100AD80208A8000 against 34ea1b6, the game these changes reach: shaders 128462/128462 unchanged, boot ok, fps 59.8 to 59.8, frame p99 17.5 to 17.43 ms, peak 5067 to 5102 MB, no new red line; the tool's status is REGRESSION for the screenshots at 190 and 215 s (dHash 17 and 16 bits, RGB 10.44 and 10.24). Looked at: the same tutorial fight with camera and characters elsewhere, no rendering difference by eye; two baseline runs of 34ea1b6 differ by more (25 and 27 bits, RGB 11.27 and 10.58), and each check has one baseline run, so its measured noise is 0. Not checked: the scenes past each exploration stall and past each fight (the bot won no fight), the later chapters and chapter 2's last node (locked in the save), so most of the 107 story and boss sequences and the 252 special techniques; sampling is one pass dump per 900 frames, so a shorter scaled stretch can be missed; whether the regression route crosses the cut; the Switch, high and very high presets with the cut; the fight at raised shadow settings by eye; the player's TV test; long sessions; collision against the stage meshes; iOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
This was referenced Nov 6, 2026
seedds
added a commit
that referenced
this pull request
Nov 7, 2026
… that would put the table in page zero, since no path of a working game carries it to the load (issue #1532) main+0x59dc90 interleaves four dispatch loops that share registers: x12 is the table base of one (adrp + add at +0x59dba4) and the constant 1 of another (mov w12,#1 at +0x59dbdc, in a block that leaves by b to its own dispatch), kept apart only by the value of w8. Since e5620b1 the base's writer walk sees a write of wN, met that mov first and gave up, and the NSP script stopped at `jump table 59dc90` on a build the profile names. patch_nso.py null_base: before the walk has found the base's add, a mov of a constant (or of wzr / xzr) that puts the whole table inside page zero is passed; Horizon never maps that page, so the load would fault through it on the console too. Any other writer still ends the chain, and a constant between the adrp and the add is the base's own input. Checked: test_jump_copies.py NullPageBase (4 of its cases fail on the rewriter before), lint_python 0 new, test_docs. The site's ten targets are instructions of the function, three of them shared with its sibling tables in x15 and x17, and Cuphead's main.sites.tsv is line for line the one of the rewriter before e5620b1. Rewritten before and after: 34 other modules of 12 games (Okami HD, Octopath Traveler 0 and II, Three Houses, Sonic Superstars, Minecraft Dungeons II, Splatoon Raiders, Ocarina of Time, DK Bananza, Pokopia, Mario Tennis Fever, Cuphead's sdk and movie module) are byte-identical. Cuphead's NSP build completes, and the game plays from a fresh save to the Inkwell Isle map at 1.3.7 with no red line (the route does not reach this function). No regress.py run: nothing changes in any module that rewrote before.
seedds
added a commit
that referenced
this pull request
Nov 7, 2026
…d jump_adr_offsets took the nearest cmp of the index, whatever followed it (issue #977, PR #1515) guarded_count takes a compare only when, between it and the table load, the first branch on an unsigned condition comes with the compare's flags still in place: b.hi out of the dispatch reads N + 1 entries, b.hs / b.cs N (read as N + 1 before), b.ls / b.lo into it the same counts when the instruction before its target ends the path that failed. A compare with no such branch only sets the flags and the walk goes on to the check before it; with none the site is refused. Before, `cmp w18,#4; b.hi exit; cmp w18,#1; ldrsw ...` read 2 entries of a table of 5 with no error. Checked (by the author): 165 sites of 27 modules of 6 games, all cmp; b.hi, rewritten byte-identically; GuardedCheck, 8 cases, 7 failing before. Checked here, as #977 asks before a stricter rule goes in: 35 modules of 12 games on the T7 (Cuphead, Three Houses, Minecraft Dungeons II, Octopath Traveler 0 and II, Okami HD, Sonic Superstars, Ocarina of Time, DK Bananza, Mario Tennis Fever, Pokopia, Splatoon Raiders) rewrite byte-identically before and after, and so do Super Smash Bros. Ultimate 13.0.5, Mario Kart 8 Deluxe and Super Mario Odyssey's main, sdk and subsdk0 (against origin/main, with the page-zero rule of the commit before); test_jump_copies 75 OK, lint_python 0 new, test_docs. No regress.py run: no module that rewrote before changes. Modules with b.hs or a branch into the dispatch are still tested only synthetically. Co-authored-by: Atomsk-debug <135618857+Atomsk-debug@users.noreply.github.com>
1 task done
62fixolab
added a commit
to 62fixolab/nxnative
that referenced
this pull request
Nov 9, 2026
…s frame interval and its dynamic resolution's bounds by the engine's own code, and the host frees the interval and scales the bounds (issue seedds#635) The game ran at 30 fps, as on the Switch, and its settings offered no frame rate. HAL's engine paces itself by a vsyncs-per-frame int32 in its frame object (the game sets 2). The field also accepts 0, for no limit: the frame manager then steps the game by the time that really passed, so the host's present cap sets the rate. The dynamic resolution compares the GPU's frame time with two bounds in 60 Hz vsyncs chosen for 30 fps (1.95 and 1.7), so at 60 it would keep full resolution at frame times too long for the target. dm/tools/hal_fps.py, run by patch_nso.py on main, finds both with no build ID and names them in the fixups (HAL_FRAME_PTR, HAL_FRAME_FIELD; HAL_DR_PTR, HAL_DR_HOP0..2, HAL_DR_FIELD): - the interval: the frame manager's switch on the field (ldr wM, [xO, #F]; cmp wM, seedds#2; b.eq; cmp wM, seedds#1; b.eq; cbnz wM) followed by the 60 Hz vsync in nanoseconds (movz / movk of 0xfe502a), and the frame object's constructor, which clears that field and stores the address of its interface at +D into a global that no other code sets but to 0: the field is at [global] + F - D - the bounds: the last of the engine's three heap roots (globals 8 bytes apart, each read by a function that looks up which of the root's heaps holds an address), then the path +0x140, +0x1b0, +0x20, +0x34 through the heaps' bookkeeping, which is masagrator's FPSLocker config's (the same for 1.0.0 and 1.1.0) and is not read from code Each place must be found exactly once; a field or roots found more than once give a [RED] line and nothing is written. loader.c reads the keys into module_t, and hle_fpslock.c writes them, with no build-keyed row: a new row kind, FREE_I32, writes the interval 0 above 30 and leaves it at 30, where the game keeps its own limit; above 30 each bound becomes the game's own value times 30 / target (its own value is what it holds when that differs from the host's last write, so a bound the game sets again is scaled again). The bounds alone do not count as an engine limit for the present cap. The profile gets fps_target 60. 60 is the ceiling: the frame manager (main+0x532eb0) counts a step in whole 60 Hz vsyncs, at least one, so a shorter frame would run the game fast. On a 120 Hz display link an iPhone 17 Pro Max refreshed at 120 and the game still delivered 60, at 3.5 times the CPU energy; fps_max stays 60. The places come from masagrator's FPSLocker config for 1.1.0 (FPSLocker-Warehouse, SaltySD/plugins/FPSLocker/patches/01004D300C5AE000/A6CE40DC3AEDB1BE.yaml), the interval found by Hazerou; the search's anchors are the code those configs name. Checked offline (2026-11-09): on 1.1.0 (a6ce40dc...) the search finds [0xa76728]+0x50 and the root 0xa767b0; on 1.0.0 (d9ba7db7...) 0xa72628 and 0xa726b0, the places FPSLocker's 1.0.0 config lists; nothing in 12 other mains on the game drive, Kirby Star Allies 4.0.0 and Kirby's Return to Dream Land Deluxe 1.0.0 among them, so the code is this game's (binding game, not engine). patch_nso.py on the 1.1.0 main writes those keys. Tests: test_hal_fps.py (Kirby's layout, no frame manager, a frame manager with no constructor storing its object, a global something else sets, two objects, heap roots not three in a row); t_fpslock cases 30 and 31 (60: interval 2 -> 0, bounds 1.95 / 1.7 -> 0.975 / 0.85, both again when the game sets its own again; 30: nothing written); the host tests; the tool tests as on main (test_dmsh_abi, test_host_msl and test_uepak_iostore fail the same on main on this Mac); lint_python against main, no new finding; lint_c, no finding in the changed files. In game, with a build row for the same places on 1.1.0: iPhone 17 Pro Max, iOS 27.2, 8 minutes of play, median 59.8 fps, dips to 44-50 only while areas load, 60 held at thermal state 2, footprint up to 4.0 GB; Mac, Apple M1 Max, macOS 27.2, 3 minutes of play, 60.0 fps in every power window but the first (loading); the same scripted walk ends at the same place at 30 and 60. Not checked: the run through the fixups in game, past the first area, regress.py.
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
The walk from the load back to the bounds check noticed copies and masks but no other write: cmp w18,seedds#4; b.hi; add w18,w18,seedds#1; ldrsw x18,[x4,x18,lsl seedds#2] read entries 0 to 4 while the code uses 1 to 5, so one case's target was missing with no sign of it. A site with a write of the index after its check, or a call with a caller-saved index, is now refused, as jump_adr_offsets and half_count already refuse a write. A refusal goes on to the other recognizers and ends in the jump table assertion. Writes before the check do not count, which keeps the sites check_before_copy takes. A write that keeps the value, such as sxtw x0,w0, is refused too; no module on the drive has one. Checked: test_jump_copies.py (the new cases fail on the previous rewriter). Of the 345 unique modules on the drive, old and new recognition are the same on 281, and 60 more mains were scanned on the previous code with no site this refuses. That includes Smash 13.0.5, EA SPORTS FC 27 and Well Dweller. Four could not be checked: New Super Mario Bros. U Deluxe's main, sdk and rtld fail alike (no profile), and Smash 1.0.0's main stops at a table the game's note already lists. No regress.py run: nothing changes in the modules checked.
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
… that would put the table in page zero, since no path of a working game carries it to the load (issue seedds#1532) main+0x59dc90 interleaves four dispatch loops that share registers: x12 is the table base of one (adrp + add at +0x59dba4) and the constant 1 of another (mov w12,seedds#1 at +0x59dbdc, in a block that leaves by b to its own dispatch), kept apart only by the value of w8. Since dfdf5ad the base's writer walk sees a write of wN, met that mov first and gave up, and the NSP script stopped at `jump table 59dc90` on a build the profile names. patch_nso.py null_base: before the walk has found the base's add, a mov of a constant (or of wzr / xzr) that puts the whole table inside page zero is passed; Horizon never maps that page, so the load would fault through it on the console too. Any other writer still ends the chain, and a constant between the adrp and the add is the base's own input. Checked: test_jump_copies.py NullPageBase (4 of its cases fail on the rewriter before), lint_python 0 new, test_docs. The site's ten targets are instructions of the function, three of them shared with its sibling tables in x15 and x17, and Cuphead's main.sites.tsv is line for line the one of the rewriter before dfdf5ad. Rewritten before and after: 34 other modules of 12 games (Okami HD, Octopath Traveler 0 and II, Three Houses, Sonic Superstars, Minecraft Dungeons II, Splatoon Raiders, Ocarina of Time, DK Bananza, Pokopia, Mario Tennis Fever, Cuphead's sdk and movie module) are byte-identical. Cuphead's NSP build completes, and the game plays from a fresh save to the Inkwell Isle map at 1.3.7 with no red line (the route does not reach this function). No regress.py run: nothing changes in any module that rewrote before.
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…d jump_adr_offsets took the nearest cmp of the index, whatever followed it (issue seedds#977, PR seedds#1515) guarded_count takes a compare only when, between it and the table load, the first branch on an unsigned condition comes with the compare's flags still in place: b.hi out of the dispatch reads N + 1 entries, b.hs / b.cs N (read as N + 1 before), b.ls / b.lo into it the same counts when the instruction before its target ends the path that failed. A compare with no such branch only sets the flags and the walk goes on to the check before it; with none the site is refused. Before, `cmp w18,seedds#4; b.hi exit; cmp w18,seedds#1; ldrsw ...` read 2 entries of a table of 5 with no error. Checked (by the author): 165 sites of 27 modules of 6 games, all cmp; b.hi, rewritten byte-identically; GuardedCheck, 8 cases, 7 failing before. Checked here, as seedds#977 asks before a stricter rule goes in: 35 modules of 12 games on the T7 (Cuphead, Three Houses, Minecraft Dungeons II, Octopath Traveler 0 and II, Okami HD, Sonic Superstars, Ocarina of Time, DK Bananza, Mario Tennis Fever, Pokopia, Splatoon Raiders) rewrite byte-identically before and after, and so do Super Smash Bros. Ultimate 13.0.5, Mario Kart 8 Deluxe and Super Mario Odyssey's main, sdk and subsdk0 (against origin/main, with the page-zero rule of the commit before); test_jump_copies 75 OK, lint_python 0 new, test_docs. No regress.py run: no module that rewrote before changes. Modules with b.hs or a branch into the dispatch are still tested only synthetically. Co-authored-by: Atomsk-debug <135618857+Atomsk-debug@users.noreply.github.com>
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…window as it is; the RGBA16Float extended-range layer showed black blocks over flat areas on an M5 (seedds#1) On a MacBook Air M5 (macOS 27.0.1) the extended linear BT.2020 layer showed black blocks with coloured squares over Mario Kart World's course-map water, now and then and after the window came back to the front, while the game's frames were clean. The layer now takes the PQ window as it is; an SDR source is encoded as HDR10 at the paper white (present_mode 3). DM_HDR_LAYER=float keeps the old layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FeReuss
pushed a commit
to FeReuss/nxnative-oot
that referenced
this pull request
Nov 10, 2026
…s after its #@after_first_frame line are built after the first frame, in the background, instead of in the prepare step (issue seedds#1 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
UserDerezzed
pushed a commit
to UserDerezzed/nxnative
that referenced
this pull request
Nov 10, 2026
…window as it is; the RGBA16Float extended-range layer showed black blocks over flat areas on an M5 (seedds#1) On a MacBook Air M5 (macOS 27.0.1) the extended linear BT.2020 layer showed black blocks with coloured squares over Mario Kart World's course-map water, now and then and after the window came back to the front, while the game's frames were clean. The layer now takes the PQ window as it is; an SDR source is encoded as HDR10 at the paper white (present_mode 3). DM_HDR_LAYER=float keeps the old layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
seedds
added a commit
that referenced
this pull request
Nov 12, 2026
…1352) Civilization VII 1.5.0.1 crashed on the Mac with CRASH sig=10 addr=0 pc=main+0x4e8a18 on its UI's second screen change: four hand-written blocks in its main save x1-x17 in a 0x98-byte frame around svc #0x29, which leaves sp 8 bytes off. Horizon allows that, Apple's kernel faults on it, as with sub sp, sp, xN (site_sp_align). odd_sp_frames rounds both immediates of such a pair up to 16 in place, only when the matching add follows within 64 instructions and nothing between them branches, writes or copies sp, uses writeback or reaches past the frame. On top of the PR: a frame of 0xff1-0xfff rounds to 0x1000, which the unshifted 12-bit field cannot hold; written as before it became sub sp, sp, #0, lsl #12, a frame of nothing whose stores land on the caller's stack. sp_adjust writes it as #1, lsl #12, and test_sp_frame.py covers it. The search now finds candidates by a one-byte regex like exclusive_order_sites instead of walking every word: 2.71 s -> 0.08 s on PRAGMATA's 134 MiB main. Checked: test_sp_frame.py (8), the 16 test files that use patch_nso.py, test_docs.py, lint_python.py --against origin/main (nothing new). The search finds no odd sub/add sp, #imm word in 42 modules (main, rtld, sdk, subsdk*) of 10 local games, so their rewrites are unchanged; the PR author measured TotK and MGS4 byte-identical and Civilization VII 8 words changed, 14 minutes (49,800 frames) without a crash. regress.py not run: no local game has such a frame. Supersedes PR #1666 (every odd immediate rounded unpaired, which would move incoming stack arguments). Co-authored-by: Xiaofeng Han <15362031+xiaofeng-han@users.noreply.github.com>
1 task done
1 task done
1 task done
seedds
added a commit
that referenced
this pull request
Nov 27, 2026
Sonic Racing: CrossWorlds 1.41 main+0x726afc (issue #3383) spills a 32-bit subs w4, w8, #1 result to [sp, #0x80] across two calls and reloads it with ldr x4, [sp, #0x80] before cmp w4, #5; b.hi; ldrsw x0, [x17, x4, lsl #2]. Without a stack-slot model, the 64-bit reload produced an unconstrained 64-bit root whose unknown upper half a 32-bit compare cannot bound, stopping the rewrite at 'the index reaches 0xffffffffffffffff'. Track provably local fixed stack slots inside the function's allocated frame (frame, slots, escaped) and stack-derived register offsets ('sp', offset) uniformly covering x29 frame pointers in dm/tools/jump_solver.py: - Only track fixed-offset GPR str/stur/stlr/stp/stnp slots strictly inside [0, frame) allocated by sub sp / pre-decrement, and reload only on matching width (or a 32-bit reload of the low half of an 8-byte slot). - Invalidate overlapping byte ranges on any fixed-offset stack write, clear slots on indexed or unknown-size stack writes (including LSE atomics), and latch escaped=True whenever a stack pointer escapes to a call (x0-x18/x30), memory, syscall, unhandled op, or mismatched join. - Reject trusting targets solely because they lie in the function when the upper half remains unproved. Checked: 37/37 test_jump_solver.py, 7/7 test_docs.py, 71/71 related rewriter tests, ruff/pyright (0 errors/warnings on modified files), byte-identical main rewrites on Cuphead (-0.6%) and Manual Samuel (+0.9%), and quick regress.py checks on Well Dweller and DOOM 3 (PASS). Awaits reporter retest on Sonic Racing: CrossWorlds main. Co-authored-by: dationguyen <26321444+dationguyen@users.noreply.github.com>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
jump_offsetsinpatch_nso.pyrecognised only the offset-table form whose temporary and index register are bothx18:Unity / IL2CPP builds use the same table shape with other registers. Every one of those aborts the rewriter with
AssertionError: jump table <addr>, which matches the entry indocs/agents/03-bringup.md("the compiler usedx18for other jump-table shapes").This generalises the recogniser to the whole family: the temporary
tand the indexiofare no longer required to be
x18.Why (evidence)
A title I am surveying — Cuphead, Unity 2017.4.9f1, SDK 5.5.0.0, base
v0— has three such sites:Before:
mainaborts at2bceb0,sdkat248e28. After:main/sdk/subsdk0/rtldall rewrite cleanlyRegression risk
It is a strict superset of the old patterns. For a site the old code accepted, the new code computes the same
rb, the sameNand the same targets, so Mario's and Engage's output should stay byte-identical. Please confirm against your game files — and, if you want a tighter guard, the newly accepted sites could be checked to be a real offset table (the index is bounds-checked againstNbefore theldrsw).Not in this PR
A
dm/games/0100A5C00D162000/profile for the title above is kept locally for now: its shaders are Unity 2017.4, andunityfs.py(format 6..8 / serialized 17..22, per your Engage work) does not reach them yet, so the profile's shader tables cannot be produced. It may be worth a follow-up if you want older-Unity support.