fix(tools): flag qualified imports exported only under a NID #9241

Merged
veosett merged 2 commits from upstream-pr/9241 into main 2026-10-24 01:21:33 +00:00
veosett commented 2026-10-21 16:18:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by veosett on 2026-10-21T16:18:20Z.


What

A library-qualified literal import such as strlen from libc.prx was reported as implemented with exit code 0 even when the provider exported only its NID. The loader requires the literal name and cannot resolve this import.

Preserve the implementation/stub class and report a separate symbol_mismatch flag and count. Show the unresolved name and exported NID, include strong mismatches in the current-stop selection, and return exit code 1. Preserve literal exports, unqualified NID fallback, guest-module priority and the existing weak-import audit policy.

Determine the mismatch during host-name fallback lookup, independently of the function's implementation class. This composes with #9372's partial class without taking that PR as a dependency. Add a regression for unresolved fallback and guest-module priority.

Found while investigating #9180. This changes the diagnostic tool; SDK conversion and runtime startup are outside its scope.

Tested

Refreshed onto main 0db47b263d1019043f7d28fad4e7ee0a1ea5ec6a. Final head: b7a6e9d245e190a0fc2ba1d26f7fc9a84c482b98.

Windows 11, Python 3.12.14, synthetic registries/providers; no compiler invocation.

  • Full test_import_audit.py suite: 126 tests, 123 passed, 3 skipped (two POSIX permission cases and the Windows symlink privilege case).
  • Before adapting this branch, git merge-tree with #9372 conflicted in tools/import_audit.py. The adapted head merges cleanly with #9372 at 72664d1ef99aca45fc3b6f17ddbd0653e4eae2eb.
  • Combined Git tree aea75d89e1f9a59c68aabb3c2d2eb194c36d5ff1, extracted outside the checkout: 128 tests, 124 passed, 4 skipped (the same three cases plus the source-commit check requiring a Git checkout).
  • 24 combined-tree cross-cases passed: implemented/stub/partial providers, literal/NID exports, qualified/unqualified imports, and strong/weak references. They verify mismatch reporting, summary counts and current-stop selection. A qualified NID-only partial provider still reports the name mismatch.
  • #9372 remains independent; its commits were not merged into this branch. The check covers its exact SHA above.
  • python tools/check_conventions.py --base origin/main and git diff --check: passed.

No new WSL, title or native loader run, and no system-library build. Earlier validation below belongs to the preceding head.

Earlier validation on preceding heads

Base: cecb540a63f614d2b06cbb557c6d1f6f02475fa3. Tested head: d3fdb88745.

  • Regression on the base: all 8 ELF/PE, implemented/stub and strong/weak subcases incorrectly returned 0. With the fix they return 1, preserve the classification, and select only strong imports as current stops.
  • Windows x64, Python 3.12.14: 125 tests discovered, 122 passed, 3 skipped (two POSIX permission cases and the symlink case requiring an unavailable Windows privilege).
  • Ubuntu 24.04 WSL, Python 3.12.3, the same commit: 125 tests discovered, 124 passed, 1 skipped (Windows read-only replacement behavior).
  • Command on both systems: python -m unittest discover -s tools/tests -p test_import_audit.py -v.
  • The tests also cover exact literal exports alongside NID exports and preserve Windows unqualified-import fallback.
  • A separate merged-tree check with #8718 (700be1869477a876cadc09bed94bac2239cfe209) and #8719 (037ad5dd967f0f2e8e1ada34482973e607de6efb) merges cleanly and runs 130 tests on Windows: 126 passed, 4 skipped (the same three platform/privilege cases and the source-commit stamp case outside a Git checkout).
  • python tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD pass.
  • python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/audit-sdk-symbol-names --jobs 4 completed with no confirmed overlap. Its legacy comparisons that conflict with main are qualified below.

No commercial title or SDK payload was executed, and system libraries were not rebuilt. This is a Python diagnostic change; no runtime or performance improvement is claimed.

