tools: audit actual narrow-string values at PPC call sites #758

Merged
coah80 merged 1 commits from agent/bittle/literal-reference-audit into main 2026-10-02 06:59:04 +00:00
coah80 commented 2026-10-02 06:57:01 +00:00 (Migrated from github.com)

Scope

Add an advisory literal-reference audit plus 36 regression tests and six lines of AGENTS usage guidance. No game source, symbol metadata, splits, matching flags, or build dependencies change. This packages the semantic audit that found #742 rather than treating a 100% instruction score as proof of correct data.

The tool tracks statically addressed narrow strings through GPR moves/additions and CFG joins, including shared-base records and named tail calls. It compares actual bytes at paired call sites with the same call identity. It uses the existing jump_table_diff ELF support and pyelftools; no new package dependency.

Limits

This is not a matching gate: binary data can resemble a string, call argument consumption is not inferred, mutable pointer globals/dynamic indices are not followed, and compiler aliases are never guessed. Unequal-size functions and missing exact names are explicitly skipped. Every candidate still requires assembly review. Exit 0 is no candidates, 1 is review candidates, and 2 is incomplete/invalid input.

Verification on 9ef60d674d

  • Full 43U all_source/progress/report/ok build passed; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, byte-identical to freshly built main.
  • All 1,027 native source objects have identical allocated section bytes and normalized relocations versus main. No progress gain claimed.
  • Full default audit: 12,261 analyzed functions, 5,975 compared arguments, 0 candidates, 0 errors, 6 explicit exact-name/alias skips.
  • Real tiCandidateBox native/reference negative experiment: inject the historical malformed 132-byte pane table in memory without changing any code. All six bad call arguments from #742 are detected; current table produces zero candidates. No original binary is committed.
  • 36 new tests pass, including fixed-width records, relocation bounds, duplicate section names, CFG merges/loops/switches, call clobbers, named tail calls, and conservative paired-single updates. Existing jump-table 27, pool 8, and workflow 7 tests pass.
  • py_compile, diff --check, main --synced and leaf worktree checks pass.
  • Published tree 8ffbbc0cfd exactly matches the locally tested tree.

Draft for review; no merge performed.

Note

Add literal_reference_diff tool to audit narrow-string values at PPC call sites

  • Adds a new decomp-assist tool that compares string literal arguments at PowerPC call sites between source and reference objects, reporting mismatches with location, register, bytes, and decoded text.
  • The analysis decodes functions, walks control flow (branches, switch tables, loops), and tracks literal addresses through a conservative register dataflow. Only provably valid addresses are compared; volatile registers are forgotten across calls.
  • The CLI loads a report, selects functions (exact match by default, with flags for all or explicit selection), and exits with distinct statuses for errors, candidates, and clean runs.
  • Covers AGENTS.md docs and a large unittest suite with synthetic ELF fixtures.
  • Risk: analysis is intentionally conservative — mutable pointer globals, non-relocated direct calls, and conflicting branch-join register values are skipped rather than guessed at.

Macroscope summarized eb668b5.

## Scope Add an advisory literal-reference audit plus 36 regression tests and six lines of AGENTS usage guidance. No game source, symbol metadata, splits, matching flags, or build dependencies change. This packages the semantic audit that found #742 rather than treating a 100% instruction score as proof of correct data. The tool tracks statically addressed narrow strings through GPR moves/additions and CFG joins, including shared-base records and named tail calls. It compares actual bytes at paired call sites with the same call identity. It uses the existing jump_table_diff ELF support and pyelftools; no new package dependency. ## Limits This is not a matching gate: binary data can resemble a string, call argument consumption is not inferred, mutable pointer globals/dynamic indices are not followed, and compiler aliases are never guessed. Unequal-size functions and missing exact names are explicitly skipped. Every candidate still requires assembly review. Exit 0 is no candidates, 1 is review candidates, and 2 is incomplete/invalid input. ## Verification on 9ef60d674d871e9d936b6f608dc7392de529e97d - Full 43U all_source/progress/report/ok build passed; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, byte-identical to freshly built main. - All 1,027 native source objects have identical allocated section bytes and normalized relocations versus main. No progress gain claimed. - Full default audit: 12,261 analyzed functions, 5,975 compared arguments, 0 candidates, 0 errors, 6 explicit exact-name/alias skips. - Real tiCandidateBox native/reference negative experiment: inject the historical malformed 132-byte pane table in memory without changing any code. All six bad call arguments from #742 are detected; current table produces zero candidates. No original binary is committed. - 36 new tests pass, including fixed-width records, relocation bounds, duplicate section names, CFG merges/loops/switches, call clobbers, named tail calls, and conservative paired-single updates. Existing jump-table 27, pool 8, and workflow 7 tests pass. - py_compile, diff --check, main --synced and leaf worktree checks pass. - Published tree 8ffbbc0cfdee5d1f37a740d65b78103c7e41ff5e exactly matches the locally tested tree. Draft 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] > ### Add `literal_reference_diff` tool to audit narrow-string values at PPC call sites > - Adds a new decomp-assist tool that compares string literal arguments at PowerPC call sites between source and reference objects, reporting mismatches with location, register, bytes, and decoded text. > - The analysis decodes functions, walks control flow (branches, switch tables, loops), and tracks literal addresses through a conservative register dataflow. Only provably valid addresses are compared; volatile registers are forgotten across calls. > - The CLI loads a report, selects functions (exact match by default, with flags for all or explicit selection), and exits with distinct statuses for errors, candidates, and clean runs. > - Covers AGENTS.md docs and a large unittest suite with synthetic ELF fixtures. > - Risk: analysis is intentionally conservative — mutable pointer globals, non-relocated direct calls, and conflicting branch-join register values are skipped rather than guessed at. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized eb668b5.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 06:59:02 +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.