fix(tools): resolve $ORIGIN-prefixed converted module dependencies in import_audit #7454

Merged
ggkouujere-debug merged 1 commit from upstream-pr/7454 into main 2026-11-08 09:11:17 +00:00
ggkouujere-debug commented 2026-10-18 08:11:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ggkouujere-debug on 2026-10-18T08:11:42Z.


What

Follow-up to #7179, which fixed the base-name half of #7174 (libX.prx vs libX.prx.guest.prx). One mismatch remains: the relinker records converted modules' own dependencies as $ORIGIN/<file> (GuestModuleBuilder.cpp), where $ORIGIN is the importing module's directory — but tools/import_audit.py matches needed-library names verbatim, so e.g. $ORIGIN/libSceFace.prx.guest.prx is reported as a missing library even though libSceFace.prx.guest.prx is present in --modules.

The fix adds strip_origin(), which strips the $ORIGIN/ prefix before matching, and applies it in classify(), audit() (all three missing-library checks) and audit_host_dependencies(), mirroring how the loader expands $ORIGIN to the importing module's directory. Plain names are untouched.

Tested

  • New test_converted_module_resolves_plain_and_origin_library_names: fails on current main (exit 1, $ORIGIN/libSceFace.prx.guest.prx reported missing), passes with the fix (exit 0, no missing libraries, import classifies as module).
  • tools/tests/test_import_audit.py: 100 tests pass (2 pre-existing platform skips).
  • python3 tools/check_conventions.py --base origin/main: pass.

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: #7174 (follow-up to #7179)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4907497302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454). Originally posted by [ggkouujere-debug](https://github.com/ggkouujere-debug) on 2026-10-18T08:11:42Z. --- ### What Follow-up to #7179, which fixed the base-name half of #7174 (`libX.prx` vs `libX.prx.guest.prx`). One mismatch remains: the relinker records converted modules' own dependencies as `$ORIGIN/<file>` (`GuestModuleBuilder.cpp`), where `$ORIGIN` is the importing module's directory — but `tools/import_audit.py` matches needed-library names verbatim, so e.g. `$ORIGIN/libSceFace.prx.guest.prx` is reported as a missing library even though `libSceFace.prx.guest.prx` is present in `--modules`. The fix adds `strip_origin()`, which strips the `$ORIGIN/` prefix before matching, and applies it in `classify()`, `audit()` (all three missing-library checks) and `audit_host_dependencies()`, mirroring how the loader expands `$ORIGIN` to the importing module's directory. Plain names are untouched. ### Tested - New `test_converted_module_resolves_plain_and_origin_library_names`: fails on current `main` (exit 1, `$ORIGIN/libSceFace.prx.guest.prx` reported missing), passes with the fix (exit 0, no missing libraries, import classifies as `module`). - `tools/tests/test_import_audit.py`: 100 tests pass (2 pre-existing platform skips). - `python3 tools/check_conventions.py --base origin/main`: pass. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 - [x] Fixes: #7174 (follow-up to #7179) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
joedeangelis533-bot commented 2026-10-19 14:32:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by joedeangelis533-bot on 2026-10-19T14:32:50Z.


@ggkouujere-debug @johnohhh1 Following the order already recorded on #6171, I'll place our Windows host-library capitalization follow-up after #7454 and then #6171 and declare both dependencies. The standalone follow-up's rebase will preserve this PR's $ORIGIN check after Windows name resolution, plus #6171's host_modules argument and identity-side normalization.

