Match and link USBAP registration; repair USBAPThread sbss ownership #721

Merged
coah80 merged 1 commits from agent/bittle/usbap-registration-link into main 2026-10-02 04:39:26 +00:00
coah80 commented 2026-10-02 04:38:21 +00:00 (Migrated from github.com)

Scope and evidence

Rebased and verified against a9833b51. Four files, 37 additions/23 deletions.

  • Match DoRegistration in ordinary C++: function-scope scan locals and a byte-buffer MAC lookup consistent with the existing u8* API. 161/161 instructions, zero ctxdiff differences. All four USBAP functions are now exact (988/988 code bytes).
  • Shared-header change disclosed: add C linkage guards around the WD C API declarations in libs/RevoEX/include/revolution/wd.h. The original calls WDCheckEnableChannel and WDScanOnce, not C++-mangled variants. A clean all-source rebuild and allocated-section byte/normalized-relocation comparison across all 1,027 source objects found only those two call relocations changed by the header fix.
  • Correct an actual ownership error: USBAP .sbss ends at 0x81698C20, not 0x81698C28. Transfer [0x81698C20,0x81698C28) to USBAPThread. The pointer at lbl_81698C20 is USBAPThread's registrationResult: original callback loads at offsets +0x8/+0x24 and setData store at +0x14. USBAP does not reference it. Total data and all symbol addresses/sizes remain unchanged.
  • Mark USBAP Matching. Before the split repair, native linking correctly failed on the thread's unresolved lbl_81698C20; after the repair the native C++ links byte-identically.

Verification

  • Full 43U all_source/progress/report/DOL build passes after rebase.
  • Every one of the 3,867,904 DOL bytes equals the supplied original; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
  • USBAP: 4/4 functions, all instruction comparisons zero differences; pools 1/1. USBAPThread pool 3/3.
  • Workflow tests 7/7, pool tests 8/8, jump-table tests 27/27; diff/worktree checks pass.
  • Gains: +644 exact code bytes / +1 exact function; +988 linked code bytes / +4,984 linked data bytes / +1 complete unit.
  • Matched-data attribution +32 bytes from the corrected ownership. No unrelated unit measure changes.

Honest data caveat

USBAP is fully linked but objdiff still reports only 40/4,984 data bytes matched; do not interpret this as 100% data matching. Its native/reference .bss have identical 4,942-byte prefixes plus two reference alignment zeros; .data has an identical nine-byte prefix plus seven alignment zeros; .sbss is exactly 24/24. USBAPThread's data is now 80/80, but that unit remains NonMatching with 6/7 exact functions. No fabricated padding, pinned sections, retail assembly, or weak-vtable score workaround was added.

Tested and published tree: 700727b5f4. Review only; no assistant merge.

Note

Match iplUSBAP registration; fix USBAPThread sbss ownership in 43U

  • Marks src/scene/setting/iplUSBAP.cpp as Matching in configure.py and replaces its typed registered-AP structure with a raw byte buffer plus an inline MAC-address slot lookup helper.
  • DoRegistration now reads and writes registered addresses through raw-buffer offsets, appending new addresses after the count byte and incrementing the count in place.
  • Adds a C++ linkage guard around the WD API declarations in wd.h.
  • Moves the last 8 bytes of .sbss from iplUSBAP.cpp to iplUSBAPThread.cpp in splits.txt to match the linker map.

Macroscope summarized 201071d.

## Scope and evidence Rebased and verified against a9833b51. Four files, 37 additions/23 deletions. - Match DoRegistration in ordinary C++: function-scope scan locals and a byte-buffer MAC lookup consistent with the existing u8* API. 161/161 instructions, zero ctxdiff differences. All four USBAP functions are now exact (988/988 code bytes). - Shared-header change disclosed: add C linkage guards around the WD C API declarations in libs/RevoEX/include/revolution/wd.h. The original calls WDCheckEnableChannel and WDScanOnce, not C++-mangled variants. A clean all-source rebuild and allocated-section byte/normalized-relocation comparison across all 1,027 source objects found only those two call relocations changed by the header fix. - Correct an actual ownership error: USBAP .sbss ends at 0x81698C20, not 0x81698C28. Transfer [0x81698C20,0x81698C28) to USBAPThread. The pointer at lbl_81698C20 is USBAPThread's registrationResult: original callback loads at offsets +0x8/+0x24 and setData store at +0x14. USBAP does not reference it. Total data and all symbol addresses/sizes remain unchanged. - Mark USBAP Matching. Before the split repair, native linking correctly failed on the thread's unresolved lbl_81698C20; after the repair the native C++ links byte-identically. ## Verification - Full 43U all_source/progress/report/DOL build passes after rebase. - Every one of the 3,867,904 DOL bytes equals the supplied original; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. - USBAP: 4/4 functions, all instruction comparisons zero differences; pools 1/1. USBAPThread pool 3/3. - Workflow tests 7/7, pool tests 8/8, jump-table tests 27/27; diff/worktree checks pass. - Gains: +644 exact code bytes / +1 exact function; +988 linked code bytes / +4,984 linked data bytes / +1 complete unit. - Matched-data attribution +32 bytes from the corrected ownership. No unrelated unit measure changes. ## Honest data caveat USBAP is fully linked but objdiff still reports only 40/4,984 data bytes matched; do not interpret this as 100% data matching. Its native/reference .bss have identical 4,942-byte prefixes plus two reference alignment zeros; .data has an identical nine-byte prefix plus seven alignment zeros; .sbss is exactly 24/24. USBAPThread's data is now 80/80, but that unit remains NonMatching with 6/7 exact functions. No fabricated padding, pinned sections, retail assembly, or weak-vtable score workaround was added. Tested and published tree: 700727b5f469392595fad91790df1c6edda8333b. Review only; no assistant merge. <!-- 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] > ### Match iplUSBAP registration; fix USBAPThread sbss ownership in 43U > - Marks `src/scene/setting/iplUSBAP.cpp` as Matching in [configure.py](https://github.com/coah80/wii-ipl/pull/721/files#diff-4d5f3192809ec1b9add6b33007e0c50031ad9a0a2f3f55a481b506468824db2c) and replaces its typed registered-AP structure with a raw byte buffer plus an inline MAC-address slot lookup helper. > - `DoRegistration` now reads and writes registered addresses through raw-buffer offsets, appending new addresses after the count byte and incrementing the count in place. > - Adds a C++ linkage guard around the WD API declarations in [wd.h](https://github.com/coah80/wii-ipl/pull/721/files#diff-2eee743b3b09e3de5c6abf22849cdb9be640fd45b77a80663466b39080fc8a6b). > - Moves the last 8 bytes of `.sbss` from `iplUSBAP.cpp` to `iplUSBAPThread.cpp` in [splits.txt](https://github.com/coah80/wii-ipl/pull/721/files#diff-d5132efbf4d83cc6fc61c89e9d57150d270f1361827760236aeab4e594f19366) to match the linker map. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 201071d.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 04:39:25 +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.