Skip to content

fix(relinker): start on Windows without a missing library nothing imports from - #3129

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
CnRJay:fix/windows-start-without-unused-library
Oct 11, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
CnRJay:fix/windows-start-without-unused-library

Conversation

@CnRJay

@CnRJay CnRJay commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

What

The Windows start-up stub stops with error 126 at the first needed library it cannot load, even when the title imports nothing from it. Road of Death and Record of Lodoss War list libSceXml.prx; Resident Evil 4 lists Party.prx. A host library that no import is searched in is now skipped with a message when it is not found. A missing library something imports from, other load errors and guest modules still stop the start.

Imports whose module matches no needed library keep their declared module name, so they count only against the library they declare. A module declared as libGuest still keeps a missing libGuest.xyz required.

Closes #2591. Fixes the Party.prx stop in #2776 (the title then stops at setSpecialFloatFormatType, tracked there).

Carried from Silverash-i8's fork branch fix/windows-start-without-unused-library (two commits, original authorship kept); the unnamed-import rule is from xXPBSXx.

Tested

Windows 11, MinGW-w64 GCC, relinker-only build (ANYPS5_RELINKER_ONLY=ON): ctest 99/99, including windows_import_modules and guest_module_identity. tools/check_conventions.py --base upstream/main passes. Not run on a title by me; xXPBSXx reported on #2591 that Record of Lodoss War (PPSA05347) and Resident Evil 4 (PPSA07411) pass the missing-library stop with these commits (...\libs\libSceXml.prx -> not found; nothing is imported from it, continuing without it), and that PRAGMATA and Returnal are unchanged.

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; silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • 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

…orts from

The Windows startup stub stopped at the first DT_NEEDED library it could
not load, even when no import is searched in that library. Titles list
libraries they import nothing from (Road of Death needs libSceXml.prx,
Resident Evil 4 needs Party.prx), so they stopped with GetLastError 126
before running. A host library that no import's search list contains is
now skipped with a message when it is not found; its handle stays null
and is never read. Missing libraries that something imports from, other
load errors and guest modules still stop the start.
…clare

An import whose module matches no needed library has no library name,
and the Windows startup stub counted it against every library, so a
missing library with nothing imported from it was still never skipped.
Every such import in the executables of Record of Lodoss War, Resident
Evil 4, PRAGMATA and Returnal declares a module that exists under
another file name (libSceJson for libSceJson2.prx, for example), and
none declares libSceXml or Party.

The relinker now keeps the declared module names of those imports, for
the executable and each guest module, and the stub counts a host
library as imported from when its name up to the first dot matches one
of them, ignoring case. A module declared as libGuest still keeps a
missing libGuest.xyz required, as guest_module_identity checks.
Imports without a module ID declare nothing and count against no
library. The rule and the title data are from xXPBSXx.

@Dextroid17 Dextroid17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distinction this draws is the whole change, and it is drawn correctly: a library that nothing imports from is skipped with a message, while a missing library something does import from, any other load error, and guest modules all still stop the start. Widening the skip as far as the symptom would have turned a hard failure into a silent one, and the second half — imports whose module matches no needed library keeping their declared name, so each counts only against the library it declares — is what stops that from becoming a loophole.

The titles are named, which is the bar this tree asks for, and the two cases read differently for a reason: libSceXml.prx and Party.prx are carried dependencies the title never calls into, which is exactly the shape the fix is for.

One thing checked, because it is the failure mode of this change. The skipped-library line is emitted unconditionally — only the path echo beside it sits behind --windows-diagnostics — so a plain --windows run says which library was skipped and why. That is the right default: the alternative is a start that succeeds while a library quietly did not load, with nothing on screen to say so.

And closing the issue it fixes, with the Party.prx case named, is the right way to write the description — a reader can check both titles against their own copies.

Written with AI assistance.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Please leave the needed libraries nothing imports from out of the start-up load list, instead of continuing after LoadLibrary fails with 126 (unusedMissing in WindowsEntryStubBuilder.cpp). Carrying on after a failed load is a fallback, which isn't allowed here, and the relinker already knows which libraries those are.

… start-up load list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@CnRJay

CnRJay commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Done in the latest commit: the start-up stub no longer loads needed libraries that no import is searched in, so there is no LoadLibrary failure path or continue-after-126 branch left. The "Searched libraries" list also omits them. windows_import_modules now asserts the run exits 11 without mentioning the unused library; relinker ctest passes.

