Represent existing MetroTRK trap entries as sized functions #775

Merged
coah80 merged 1 commits from agent/bittle/trk-entry-functions into main 2026-10-02 08:38:52 +00:00
coah80 commented 2026-10-02 08:37:10 +00:00 (Migrated from github.com)

Scope and assembly disclosure

This restructures EXISTING unavoidable MetroTRK debugger trap assembly; it does not add trap instructions, transplant retail code, introduce a .s file, or replace any C/C++ implementation with assembly. The same four pre-existing twi 31,r0,0; blr pairs are expressed as four functions with the API signatures already declared in trk/MetroTRK.h, instead of four untyped entry labels inside the synthetic __targsupp wrapper.

The first function retains the existing 43U 32-byte alignment; subsequent 8-byte functions use 8-byte alignment. All emitted instruction bytes, addresses, relocation data, and section alignment are unchanged. __targsupp had no repository references outside its definition.

Add explicit size:0x8 to the four reference symbols at 0x8160CFA0/A8/B0/B8. Each body is exactly the existing trap and return, ending at the next entry or the unit boundary. Previously the extractor emitted zero-size reference symbols and the source used STT_NOTYPE zero-size entry labels.

Accounting, not new decompilation/linkage

The unit was already linked and byte-identical. Proper function symbols make all four existing 8-byte entries report 100%: +32 matched-code attribution, +4 matched-function attribution; no additional native code, linked bytes, or completed units. Total code/function counts remain unchanged. No new matching logic is claimed.

Verification on 7b64914abb

  • 4/4 exact-name ctxdiff, 2/2 instructions each, 0 differences.
  • All 1,027 native source objects: allocated bytes and normalized relocations IDENTICAL versus main, including the complete 32-byte MetroTRK .text. Global link-address audit 0 differences.
  • Full 43U all_source/progress/report/ok build: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
  • Pool 0/0 identical. Literal audit analyzes all four functions without skips/errors (no string arguments).
  • Tests: workflow 8, literal 36, jump-table 27, pool 8 pass. Diff and main/leaf worktree checks pass.
  • Published tree 050f671b9c exactly matches tested local tree.

Draft for explicit review of this existing-assembly restructuring; no merge performed.

Note

Split MetroTRK trap entries into four standalone sized functions

  • Replaces the single assembly wrapper in targsupp.c with four standalone assembly functions: TRKAccessFile, TRKOpenFile, TRKCloseFile, and TRKPositionFile. Each keeps the nofralloc, trap, and return instruction sequence.
  • TRKAccessFile now has an explicit DSIOResult return type and parameter list.
  • Adds 8-byte alignment directives before the latter three stubs and updates VERSION_43U conditional alignment and comments.
  • Updates symbols.txt so all four functions record a size of 0x8 at their existing addresses.

Macroscope summarized b2dcf13.

## Scope and assembly disclosure This restructures EXISTING unavoidable MetroTRK debugger trap assembly; it does not add trap instructions, transplant retail code, introduce a .s file, or replace any C/C++ implementation with assembly. The same four pre-existing `twi 31,r0,0; blr` pairs are expressed as four functions with the API signatures already declared in trk/MetroTRK.h, instead of four untyped entry labels inside the synthetic __targsupp wrapper. The first function retains the existing 43U 32-byte alignment; subsequent 8-byte functions use 8-byte alignment. All emitted instruction bytes, addresses, relocation data, and section alignment are unchanged. __targsupp had no repository references outside its definition. Add explicit size:0x8 to the four reference symbols at 0x8160CFA0/A8/B0/B8. Each body is exactly the existing trap and return, ending at the next entry or the unit boundary. Previously the extractor emitted zero-size reference symbols and the source used STT_NOTYPE zero-size entry labels. ## Accounting, not new decompilation/linkage The unit was already linked and byte-identical. Proper function symbols make all four existing 8-byte entries report 100%: +32 matched-code attribution, +4 matched-function attribution; no additional native code, linked bytes, or completed units. Total code/function counts remain unchanged. No new matching logic is claimed. ## Verification on 7b64914abbd4b2a36af0370b834a79bad5363acd - 4/4 exact-name ctxdiff, 2/2 instructions each, 0 differences. - All 1,027 native source objects: allocated bytes and normalized relocations IDENTICAL versus main, including the complete 32-byte MetroTRK .text. Global link-address audit 0 differences. - Full 43U all_source/progress/report/ok build: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. - Pool 0/0 identical. Literal audit analyzes all four functions without skips/errors (no string arguments). - Tests: workflow 8, literal 36, jump-table 27, pool 8 pass. Diff and main/leaf worktree checks pass. - Published tree 050f671b9cff3d9ca939cdcd6a960f6c1f4ce069 exactly matches tested local tree. Draft for explicit review of this existing-assembly restructuring; 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] > ### Split MetroTRK trap entries into four standalone sized functions > - Replaces the single assembly wrapper in [targsupp.c](https://github.com/coah80/wii-ipl/pull/775/files#diff-60a52f5c84b886b040c97b64aea120ec69cdcfa671b9b9e1e7153fdd6a2709c9) with four standalone assembly functions: `TRKAccessFile`, `TRKOpenFile`, `TRKCloseFile`, and `TRKPositionFile`. Each keeps the `nofralloc`, `trap`, and return instruction sequence. > - `TRKAccessFile` now has an explicit `DSIOResult` return type and parameter list. > - Adds 8-byte alignment directives before the latter three stubs and updates `VERSION_43U` conditional alignment and comments. > - Updates [symbols.txt](https://github.com/coah80/wii-ipl/pull/775/files#diff-92f49dd4754762deffc0a2c26a42d508945e86a4db65a437b06cd7a740fab114) so all four functions record a size of 0x8 at their existing addresses. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized b2dcf13.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 08:38:50 +00:00 (Migrated from github.com)

Orchestrator review: approved and merged by hand (the daemon flagged it on the asm-count scan).

Gate: DOL sha1 26116613… OK, 0 regressions, targsupp 0/4 -> 4/4 instruction-exact, code 32/32 linked.

Why the one forbidden-pattern hit is accepted: the scan counts asm function definitions, and this goes from one asm wrapper with four entry labels to four asm functions. No trap instruction is added, no retail code is transplanted, and twi 31,r0,0 has no C equivalent, so this is the "existing target structure makes it unavoidable" case in AGENTS.md. Typed, separately sized functions are also the honest representation of what the DOL contains (four 8-byte functions), and it turns 4 of the last 5 "missing" functions in the report into exact ones.

Nothing to change. For future PRs like this, keep doing what you did here: state up front that it restructures existing asm, so review is quick.

Orchestrator review: **approved and merged by hand** (the daemon flagged it on the asm-count scan). Gate: DOL sha1 `26116613…` OK, 0 regressions, `targsupp` 0/4 -> 4/4 instruction-exact, code 32/32 linked. Why the one forbidden-pattern hit is accepted: the scan counts asm *function definitions*, and this goes from one asm wrapper with four `entry` labels to four asm functions. No trap instruction is added, no retail code is transplanted, and `twi 31,r0,0` has no C equivalent, so this is the "existing target structure makes it unavoidable" case in AGENTS.md. Typed, separately sized functions are also the honest representation of what the DOL contains (four 8-byte functions), and it turns 4 of the last 5 "missing" functions in the report into exact ones. Nothing to change. For future PRs like this, keep doing what you did here: state up front that it restructures existing asm, so review is quick.
Sign in to join this conversation.