fix(relinker): discover bundled modules in prx directories #602

Merged
NumberGuan merged 1 commit from upstream-pr/602 into main 2026-10-05 03:54:19 +00:00
NumberGuan commented 2026-10-05 02:23:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NumberGuan on 2026-10-05T02:23:57Z.


What

The relinker ignores bundled ELF modules in a sibling prx/ directory. Discover that directory alongside either sce_module/ or sce_modules/, preserve each module's folder under app0/, and write Linux dependency paths relative to the importing module. The CLI layout and usage documentation reflect both folders.

Refs #556. This addresses module discovery only. The duplicate-export rejection remains in place; the rt7XQ7s-wQQ collision reported for DOOM + DOOM II still needs separate investigation. This PR does not claim that title now runs.

Tested

Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 (15.2.0posix-14.0.0-ucrt-r7), Python 3.12.

  • Built the relinker and all tests registered in core/relinker/CMakeLists.txt through an isolated CMake harness. ctest --output-on-failure --timeout 60 --parallel 2: 22/22 passed.
  • The new test fails against the original GuestModuleBuilder because it rejects a lone prx/ directory, and passes with this change.
  • Synthetic ELF fixtures cover lone prx/, coexistence with either standard directory, dependencies between folders, preserved output paths and CLI layout, exclusion of matching filenames in both folders, invalid directories, singular/plural ambiguity, and retained duplicate-export rejection.
  • Executed the generated Windows fixtures: guest modules load and imports resolve before the executable returns 42. Linux output format and DT_NEEDED paths were checked on Windows.

No game or homebrew title was run. Native Linux execution, system-library builds, and the full-project test suite were not tested.

Checklist

  • Based on current main; no other open PR implements the same behavior
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source; no dependencies added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4739428561 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/602). Originally posted by [NumberGuan](https://github.com/NumberGuan) on 2026-10-05T02:23:57Z. --- ### What The relinker ignores bundled ELF modules in a sibling `prx/` directory. Discover that directory alongside either `sce_module/` or `sce_modules/`, preserve each module's folder under `app0/`, and write Linux dependency paths relative to the importing module. The CLI layout and usage documentation reflect both folders. Refs #556. This addresses module discovery only. The duplicate-export rejection remains in place; the `rt7XQ7s-wQQ` collision reported for DOOM + DOOM II still needs separate investigation. This PR does not claim that title now runs. ### Tested Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 (`15.2.0posix-14.0.0-ucrt-r7`), Python 3.12. - Built the relinker and all tests registered in `core/relinker/CMakeLists.txt` through an isolated CMake harness. `ctest --output-on-failure --timeout 60 --parallel 2`: **22/22 passed**. - The new test fails against the original `GuestModuleBuilder` because it rejects a lone `prx/` directory, and passes with this change. - Synthetic ELF fixtures cover lone `prx/`, coexistence with either standard directory, dependencies between folders, preserved output paths and CLI layout, exclusion of matching filenames in both folders, invalid directories, singular/plural ambiguity, and retained duplicate-export rejection. - Executed the generated Windows fixtures: guest modules load and imports resolve before the executable returns 42. Linux output format and `DT_NEEDED` paths were checked on Windows. No game or homebrew title was run. Native Linux execution, system-library builds, and the full-project test suite were not tested. ### Checklist - [x] Based on current `main`; no other open PR implements the same behavior - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source; no dependencies added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Codex)
oneandonlydean commented 2026-10-05 03:09:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T03:09:14Z.


Thanks, this looks right to me. prx/ is now read next to either sce_module/ or sce_modules/, exclusions apply to a file of that name in both folders, each converted module keeps its own folder under app0/, and the Linux DT_NEEDED entries between modules are relative to the importing module (so $ORIGIN/x.guest.prx within one folder, as before, and $ORIGIN/../prx/... across folders). Two modules with the same file name in both folders still stop on "Conflicting guest output filename", which is a clear error.

Since you couldn't run it on Linux, I did: guest_module_directories and the updated linux_load_alignment pass, both fail on main as expected, and the full ctest passes with this branch merged. It also merges cleanly with the other open PRs that touch the relinker.

One thing for later, not for this PR: games usually load their prx/ modules themselves with sceKernelLoadStartModule("/app0/prx/..."). With this change those modules are already linked at startup, but that later call still goes to dlopen on the original path rather than the converted .guest.prx, so it may need a small mapping once a game that does this gets further.

CI hasn't run yet on this branch (first-time workflows need approval). Once it's green, it's ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5987416971 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/602#issuecomment-5987416971). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T03:09:14Z. --- Thanks, this looks right to me. `prx/` is now read next to either `sce_module/` or `sce_modules/`, exclusions apply to a file of that name in both folders, each converted module keeps its own folder under `app0/`, and the Linux `DT_NEEDED` entries between modules are relative to the importing module (so `$ORIGIN/x.guest.prx` within one folder, as before, and `$ORIGIN/../prx/...` across folders). Two modules with the same file name in both folders still stop on "Conflicting guest output filename", which is a clear error. Since you couldn't run it on Linux, I did: `guest_module_directories` and the updated `linux_load_alignment` pass, both fail on main as expected, and the full ctest passes with this branch merged. It also merges cleanly with the other open PRs that touch the relinker. One thing for later, not for this PR: games usually load their `prx/` modules themselves with `sceKernelLoadStartModule("/app0/prx/...")`. With this change those modules are already linked at startup, but that later call still goes to `dlopen` on the original path rather than the converted `.guest.prx`, so it may need a small mapping once a game that does this gets further. CI hasn't run yet on this branch (first-time workflows need approval). Once it's green, it's ready to merge from my side.
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!602
No description provided.