Our branch fixes PE host imports falsely reported missing when filename capitalization differs; ELF lookup remains case sensitive. Standalone validation on main bcdee66d1 passes 112 tests with 3 platform skips. An isolated combination with exact heads 11840ad87 (#7454) and a12828cf6 (#6171), preserving upstream PE modules and normalizing requested names before identity lookup, passes 120 tests with 3 skips, plus eight SCE-identity/$ORIGIN resolution and ambiguity cases. Combined evidence uses main 3686960c5; its audit/tool test blobs match bcdee66d1 exactly.

Our follow-up stays a two-file Windows lookup change and will take its own rebase after the existing pair lands. No game runtime, full native build, Linux/macOS, or performance claim.

AI-assisted implementation, testing and communication: OpenAI Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269733797 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454#issuecomment-6269733797). Originally posted by [joedeangelis533-bot](https://github.com/joedeangelis533-bot) on 2026-10-19T14:32:50Z. --- <!-- anyps5-windows-host-case-order-v1 --> @ggkouujere-debug @johnohhh1 Following the order already recorded [on #6171](https://github.com/boykopovar/AnyPS5/pull/6171#issuecomment-6264417521), I'll place our Windows host-library capitalization follow-up **after #7454 and then #6171** and declare both dependencies. The standalone follow-up's rebase will preserve this PR's `$ORIGIN` check after Windows name resolution, plus #6171's `host_modules` argument and identity-side normalization. [Our branch](https://github.com/joedeangelis533-bot/AnyPS5/tree/fix/audit-windows-host-library-case) fixes PE host imports falsely reported missing when filename capitalization differs; ELF lookup remains case sensitive. Standalone validation on main `bcdee66d1` passes 112 tests with 3 platform skips. An isolated combination with exact heads `11840ad87` (#7454) and `a12828cf6` (#6171), preserving upstream PE modules and normalizing requested names before identity lookup, passes 120 tests with 3 skips, plus eight SCE-identity/$ORIGIN resolution and ambiguity cases. Combined evidence uses main `3686960c5`; its audit/tool test blobs match `bcdee66d1` exactly. Our follow-up stays a two-file Windows lookup change and will take its own rebase after the existing pair lands. No game runtime, full native build, Linux/macOS, or performance claim. AI-assisted implementation, testing and communication: OpenAI Codex.
johnohhh1 commented 2026-10-20 18:29:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnohhh1 on 2026-10-20T18:29:47Z.


Independent validation of 11840ad87 on Ubuntu and Windows Server 2025/Python 3.12 and 3.14. The original same-directory $ORIGIN/<file> case passes. I also found two directory-bearing forms emitted by the relinker that still produce false missing-library reports; reproducer below.

Author-run CI and detailed artifacts, workflow commit f97135c4b:

Tested snapshot Linux passed / skipped Windows passed / skipped, each Python version
Exact #7454 11840ad87 108 / 1 107 / 2
Rebase candidate aa89b41d8 on main 78e398d6d 120 / 1 119 / 2
Candidate plus #6171 35bf15c51, with its prepared identity-side normalization (70d98a029) 127 / 1 126 / 2

Skips are the Windows-only replacement test on Linux and two POSIX permission tests on Windows. All three snapshots pass six subprocess CLI cases per platform. The new converted-module regression fails against both original and current main's tool, with one assertion failure and zero errors each. The combined preview also passes all four integration methods; omitting the identity-side normalization reproduces eight failed subcases with zero errors.

Rebase assistance: candidate commit aa89b41d8 preserves your authorship and resolves the two tool conflicts by retaining main's Windows host-importer matching and ModuleNames suffix/case rules alongside your prefix removal. The separate #6171 preview keeps our identity adjustment on our side. Both PR branches are unchanged; the agreed order stays #7454, then #6171. Candidate conventions and whitespace pass.

Remaining path cases: stripping only $ORIGIN/ leaves a relative path that cannot match the audit's basename module set. With both module directories supplied and the referenced provider verified present:

  • A consumer in app0/sce_module needing $ORIGIN/../Media/Modules/Provider.prx.guest.prx still exits 1, reporting that dependency missing.
  • An executable's .needed.json entry $ORIGIN/app0/Media/Modules/Provider.prx.guest.prx also still exits 1, reporting a missing needed library with zero import references.

These correspond to guest dependency emission and executable dependency emission. On Linux, both fail on the exact PR, rebase candidate and combined preview; the same-directory control passes on all three. This additional path probe was not run on Windows.

Self-contained replay and pinned snapshots: check out the fork's validation/pr-7454-windows-linux-20261020 branch, then run python validation-7454/probe_origin_layout.py. Could these emitted directory forms be covered when rebasing, while retaining ambiguity checks and the physical-file requirement for host dependencies?

Synthetic Python/ELF/PE checks only; no native build, title/console replay, macOS result or performance claim. No maintainer-triggered upstream CI is claimed.

AI-assisted testing, rebase preparation and reporting: OpenAI Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298185497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454#issuecomment-6298185497). Originally posted by [johnohhh1](https://github.com/johnohhh1) on 2026-10-20T18:29:47Z. --- Independent validation of `11840ad87` on Ubuntu and Windows Server 2025/Python 3.12 and 3.14. The original same-directory `$ORIGIN/<file>` case passes. I also found two directory-bearing forms emitted by the relinker that still produce false missing-library reports; reproducer below. [Author-run CI and detailed artifacts](https://github.com/johnohhh1/AnyPS5/actions/runs/39474708006), workflow commit `f97135c4b`: | Tested snapshot | Linux passed / skipped | Windows passed / skipped, each Python version | | --- | --- | --- | | Exact #7454 `11840ad87` | 108 / 1 | 107 / 2 | | Rebase candidate `aa89b41d8` on main `78e398d6d` | 120 / 1 | 119 / 2 | | Candidate plus #6171 `35bf15c51`, with its prepared identity-side normalization (`70d98a029`) | 127 / 1 | 126 / 2 | Skips are the Windows-only replacement test on Linux and two POSIX permission tests on Windows. All three snapshots pass six subprocess CLI cases per platform. The new converted-module regression fails against both original and current main's tool, with one assertion failure and zero errors each. The combined preview also passes all four integration methods; omitting the identity-side normalization reproduces eight failed subcases with zero errors. **Rebase assistance:** [candidate commit `aa89b41d8`](https://github.com/johnohhh1/AnyPS5/commit/aa89b41d818006bbf5dc3623fa6339d17a9ba727) preserves your authorship and resolves the two tool conflicts by retaining main's Windows host-importer matching and `ModuleNames` suffix/case rules alongside your prefix removal. The [separate #6171 preview](https://github.com/johnohhh1/AnyPS5/commit/70d98a029633425154fc2178cd4c074ccdb6dc88) keeps our identity adjustment on our side. Both PR branches are unchanged; the agreed order stays #7454, then #6171. Candidate conventions and whitespace pass. **Remaining path cases:** stripping only `$ORIGIN/` leaves a relative path that cannot match the audit's basename module set. With both module directories supplied and the referenced provider verified present: - A consumer in `app0/sce_module` needing `$ORIGIN/../Media/Modules/Provider.prx.guest.prx` still exits 1, reporting that dependency missing. - An executable's `.needed.json` entry `$ORIGIN/app0/Media/Modules/Provider.prx.guest.prx` also still exits 1, reporting a missing needed library with zero import references. These correspond to [guest dependency emission](https://github.com/boykopovar/AnyPS5/blob/78e398d6d007c1ec6fcf5533488a369ad38eef15/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L395) and [executable dependency emission](https://github.com/boykopovar/AnyPS5/blob/78e398d6d007c1ec6fcf5533488a369ad38eef15/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L335). On Linux, both fail on the exact PR, rebase candidate and combined preview; the same-directory control passes on all three. This additional path probe was not run on Windows. [Self-contained replay and pinned snapshots](https://github.com/johnohhh1/AnyPS5/blob/082a7858b68e867fffdb734964edfc3e86437b3d/validation-7454/probe_origin_layout.py): check out the fork's `validation/pr-7454-windows-linux-20261020` branch, then run `python validation-7454/probe_origin_layout.py`. Could these emitted directory forms be covered when rebasing, while retaining ambiguity checks and the physical-file requirement for host dependencies? Synthetic Python/ELF/PE checks only; no native build, title/console replay, macOS result or performance claim. No maintainer-triggered upstream CI is claimed. AI-assisted testing, rebase preparation and reporting: OpenAI Codex.
ggkouujere-debug commented 2026-10-21 10:44:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ggkouujere-debug on 2026-10-21T10:44:18Z.


Thank you for the independent validation — great to see the exact PR commit pass on both Ubuntu and Windows Server 2025 across Python 3.12 and 3.14.
Agreed: #7454 stays first, then #6171. I'll rebase the PR branch onto latest main using the rebase assistance you prepared (authorship preserved), resolving the two tool conflicts as you suggested.
On the remaining path cases: yes, let's cover the two directory-bearing $ORIGIN forms in the rebase. After stripping $ORIGIN/, the audit will normalize the remaining relative path (resolving .. segments) and match on the resulting basename against the converted-module set, while keeping the ambiguity checks and the physical-file requirement for host dependencies. I'll add regression cases from your probe layout so the same-directory control and both new forms are covered.
Thanks again for the thorough validation and the rebase assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314032889 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454#issuecomment-6314032889). Originally posted by [ggkouujere-debug](https://github.com/ggkouujere-debug) on 2026-10-21T10:44:18Z. --- Thank you for the independent validation — great to see the exact PR commit pass on both Ubuntu and Windows Server 2025 across Python 3.12 and 3.14. Agreed: #7454 stays first, then #6171. I'll rebase the PR branch onto latest main using the rebase assistance you prepared (authorship preserved), resolving the two tool conflicts as you suggested. On the remaining path cases: yes, let's cover the two directory-bearing $ORIGIN forms in the rebase. After stripping $ORIGIN/, the audit will normalize the remaining relative path (resolving .. segments) and match on the resulting basename against the converted-module set, while keeping the ambiguity checks and the physical-file requirement for host dependencies. I'll add regression cases from your probe layout so the same-directory control and both new forms are covered. Thanks again for the thorough validation and the rebase assistance.
JJenkx commented 2026-10-22 00:14:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T00:14:31Z.


Real-title confirmation for the directory-bearing cases already discussed here: Darkest Dungeon II (PPSA19591) produces both ../Plugins and ../../sce_module dependencies after conversion.

I compared main a6dcea9279b53b3a39c13695eac66f7c8b5b503c with a private tool-only integration of this PR's unchanged head 11840ad87c4065873cb2923b2367232d33bbe5ee. The one Windows host-matching conflict retains main's matching before the prefix check; main's newer locate_missing and --strict-stubs behavior are retained. This is an integration result, not a test of the exact standalone PR snapshot.

All 17 registries and all three converted-module directories were supplied. A converted-only symlink view avoids scanning the original encrypted .prx assets staged beside their converted counterparts. Both audits exit 1:

Dependency reported missing Main references Main + #7454 references
$ORIGIN/PS5Util.prx.guest.prx 1 0
$ORIGIN/libSceFace.prx.guest.prx 1 0
$ORIGIN/libfmod.prx.guest.prx 1 0
$ORIGIN/../../sce_module/libSceNpCppWebApi.prx.guest.prx 1 1
$ORIGIN/../../sce_module/libc.prx.guest.prx 9 9
$ORIGIN/../Plugins/NativePluginPS5Example.prx.guest.prx 1 1

I independently parsed each importing ELF's DT_NEEDED, expanded $ORIGIN using that importing file's physical parent, resolved the resulting path, and verified that all 14 references above point to existing files (with SHA-256 recorded locally). For example, app0/Media/Modules/Il2cppUserAssemblies.prx.guest.prx resolves its ../Plugins/NativePluginPS5Example.prx.guest.prx dependency to app0/Media/Plugins/NativePluginPS5Example.prx.guest.prx.

Import classifications are unchanged: 6,617 references, 4,896 unique entries, 4,697 implemented / 47 stub / 152 module / 0 absent. The audit also reports ld-linux-x86-64.so.2 separately; that system-loader issue is outside the $ORIGIN result above. Host dependency failures are empty in both reports.

Current-main Python suite: 122 tests run, 2 skipped; private integration plus this PR's regression: 123 run, 2 skipped, both successful. Command: python3 -m unittest discover -s tools/tests -p test_import_audit.py. Static Linux/ELF evidence only; no game bring-up, native-loader, Windows or performance claim. This supports covering the nested forms in your planned rebase; no competing PR opened.

AI-assisted testing and reporting: OpenAI Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329478356 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454#issuecomment-6329478356). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T00:14:31Z. --- Real-title confirmation for the directory-bearing cases already discussed here: Darkest Dungeon II (`PPSA19591`) produces both `../Plugins` and `../../sce_module` dependencies after conversion. I compared main `a6dcea9279b53b3a39c13695eac66f7c8b5b503c` with a private tool-only integration of this PR's unchanged head `11840ad87c4065873cb2923b2367232d33bbe5ee`. The one Windows host-matching conflict retains main's matching before the prefix check; main's newer `locate_missing` and `--strict-stubs` behavior are retained. This is an integration result, not a test of the exact standalone PR snapshot. All 17 registries and all three converted-module directories were supplied. A converted-only symlink view avoids scanning the original encrypted `.prx` assets staged beside their converted counterparts. Both audits exit 1: | Dependency reported missing | Main references | Main + #7454 references | | --- | ---: | ---: | | `$ORIGIN/PS5Util.prx.guest.prx` | 1 | 0 | | `$ORIGIN/libSceFace.prx.guest.prx` | 1 | 0 | | `$ORIGIN/libfmod.prx.guest.prx` | 1 | 0 | | `$ORIGIN/../../sce_module/libSceNpCppWebApi.prx.guest.prx` | 1 | 1 | | `$ORIGIN/../../sce_module/libc.prx.guest.prx` | 9 | 9 | | `$ORIGIN/../Plugins/NativePluginPS5Example.prx.guest.prx` | 1 | 1 | I independently parsed each importing ELF's `DT_NEEDED`, expanded `$ORIGIN` using that importing file's physical parent, resolved the resulting path, and verified that all 14 references above point to existing files (with SHA-256 recorded locally). For example, `app0/Media/Modules/Il2cppUserAssemblies.prx.guest.prx` resolves its `../Plugins/NativePluginPS5Example.prx.guest.prx` dependency to `app0/Media/Plugins/NativePluginPS5Example.prx.guest.prx`. Import classifications are unchanged: 6,617 references, 4,896 unique entries, 4,697 implemented / 47 stub / 152 module / 0 absent. The audit also reports `ld-linux-x86-64.so.2` separately; that system-loader issue is outside the `$ORIGIN` result above. Host dependency failures are empty in both reports. Current-main Python suite: 122 tests run, 2 skipped; private integration plus this PR's regression: 123 run, 2 skipped, both successful. Command: `python3 -m unittest discover -s tools/tests -p test_import_audit.py`. Static Linux/ELF evidence only; no game bring-up, native-loader, Windows or performance claim. This supports covering the nested forms in your planned rebase; no competing PR opened. AI-assisted testing and reporting: OpenAI Codex.
THEMANnt commented 2026-10-29 06:07:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-29T06:07:29Z.

Review: COMMENTED


Reviewed 11840ad87c4065873cb2923b2367232d33bbe5ee against f6eeca4f5f0a6eee1eb884c1e8148a90d0d5d38f. The $ORIGIN/ prefix is removed for converted-module availability checks while original dependency names remain in diagnostics. Plain module names still resolve; similarly named prefixes and nested names are not silently collapsed to a basename. No actionable defect found in this change.

Windows/Python 3.11 validation: head 106 passed, 3 skipped; baseline 105 passed, 3 skipped. Skips cover two POSIX permission cases and one unavailable symlink privilege. The new regression fails against the old implementation (exit 1 rather than 0). Independent direct classification and host-dependency probes also reproduce the old false-missing result and pass with the fix, including plain, prefixed, lookalike-prefix and nested-name controls. No game execution was performed.

Publication-time checks: merge conflict with main. Please complete these checks before final approval; this status alone is not a demonstrated implementation defect.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693547867 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7454#pullrequestreview-5693547867). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-29T06:07:29Z. **Review:** COMMENTED --- Reviewed `11840ad87c4065873cb2923b2367232d33bbe5ee` against `f6eeca4f5f0a6eee1eb884c1e8148a90d0d5d38f`. The `$ORIGIN/` prefix is removed for converted-module availability checks while original dependency names remain in diagnostics. Plain module names still resolve; similarly named prefixes and nested names are not silently collapsed to a basename. No actionable defect found in this change. Windows/Python 3.11 validation: head 106 passed, 3 skipped; baseline 105 passed, 3 skipped. Skips cover two POSIX permission cases and one unavailable symlink privilege. The new regression fails against the old implementation (exit 1 rather than 0). Independent direct classification and host-dependency probes also reproduce the old false-missing result and pass with the fix, including plain, prefixed, lookalike-prefix and nested-name controls. No game execution was performed. Publication-time checks: merge conflict with main. Please complete these checks before final approval; this status alone is not a demonstrated implementation defect.
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!7454
No description provided.