fix(relinker): match needed module names that differ only in the extension #1830

Merged
tv7 merged 2 commits from upstream-pr/1830 into main 2026-10-10 04:41:41 +00:00
tv7 commented 2026-10-08 20:45:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-08T20:45:41Z.


What

Fixes items 1 and 5 of #1794 (traced in this comment).

A title's executable can name a bundled module differently from the file it ships. Dying Light 2 (PPSA02262) needs EOSSDK-PS5-Shipping.debug_prx and ships EOSSDK-PS5-Shipping.prx beside the executable. Needed names were matched by exact filename, so the relinker skipped the module without an error, and start-up stopped with Failed to load module: ...\libs\EOSSDK-PS5-Shipping.debug_prx. Renaming the file is not a workaround. The title later calls sceKernelLoadStartModule("/app0//EOSSDK-PS5-Shipping.prx"), and dlopen looks for app0/EOSSDK-PS5-Shipping.prx.guest.prx. That load fails with ENOENT, so the title's EOS lobby backend fails and CGame::Initialize asserts Net_StartUp failed.

GuestModuleBuilder now resolves a needed name that no file has exactly to a module whose name differs only in its .prx, .sprx or .debug_prx extension. This applies both in the module directories and in the search under the input. The output keeps the shipped file name (EOSSDK-PS5-Shipping.prx.guest.prx), so run-time loads by that name find it. The needed name is added as another name of that guest module, so the executable binds to it instead of asking for a host library. An exact filename still wins. Two candidates for one needed name are ambiguous, as for exact names.

Tested

Windows 11, MinGW GCC 15.2.0, RTX 3070:

  • guest_needed_modules has new cases. An executable needs needed.debug_prx while needed.prx is shipped, once in Media/Modules and once in sce_module/, on both the Linux and the Windows output. The guest output is needed.prx.guest.prx, the Linux executable's DT_NEEDED is that path and no host needed.debug_prx, and the Windows output runs and returns 42. needed.prx and needed.sprx side by side are reported as ambiguous. Without the change the new cases fail; with it they pass.
  • Full build and ctest: 479/479 pass.
  • python tools/check_conventions.py --base origin/main passes.
  • Dying Light 2: relinked without renaming anything, EOSSDK-PS5-Shipping.prx.guest.prx is produced, and with the title's logging enabled it reports [Lobby.Backend.Eos] > [StartUp] ok and [Lobby] > [Initialize] all backends are up. Net_StartUp passes. The title then stops in EOS's RtcNetworkThread, which is the socket descriptor / fd_set question raised in #1794 and is not part of this PR. Other #1794 items were worked around locally for this run.

