decomp(bs2): recover loader address capture ordering #1079

Merged
coah80 merged 1 commits from agent/bittle/bs2-loader-lifetime into main 2026-10-03 07:50:31 +00:00
coah80 commented 2026-10-03 07:49:47 +00:00 (Migrated from github.com)

Source evidence

Capture loaderRead.address in a genuinely consumed u32 local after BS2ReadDiskID returns, before reading length and publishing the existing LoaderLength/LoaderAddress/LoaderOffset globals. The original reads the post-call address before length but stores length before address. This preserves the real volatile store order; the historical alternative that reversed publication order was explicitly rejected. No pre-call snapshot, dummy state, qualifier, assembly, shared-header or linking change.

Independent parent verification on cd0db8fd

  • BS2Tick fuzzy: 98.73196% → 98.74072%; still 1937/1940 instructions, not exact
  • Exactly five changed instructions, all now matching original operands: two field loads, two publication operands and the transfer-length operand
  • All 25 exact functions, matched code/data, other 1026 unit reports and text outside the function preserved
  • All 1461 relocation positions/types/target addresses/addends preserved. Compiler renumbers 15 anonymous local object labels referenced by 39 relocations; raw binding/section/offset/size identities were separately checked, not assumed from names
  • All 201 candidate call sites unchanged; original call targets independently checked against raw DOL
  • Parent independently rebuilt and executed actual baseline/candidate/original publication slices for 16,250 cases covering flag branches, full-width boundaries, arbitrary post-call output fields and saved IRQ values. All 17 slice instructions covered; outputs/store order agree, candidate full access trace matches target; deliberately stale pre-call capture fails
  • Parent separately verified 23 original loader-slice instructions against DOL bytes, resolving call/data relocations. These bounded checks are not whole-function equivalence or Wii hardware tests
  • Pool 91/91 identical; literal audit 28 functions / 97 arguments, no candidates/errors; BS2Tick remains an unequal-size skip
  • Full 43U all_source/progress/report/ok, worktree and diff gates pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d

Only one source form tried. Candidate SHA256 cbe805674ee00b147e3a70f6304fd7c154b1ae1c88886f889a66b39344a85962; uploaded tree d5df596127 equals independently tested tree. Evidence and limitations recorded in attempts log. No merge or auto-merge requested.

Note

Capture loader read address in BS2Tick before publishing LoaderAddress

Adds a 32-bit unsigned local in BS2Tick to hold the loader read address returned by the disk-read helper, and uses that local when writing LoaderAddress in BS2Mach.c. Field-assignment order and surrounding control flow stay the same. Adds an investigation report in bs2-loader-address-lifetime-20261003.md covering instruction-level comparison, validation scope, relocation, and call-site audits.

Macroscope summarized d90cf31.

## Source evidence Capture loaderRead.address in a genuinely consumed u32 local after BS2ReadDiskID returns, before reading length and publishing the existing LoaderLength/LoaderAddress/LoaderOffset globals. The original reads the post-call address before length but stores length before address. This preserves the real volatile store order; the historical alternative that reversed publication order was explicitly rejected. No pre-call snapshot, dummy state, qualifier, assembly, shared-header or linking change. ## Independent parent verification on cd0db8fd - BS2Tick fuzzy: 98.73196% → 98.74072%; still 1937/1940 instructions, not exact - Exactly five changed instructions, all now matching original operands: two field loads, two publication operands and the transfer-length operand - All 25 exact functions, matched code/data, other 1026 unit reports and text outside the function preserved - All 1461 relocation positions/types/target addresses/addends preserved. Compiler renumbers 15 anonymous local object labels referenced by 39 relocations; raw binding/section/offset/size identities were separately checked, not assumed from names - All 201 candidate call sites unchanged; original call targets independently checked against raw DOL - Parent independently rebuilt and executed actual baseline/candidate/original publication slices for 16,250 cases covering flag branches, full-width boundaries, arbitrary post-call output fields and saved IRQ values. All 17 slice instructions covered; outputs/store order agree, candidate full access trace matches target; deliberately stale pre-call capture fails - Parent separately verified 23 original loader-slice instructions against DOL bytes, resolving call/data relocations. These bounded checks are not whole-function equivalence or Wii hardware tests - Pool 91/91 identical; literal audit 28 functions / 97 arguments, no candidates/errors; BS2Tick remains an unequal-size skip - Full 43U all_source/progress/report/ok, worktree and diff gates pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d Only one source form tried. Candidate SHA256 cbe805674ee00b147e3a70f6304fd7c154b1ae1c88886f889a66b39344a85962; uploaded tree d5df596127f4b9bdc9dd0508885a1e53c8794889 equals independently tested tree. Evidence and limitations recorded in attempts log. No merge or auto-merge requested. <!-- 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] > ### Capture loader read address in `BS2Tick` before publishing `LoaderAddress` > Adds a 32-bit unsigned local in `BS2Tick` to hold the loader read address returned by the disk-read helper, and uses that local when writing `LoaderAddress` in [BS2Mach.c](https://github.com/coah80/wii-ipl/pull/1079/files#diff-2abf473529b49cca688ecd961c46eb8e1f0a6f20ca9aeecb1f6633e8282b185d). Field-assignment order and surrounding control flow stay the same. Adds an investigation report in [bs2-loader-address-lifetime-20261003.md](https://github.com/coah80/wii-ipl/pull/1079/files#diff-7a08a2426445175022fb9e11c9be3f54563d19f7ef483bdc844c4e71a0b2eaf8) covering instruction-level comparison, validation scope, relocation, and call-site audits. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized d90cf31.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 07:50:29 +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.