feat(relinker): log deferred Windows modules the executable imports from #9228

Merged
savvaniss merged 2 commits from upstream-pr/9228 into main 2026-10-24 16:10:41 +00:00
savvaniss commented 2026-10-21 15:40:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T15:40:47Z.


What

This is the follow-up to #8162 that @oneandonlydean asked for in this comment.

Since #8162, a --module-dir module that the executable needs is deferred on Windows. The entry stub maps it at startup, and DynamicLoader runs its module_start and initializers only when the title loads it with sceKernelLoadStartModule. If the executable imports from such a module but the title never loads it, the module gets neither, and nothing reported that.

Now the Windows entry stub prints one line at startup for each deferred guest module that an import of the executable names. The lines come after the imports are bound and before Transferring control to ELF entry point:

Deferred module app0/Media/Modules/needed.prx.guest.prx: the executable imports from it, but it starts only when the title loads it
  • Which modules: a guest module with DeferInitialization that is in the search order of one of the executable's own imports, matched by file name or module identity. The stub uses the same match to bind the import. A guest module's own imports do not count. An import with no module name searches every library, so it is not reported.
  • What changes: only the executable's entry stub. Guest module bytes stay identical for every executable, so the uniform deferral and --executable conversions are unchanged.
  • When it prints: every time such a module is imported, including when the title does load it later, as a Unity player loads mono-ps4.sprx. I left out the optional second line (the first imported call runs before the module has started), because it needs a check on every call through those imports.
  • Docs: the debt line from #8162 now says what is reported, instead of "nothing reports it".
  • Other targets: Linux and macOS output is unchanged. Since #6586 merged, the debt entry lists only macOS as starting such a module at startup; this PR reports only from the Windows entry stub.

Tested

Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, relinker-only build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON) on main cecb540a63, then again after merging main 6cd36e6517.

  • Full ctest: 233/233 pass on cecb540a63. After the merge, 240/241 pass with -j8; conventions_env_reference timed out at 60 s under load and passes alone in 32 s.
  • guest_module_dir (new case): an executable that calls shared from needed.prx.
    • needed.prx in Media/Modules, converted with --module-dir Media/Modules: the Windows executable contains the line, prints it on stdout and exits with 42.
    • needed.prx in sce_module, which starts at startup: the executable contains no such line and exits with 42.
    • Linux: the module is a startup DT_NEEDED entry in both directories.
  • Negative control: with main's WindowsEntryStubBuilder.cpp, the case fails (AssertionError: Media/Modules); with the change, it passes.
  • Not run on a title. On main alone, Boggle's conversion stops at libSceFios2.prx (the fix is in #6977).
  • tools/check_conventions.py --base origin/main passes.
  • tools/pr_overlap.py:
    • #6586 rewrote the same debt sentence and has merged; the merge keeps its wording and this PR's sentence. #3965 adds code at the same place in the entry stub, just before guestStartup.Initialize, which would only be a textual conflict.
    • #5021, #6977, #7918 and #8076 edit other entries of docs/dev/debt/relinker.md. #7450, which touched test_guest_module_dir.py, is closed.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4954265606 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9228). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-21T15:40:47Z. --- ### What This is the follow-up to #8162 that @oneandonlydean asked for in [this comment](https://github.com/boykopovar/AnyPS5/pull/8162#issuecomment-6311678668). Since #8162, a `--module-dir` module that the executable needs is deferred on Windows. The entry stub maps it at startup, and `DynamicLoader` runs its `module_start` and initializers only when the title loads it with `sceKernelLoadStartModule`. If the executable imports from such a module but the title never loads it, the module gets neither, and nothing reported that. Now the Windows entry stub prints one line at startup for each deferred guest module that an import of the executable names. The lines come after the imports are bound and before `Transferring control to ELF entry point`: ``` Deferred module app0/Media/Modules/needed.prx.guest.prx: the executable imports from it, but it starts only when the title loads it ``` - **Which modules:** a guest module with `DeferInitialization` that is in the search order of one of the executable's own imports, matched by file name or module identity. The stub uses the same match to bind the import. A guest module's own imports do not count. An import with no module name searches every library, so it is not reported. - **What changes:** only the executable's entry stub. Guest module bytes stay identical for every executable, so the uniform deferral and `--executable` conversions are unchanged. - **When it prints:** every time such a module is imported, including when the title does load it later, as a Unity player loads `mono-ps4.sprx`. I left out the optional second line (the first imported call runs before the module has started), because it needs a check on every call through those imports. - **Docs:** the debt line from #8162 now says what is reported, instead of "nothing reports it". - **Other targets:** Linux and macOS output is unchanged. Since #6586 merged, the debt entry lists only macOS as starting such a module at startup; this PR reports only from the Windows entry stub. ### Tested Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, relinker-only build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`) on `main` `cecb540a63`, then again after merging `main` `6cd36e6517`. - Full `ctest`: 233/233 pass on `cecb540a63`. After the merge, 240/241 pass with `-j8`; `conventions_env_reference` timed out at 60 s under load and passes alone in 32 s. - `guest_module_dir` (new case): an executable that calls `shared` from `needed.prx`. - `needed.prx` in `Media/Modules`, converted with `--module-dir Media/Modules`: the Windows executable contains the line, prints it on stdout and exits with 42. - `needed.prx` in `sce_module`, which starts at startup: the executable contains no such line and exits with 42. - Linux: the module is a startup `DT_NEEDED` entry in both directories. - Negative control: with `main`'s `WindowsEntryStubBuilder.cpp`, the case fails (`AssertionError: Media/Modules`); with the change, it passes. - Not run on a title. On `main` alone, Boggle's conversion stops at `libSceFios2.prx` (the fix is in #6977). - `tools/check_conventions.py --base origin/main` passes. - `tools/pr_overlap.py`: - #6586 rewrote the same debt sentence and has merged; the merge keeps its wording and this PR's sentence. #3965 adds code at the same place in the entry stub, just before `guestStartup.Initialize`, which would only be a textual conflict. - #5021, #6977, #7918 and #8076 edit other entries of `docs/dev/debt/relinker.md`. #7450, which touched `test_guest_module_dir.py`, is closed. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/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!9228
No description provided.