Linux output is covered by the test; I did not run a title on Linux.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792586325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1830). Originally posted by [tv7](https://github.com/tv7) on 2026-10-08T20:45:41Z. --- ### What Fixes items 1 and 5 of #1794 (traced in [this comment](https://github.com/boykopovar/AnyPS5/issues/1794#issuecomment-6068608707)). A title's executable can name a bundled module differently from the file it ships. Dying Light 2 (PPSA02262) needs `EOSSDK-PS5-Shipping.debug_prx` and ships `EOSSDK-PS5-Shipping.prx` beside the executable. Needed names were matched by exact filename, so the relinker skipped the module without an error, and start-up stopped with `Failed to load module: ...\libs\EOSSDK-PS5-Shipping.debug_prx`. Renaming the file is not a workaround. The title later calls `sceKernelLoadStartModule("/app0//EOSSDK-PS5-Shipping.prx")`, and `dlopen` looks for `app0/EOSSDK-PS5-Shipping.prx.guest.prx`. That load fails with `ENOENT`, so the title's EOS lobby backend fails and `CGame::Initialize` asserts `Net_StartUp failed`. `GuestModuleBuilder` now resolves a needed name that no file has exactly to a module whose name differs only in its `.prx`, `.sprx` or `.debug_prx` extension. This applies both in the module directories and in the search under the input. The output keeps the shipped file name (`EOSSDK-PS5-Shipping.prx.guest.prx`), so run-time loads by that name find it. The needed name is added as another name of that guest module, so the executable binds to it instead of asking for a host library. An exact filename still wins. Two candidates for one needed name are ambiguous, as for exact names. ### Tested Windows 11, MinGW GCC 15.2.0, RTX 3070: - `guest_needed_modules` has new cases. An executable needs `needed.debug_prx` while `needed.prx` is shipped, once in `Media/Modules` and once in `sce_module/`, on both the Linux and the Windows output. The guest output is `needed.prx.guest.prx`, the Linux executable's `DT_NEEDED` is that path and no host `needed.debug_prx`, and the Windows output runs and returns 42. `needed.prx` and `needed.sprx` side by side are reported as ambiguous. Without the change the new cases fail; with it they pass. - Full build and `ctest`: 479/479 pass. - `python tools/check_conventions.py --base origin/main` passes. - Dying Light 2: relinked without renaming anything, `EOSSDK-PS5-Shipping.prx.guest.prx` is produced, and with the title's logging enabled it reports `[Lobby.Backend.Eos] > [StartUp] ok` and `[Lobby] > [Initialize] all backends are up`. `Net_StartUp` passes. The title then stops in EOS's `RtcNetworkThread`, which is the socket descriptor / `fd_set` question raised in #1794 and is not part of this PR. Other #1794 items were worked around locally for this run. Linux output is covered by the test; I did not run a title on Linux. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Rohan03x commented 2026-10-09 15:05:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rohan03x on 2026-10-09T15:05:30Z.


Tested on Windows with a second title that hits the same failure as #1794 item 1.

Setup: Windows 11 22621, GCC 15.2.0 UCRT Release, this PR (cb571d30) merged onto main d70b8998. Title: Palworld (PPSA23126, v01.102.999).

Case: the eboot's DT_NEEDED has EOSSDK-PS5-Shipping.debug_prx; the dump ships the module as prx/eossdk-ps5-shipping.prx (no DT_SONAME). The name differs in the extension and in case.

Result: with this PR the relinked app.exe is byte-identical to main's and still lists libs\EOSSDK-PS5-Shipping.debug_prx, so the app stops at start with Failed to load module, error 126. ModuleStem(path.filename().string()) == stem compares eossdk-ps5-shipping with EOSSDK-PS5-Shipping, so no alias is recorded. Relinker tests pass 36/36 with the PR.

Local variant: folding ASCII case in ModuleStem when windows is true (like the existing Windows-only filename fold) removes the slot, and the relinked app then gets past module loading on this host (it stops later on an unrelated missing import). Folding alone made windows_import_modules fail with Ambiguous guest dependency name: Party.prx, so an exact name has to win over a folded stem match in the alias loop. With that, 36/36 plus a new Foo-Bar.debug_prx / foo-bar.prx case. I can share the diff (+26 −7) if useful.

Limits: one title; the run only shows that module loading passes, not that the title boots. Dying Light 2 not tested. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083578994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1830#issuecomment-6083578994). Originally posted by [Rohan03x](https://github.com/Rohan03x) on 2026-10-09T15:05:30Z. --- Tested on Windows with a second title that hits the same failure as #1794 item 1. **Setup:** Windows 11 22621, GCC 15.2.0 UCRT Release, this PR (cb571d30) merged onto main d70b8998. Title: Palworld (PPSA23126, v01.102.999). **Case:** the eboot's `DT_NEEDED` has `EOSSDK-PS5-Shipping.debug_prx`; the dump ships the module as `prx/eossdk-ps5-shipping.prx` (no `DT_SONAME`). The name differs in the extension and in case. **Result:** with this PR the relinked `app.exe` is byte-identical to main's and still lists `libs\EOSSDK-PS5-Shipping.debug_prx`, so the app stops at start with `Failed to load module`, error 126. `ModuleStem(path.filename().string()) == stem` compares `eossdk-ps5-shipping` with `EOSSDK-PS5-Shipping`, so no alias is recorded. Relinker tests pass 36/36 with the PR. **Local variant:** folding ASCII case in `ModuleStem` when `windows` is true (like the existing Windows-only filename fold) removes the slot, and the relinked app then gets past module loading on this host (it stops later on an unrelated missing import). Folding alone made `windows_import_modules` fail with `Ambiguous guest dependency name: Party.prx`, so an exact name has to win over a folded stem match in the alias loop. With that, 36/36 plus a new `Foo-Bar.debug_prx` / `foo-bar.prx` case. I can share the diff (+26 −7) if useful. **Limits:** one title; the run only shows that module loading passes, not that the title boots. Dying Light 2 not tested. AI-assisted: yes.
tv7 commented 2026-10-09 21:29:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-09T21:29:54Z.


@Rohan03x thanks for the Palworld run and the diagnosis. I took your approach into the PR (0745d803e, credited in the commit) rather than asking for the diff:

  • On Windows ModuleStem folds ASCII case, so EOSSDK-PS5-Shipping.debug_prx matches eossdk-ps5-shipping.prx.
  • A name that already resolves to a guest image wins over a stem alias: the first pass treats a case-folded filename match as found (the existing Windows findGuest fold handles it), and the alias loop skips names already in guestNames. That is what keeps windows_import_modules (Party.prx) passing.
  • guest_needed_modules gets a Windows case for Foo-Bar.debug_prx vs prx/foo-bar.prx that runs the relinked exe. It fails on the previous head with Failed to load module ... Foo-Bar.debug_prx, error 126 (same as your report), and passes now.

Also rebased onto current main (no conflicts). Full build + ctest 516/516 on Windows (GCC 15.2 UCRT); check_conventions.py passes. If you can rerun Palworld on this head, that would confirm it on a real title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089575492 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1830#issuecomment-6089575492). Originally posted by [tv7](https://github.com/tv7) on 2026-10-09T21:29:54Z. --- @Rohan03x thanks for the Palworld run and the diagnosis. I took your approach into the PR (0745d803e, credited in the commit) rather than asking for the diff: - On Windows `ModuleStem` folds ASCII case, so `EOSSDK-PS5-Shipping.debug_prx` matches `eossdk-ps5-shipping.prx`. - A name that already resolves to a guest image wins over a stem alias: the first pass treats a case-folded filename match as found (the existing Windows `findGuest` fold handles it), and the alias loop skips names already in `guestNames`. That is what keeps `windows_import_modules` (`Party.prx`) passing. - `guest_needed_modules` gets a Windows case for `Foo-Bar.debug_prx` vs `prx/foo-bar.prx` that runs the relinked exe. It fails on the previous head with `Failed to load module ... Foo-Bar.debug_prx`, error 126 (same as your report), and passes now. Also rebased onto current main (no conflicts). Full build + ctest 516/516 on Windows (GCC 15.2 UCRT); `check_conventions.py` passes. If you can rerun Palworld on this head, that would confirm it on a real title.
github-actions[bot] commented 2026-10-09 22:05:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:05:58Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1815 core/relinker/relinker/src/guest/GuestModuleBuilder.cpp L75-76, L81-84
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090037669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1830#issuecomment-6090037669). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:05:58Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1815 | `core/relinker/relinker/src/guest/GuestModuleBuilder.cpp` [L75-76](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L75-L76), [L81-84](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/relinker/relinker/src/guest/GuestModuleBuilder.cpp#L81-L84) | | |
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!1830
No description provided.