Skip to content

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

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
savvaniss:feat/log-deferred-imported-modules
Oct 24, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
savvaniss:feat/log-deferred-imported-modules

Conversation

@savvaniss

@savvaniss savvaniss commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(relinker): start Windows runtime modules the executable needs when the title loads them #8162 now says what is reported, instead of "nothing reports it".
  • Other targets: Linux and macOS output is unchanged. Since fix(loader): defer Linux runtime module starts until requested #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.

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

Since boykopovar#8162 a --module-dir module that the executable needs is deferred
on Windows: the entry stub maps it and the title starts it with
sceKernelLoadStartModule. A module the executable imports from but the
title never loads gets no module_start and no initializers, silently.

The entry stub now prints one line at startup for each deferred guest
module that an import of the executable names. Guest module bytes are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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
PR 3965 core/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cpp L719

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/relinker.md
PR 7173 docs/dev/debt/relinker.md
PR 8076 docs/dev/debt/relinker.md

@BKlaasWerkman

Copy link
Copy Markdown
Contributor

Rechecked on current main: head 960863f merged into main 990f45e (clean merge). Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, relinker-only BUILD_TESTING=ON, Release: 235 of 235 pass, including guest_module_dir with the new case, and none changes result against a run of that main on the same machine.

#10157 also changes WindowsEntryStubBuilder.cpp, after SetStdHandle. The two PRs merge cleanly with each other on top of that main; I'll post a build and test of the combination once it has run.

AI-assisted: yes (Claude Code)

@BKlaasWerkman

Copy link
Copy Markdown
Contributor

The combination, as promised: main 990f45e + this PR (960863f) + #10157 (1e79db7), merged in that order with no conflict. Same machine and toolchain (Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, relinker-only BUILD_TESTING=ON, Release). It builds, and the full suite passes 235 of 235, with no result changed against that main. That includes guest_module_dir with this PR's new case and windows_import_modules with #10157's suspended-process preload case. The two entry-stub changes work together in either merge order as far as these tests reach.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
…orted-modules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean
oneandonlydean merged commit 5c90b0a into boykopovar:main Oct 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants