fix: model Run stack address independently of printf #982

Merged
coah80 merged 1 commits from agent/bittle/run-fixed-stack into main 2026-10-02 22:49:33 +00:00
coah80 commented 2026-10-02 22:47:58 +00:00 (Migrated from github.com)

Narrow correction to #973 — please review metadata attribution

Run already contains the required architecture-bound assembly. This PR adds no instructions and is not another Run implementation or a new match.

The verified original DOL establishes SP as 0x81600000 at instructions 0x8137B468/0x8137B46C. Automatic extraction bound their HI/LO operands to __pformatter + 0x280, which happens to have that address but is an unrelated formatted-output function. The reconstruction should not make its boot stack depend on formatter placement.

Remove the unrelated extern, use the fixed high/low immediate, and block exactly those two false relocations. DTK block_relocations requires instruction addresses, not the ELF immediate halfword offsets at Run+0x7E/+0x82. All register clearing, labels, cache loop, original zero-count wrap behavior, LR transfer and linking flags remain unchanged.

Fresh independent verification on 813660b9

  • Original app and rebuilt DOL SHA1 both 26116613f624061ba99c8d1a299aaa6efa85670d.
  • Full 43U all_source/progress/report/DOL pass. Whole report unchanged: no code/data/function/fuzzy/link delta.
  • Run remains 100%, 43/43 instructions, ctxdiff zero. Pool 91/91 identical.
  • All 1027 native objects audited: only BS2Mach text changes, size 16960 unchanged, exactly the two false relocations removed. Other allocated objects/data unchanged.
  • Extracted-object audit: only BS2Mach text changes; its high immediate placeholder bytes become original 0x81,0x60. The same two relocations disappear, defined symbols/non-text sections unchanged. 1027 active objects plus the same obsolete cached tiManager object on both sides were compared.
  • Supplemental compiled-PPC contract model passes 1,4,131072 cache lines, fixed SP, cleared GPRs, preserved LR entry and dcbz/dcbf event order. Zero-count first iteration wraps CTR to 0xFFFFFFFF; the full 2^32 iteration path is not executed. Not a hardware/console test.
  • Tests 8/36/27/8, worktree checks and diff check pass. Remote tree 4f7fae9fad equals tested tree.

No retail .s substitution, byte transplant, padding, new forced-register use or linking change. The separate full-Run experiment was superseded by #973 and is deliberately excluded. Left for review; no merge performed.

Note

Fix Run stack address to be modeled independently of __pformatter

Replaces the formatter-relative stack-pointer initialization in the Run assembly routine in BS2Mach.c with explicit immediates for the fixed address 0x81600000, and removes the __pformatter declaration.

  • Adds .text:0x8137B468 and .text:0x8137B46C to the relocation exclusions in config.yml, since these instructions now load a fixed stack address.
  • Documents the correction and its validation in run-fixed-stack.attempts.md.

Macroscope summarized 306ff59.

## Narrow correction to #973 — please review metadata attribution Run already contains the required architecture-bound assembly. This PR adds no instructions and is not another Run implementation or a new match. The verified original DOL establishes SP as **0x81600000** at instructions 0x8137B468/0x8137B46C. Automatic extraction bound their HI/LO operands to `__pformatter + 0x280`, which happens to have that address but is an unrelated formatted-output function. The reconstruction should not make its boot stack depend on formatter placement. Remove the unrelated extern, use the fixed high/low immediate, and block exactly those two false relocations. DTK block_relocations requires instruction addresses, not the ELF immediate halfword offsets at Run+0x7E/+0x82. All register clearing, labels, cache loop, original zero-count wrap behavior, LR transfer and linking flags remain unchanged. ## Fresh independent verification on 813660b9 - Original app and rebuilt DOL SHA1 both 26116613f624061ba99c8d1a299aaa6efa85670d. - Full 43U all_source/progress/report/DOL pass. Whole report unchanged: no code/data/function/fuzzy/link delta. - Run remains 100%, 43/43 instructions, ctxdiff zero. Pool 91/91 identical. - All 1027 native objects audited: only BS2Mach text changes, size 16960 unchanged, exactly the two false relocations removed. Other allocated objects/data unchanged. - Extracted-object audit: only BS2Mach text changes; its high immediate placeholder bytes become original 0x81,0x60. The same two relocations disappear, defined symbols/non-text sections unchanged. 1027 active objects plus the same obsolete cached tiManager object on both sides were compared. - Supplemental compiled-PPC contract model passes 1,4,131072 cache lines, fixed SP, cleared GPRs, preserved LR entry and dcbz/dcbf event order. Zero-count first iteration wraps CTR to 0xFFFFFFFF; the full 2^32 iteration path is not executed. Not a hardware/console test. - Tests 8/36/27/8, worktree checks and diff check pass. Remote tree 4f7fae9fadb7c664fe3ee1e27f8a68beac085170 equals tested tree. No retail .s substitution, byte transplant, padding, new forced-register use or linking change. The separate full-Run experiment was superseded by #973 and is deliberately excluded. Left for review; no merge performed. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Fix `Run` stack address to be modeled independently of `__pformatter` > Replaces the formatter-relative stack-pointer initialization in the `Run` assembly routine in [BS2Mach.c](https://github.com/coah80/wii-ipl/pull/982/files#diff-2abf473529b49cca688ecd961c46eb8e1f0a6f20ca9aeecb1f6633e8282b185d) with explicit immediates for the fixed address 0x81600000, and removes the `__pformatter` declaration. > - Adds .text:0x8137B468 and .text:0x8137B46C to the relocation exclusions in [config.yml](https://github.com/coah80/wii-ipl/pull/982/files#diff-c16baf9586707619a56914d7493d17bca7d05685a166f1b57faca7b8959c565a), since these instructions now load a fixed stack address. > - Documents the correction and its validation in [run-fixed-stack.attempts.md](https://github.com/coah80/wii-ipl/pull/982/files#diff-e951ef42defd9d7232dcf37e4bee2321c74caa9485353b9aae607f5312a1156a). > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 306ff59.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 22:49:31 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.