The legacy shared-file changes in #6171 (guest module identities) and #7454 ($ORIGIN dependencies) were inspected and implement different behavior. Both already conflict with main, so their combined merge is unverified. The other legacy documentation-only comparisons concern different sections of USAGE.

Additional native loader validation on the same head, using fresh relinker-only builds on Windows x64 (WinLibs GCC 15.2.0) and Ubuntu 24.04 WSL (GCC 13.3): synthetic ELF inputs import shared#A#B from available.prx. Both audit versions read the registry produced by the actual relinker and the same provider files.

Provider export Actual Windows process Actual Linux process Audit on base Audit with this PR
9E8ipSX3c9g, the NID of shared unresolved ELF import shared from available.prx, status 0xC0000139 undefined symbol: shared, exit 127 Exit 0, no current stop Exit 1, current stop shared, symbol_mismatch: 1
Literal shared Expected provider return value 33 Expected provider exit value 33 Exit 0, no current stop Exit 0, no current stop, symbol_mismatch: 0

The synthetic processes actually ran on their native hosts. They validate the qualified-name diagnostic; they do not exercise the SDK CRT or title startup.

GitHub Build 39633560471 succeeded at d3fdb88745017415aa6f542230436ffe9bd0411d: relinker build/CTest on Ubuntu, Windows, macOS ARM64 and macOS x86_64, plus the ASan TLS-function-coverage job. The CTest steps themselves completed successfully. Full Linux/Windows system-library jobs were policy-skipped.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4954768087 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9241). Originally posted by [veosett](https://github.com/veosett) on 2026-10-21T16:18:20Z. --- ### What A library-qualified literal import such as `strlen` from `libc.prx` was reported as implemented with exit code 0 even when the provider exported only its NID. The loader requires the literal name and cannot resolve this import. Preserve the implementation/stub class and report a separate `symbol_mismatch` flag and count. Show the unresolved name and exported NID, include strong mismatches in the current-stop selection, and return exit code 1. Preserve literal exports, unqualified NID fallback, guest-module priority and the existing weak-import audit policy. Determine the mismatch during host-name fallback lookup, independently of the function's implementation class. This composes with #9372's `partial` class without taking that PR as a dependency. Add a regression for unresolved fallback and guest-module priority. Found while investigating #9180. This changes the diagnostic tool; SDK conversion and runtime startup are outside its scope. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Refreshed onto `main` `0db47b263d1019043f7d28fad4e7ee0a1ea5ec6a`. Final head: `b7a6e9d245e190a0fc2ba1d26f7fc9a84c482b98`. Windows 11, Python 3.12.14, synthetic registries/providers; no compiler invocation. - Full `test_import_audit.py` suite: 126 tests, 123 passed, 3 skipped (two POSIX permission cases and the Windows symlink privilege case). - Before adapting this branch, `git merge-tree` with #9372 conflicted in `tools/import_audit.py`. The adapted head merges cleanly with #9372 at `72664d1ef99aca45fc3b6f17ddbd0653e4eae2eb`. - Combined Git tree `aea75d89e1f9a59c68aabb3c2d2eb194c36d5ff1`, extracted outside the checkout: 128 tests, 124 passed, 4 skipped (the same three cases plus the source-commit check requiring a Git checkout). - 24 combined-tree cross-cases passed: implemented/stub/partial providers, literal/NID exports, qualified/unqualified imports, and strong/weak references. They verify mismatch reporting, summary counts and current-stop selection. A qualified NID-only `partial` provider still reports the name mismatch. - #9372 remains independent; its commits were not merged into this branch. The check covers its exact SHA above. - `python tools/check_conventions.py --base origin/main` and `git diff --check`: passed. No new WSL, title or native loader run, and no system-library build. Earlier validation below belongs to the preceding head. <details> <summary>Earlier validation on preceding heads</summary> Base: `cecb540a63f614d2b06cbb557c6d1f6f02475fa3`. Tested head: `d3fdb88745`. - Regression on the base: all 8 ELF/PE, implemented/stub and strong/weak subcases incorrectly returned 0. With the fix they return 1, preserve the classification, and select only strong imports as current stops. - Windows x64, Python 3.12.14: 125 tests discovered, 122 passed, 3 skipped (two POSIX permission cases and the symlink case requiring an unavailable Windows privilege). - Ubuntu 24.04 WSL, Python 3.12.3, the same commit: 125 tests discovered, 124 passed, 1 skipped (Windows read-only replacement behavior). - Command on both systems: `python -m unittest discover -s tools/tests -p test_import_audit.py -v`. - The tests also cover exact literal exports alongside NID exports and preserve Windows unqualified-import fallback. - A separate merged-tree check with #8718 (`700be1869477a876cadc09bed94bac2239cfe209`) and #8719 (`037ad5dd967f0f2e8e1ada34482973e607de6efb`) merges cleanly and runs 130 tests on Windows: 126 passed, 4 skipped (the same three platform/privilege cases and the source-commit stamp case outside a Git checkout). - `python tools/check_conventions.py --base origin/main` and `git diff --check origin/main...HEAD` pass. - `python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/audit-sdk-symbol-names --jobs 4` completed with no confirmed overlap. Its legacy comparisons that conflict with main are qualified below. No commercial title or SDK payload was executed, and system libraries were not rebuilt. This is a Python diagnostic change; no runtime or performance improvement is claimed. The legacy shared-file changes in #6171 (guest module identities) and #7454 (`$ORIGIN` dependencies) were inspected and implement different behavior. Both already conflict with main, so their combined merge is unverified. The other legacy documentation-only comparisons concern different sections of USAGE. Additional native loader validation on the same head, using fresh relinker-only builds on Windows x64 (WinLibs GCC 15.2.0) and Ubuntu 24.04 WSL (GCC 13.3): synthetic ELF inputs import `shared#A#B` from `available.prx`. Both audit versions read the registry produced by the actual relinker and the same provider files. | Provider export | Actual Windows process | Actual Linux process | Audit on base | Audit with this PR | |---|---|---|---|---| | `9E8ipSX3c9g`, the NID of `shared` | `unresolved ELF import shared from available.prx`, status `0xC0000139` | `undefined symbol: shared`, exit 127 | Exit 0, no current stop | Exit 1, current stop `shared`, `symbol_mismatch: 1` | | Literal `shared` | Expected provider return value 33 | Expected provider exit value 33 | Exit 0, no current stop | Exit 0, no current stop, `symbol_mismatch: 0` | The synthetic processes actually ran on their native hosts. They validate the qualified-name diagnostic; they do not exercise the SDK CRT or title startup. [GitHub Build 39633560471](https://github.com/boykopovar/AnyPS5/actions/runs/39633560471) succeeded at `d3fdb88745017415aa6f542230436ffe9bd0411d`: relinker build/CTest on Ubuntu, Windows, macOS ARM64 and macOS x86_64, plus the ASan TLS-function-coverage job. The CTest steps themselves completed successfully. Full Linux/Windows system-library jobs were policy-skipped. </details> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
xXPBSXx commented 2026-10-21 17:53:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T17:53:26Z.


Linux data point for d3fdb88745 (WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; Python 3.12.3), this head merged onto main 950388bfd (clean merge), python3 -I tools/tests/test_import_audit.py:

  • With the PR: 125 tests OK, 1 skipped (Windows read-only behaviour).
  • Without it (the PR's test_import_audit.py on top of main without the PR's source change): FAILED (8 failures, 3 errors).
    Not tested: macOS, Windows.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322785427 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9241#issuecomment-6322785427). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T17:53:26Z. --- Linux data point for `d3fdb88745` (WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; Python 3.12.3), this head merged onto `main` `950388bfd` (clean merge), `python3 -I tools/tests/test_import_audit.py`: - With the PR: 125 tests OK, 1 skipped (Windows read-only behaviour). - Without it (the PR's `test_import_audit.py` on top of `main` without the PR's source change): FAILED (8 failures, 3 errors). Not tested: macOS, Windows. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9241
No description provided.