🤖 Addressed by Claude Code

@reyani-dev

Copy link
Copy Markdown
Contributor

Windows run of the current head (7755e1d0) merged onto main 961b25fe: Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, relinker-only build (ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON).

  • ctest: 100/100 pass, including windows_import_modules and guest_module_identity.
  • I relinked 48 open-source catalog homebrew executables with --windows --registry, once with this merge and once with a relinker built from main 961b25fe. Relink results are the same: 41 succeed and 7 stop with rc 2 on both. Once the output paths are normalized, the relinker logs are identical. This was a static check only; I did not run the outputs, so it doesn't exercise the start-up skip itself.

Two small things from reading the latest commit:

  1. WindowsEntryStubBuilder.cpp:153 still adds skippedModule (" -> not found; nothing is imported from it, continuing without it\n"), but after the review change nothing references it. The string is now written into every stub's data and never used.
  2. The description still says such a library "is now skipped with a message when it is not found" and quotes that message as xXPBSXx's result. After the latest commit, the library is never loaded at all, so the message no longer appears. The Lodoss / RE4 log lines in the Tested section are from the earlier commits.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

A library that an import is still searched in has to stay in the load list. At 7755e1d it doesn't when the import has no matching library: WindowsEntryStubBuilder.cpp:127 marks a library only when import.Library is set, and :143 only by the declared module's name, while the search order of such an import still holds every library.

An executable needing a.prx (host library in libs/, nothing in sce_module) that imports shared, or shared#A#B with module libSceJson, exits 11 on main 961b25f. With this head it stops:

FAIL: unresolved ELF import shared
Searched libraries:

Please fix that and add the case to windows_import_modules; the three new cases pass only because their provider is a guest module, which is always loaded. skippedModule (:153) is unused now.

@github-actions

github-actions Bot commented Oct 11, 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
#2705 core/relinker/domain/include/domain/GuestRuntime.hpp L26

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the diff, relinker build and ctest (94/94) on current main, and the Windows relinker job (windows_import_modules asserts exit 11 and no mention of the unused library). Libraries nothing imports from are now left out of the start-up load list, which covers Dean's request; missing libraries something imports from, other load errors and guest modules still stop the start. Merging.

@xXPBSXx

xXPBSXx commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

FYI for the authors of this change (@Silverash-i8, @CnRJay): the last commit here (7755e1d0, needed libraries nothing imports from are left out of the start-up load) breaks start-up on Hotline Miami (PPSA09682): an import without a library name (sceAppContentAddcontMount) can no longer be resolved because libSceAppContent.prx is no longer loaded. Bisect, evidence and a fix with a regression test are in #3367. The Party.prx case should stay working with that fix (missing library file tolerated, message restored).

AI-assisted (Claude Code).

@CnRJay

CnRJay commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

FYI for the authors of this change (@Silverash-i8, @CnRJay): the last commit here (7755e1d0, needed libraries nothing imports from are left out of the start-up load) breaks start-up on Hotline Miami (PPSA09682): an import without a library name (sceAppContentAddcontMount) can no longer be resolved because libSceAppContent.prx is no longer loaded. Bisect, evidence and a fix with a regression test are in #3367. The Party.prx case should stay working with that fix (missing library file tolerated, message restored).

AI-assisted (Claude Code).

Will investigate. Thanks

adriadam10 pushed a commit that referenced this pull request Oct 11, 2026
PPSA19546 (Cookie Clicker) and PPSA34959 (The King is Watching) list
libSceXml.prx among their needed libraries but import nothing from it.
AnyPS5 builds no such library, so on Linux the dynamic loader stops both
before they run:

  ./eboot.elf: error while loading shared libraries: libSceXml.prx:
  cannot open shared object file: No such file or directory

On Windows the start-up stub has skipped a missing library that nothing
imports from since #3129; the Linux loader resolves DT_NEEDED itself
and cannot skip one. libSceXml now exists with no exports, like
libSceAgcVsh and libSceAudio, so it loads on both. A title that imports
from it still stops at the missing import.

Both titles now load and stop at their next missing import:
setSpecialFloatFormatType (PPSA19546, #3575) and sceHttpsFreeCaList
(PPSA34959, #3497).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Road of Death (PPSA07286) fails on startup: missing libSceXml.prx

7 participants