fix(libkernel): resolve original .prx names to relinked .guest.prx in stat, open and reachability #4688
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4688"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by eliyarson on 2026-10-12T19:03:03Z.
What
Refs #4225.
Titles that ship a plugin check for it with
sceKernelStatbefore loading it. The relinker emits only<name>.prx.guest.prx, sosceKernelStat("/app0/Media/Plugins/PSNCore.prx")returned ENOENT, whiledlopenalready mapsXtoX.guest.prx. Blasphemous 2 (PPSA13579): the il2cpp find-plugin callback (eboot 0xa46860) stats the plugin and only on success takes the engine load path that passes the{0x10, 0x200, getInterface}block tosceKernelLoadStartModule. After the failed stat the title falls back to a baresceKernelLoadStartModule(path, 0, NULL), PSNCore'smodule_startrejects the missing block ("PSNCore is an old version") and dereferences NULL.This moves the
X -> X.guest.prxrule out ofdlopeninto one helper,RelinkedModulePath_nid_no_patch(libc, next toResolvePath_nid_no_patch). libkernel wraps it asFile::PathOrRelinkedModule, which keepsXwhen it exists (including a dangling symlink) and otherwise returnsX.guest.prxif that file exists.dlopen,sceKernelStat(andstat), read-onlysceKernelOpenandsceKernelCheckReachabilityuse it. Open with write orO_CREATis unchanged. No module arguments are replayed.Alternative to my draft #4296 (module-argument replay), which this makes unnecessary for PPSA13579; I will close #4296 once this is merged.
Not covered, behaviour unchanged:
lstat,access, directory listings.Tested
Linux x86-64 (Release), Blasphemous 2 PPSA13579 relinked with the stock relinker,
app0/Media/Pluginsholding only*.prx.guest.prx, no symlinks, #4296 not applied.TestRelinkedModuleNamesinGuestFilesystem.cppfails without the change (aborts at the first relinked stat,GuestFilesystem.cpp:188) and passes with it.ctest -j4 --timeout 120on the branch rebased onto1acfa7f78(the final rebase ontoa60f52e31only adds workflow and CONTRIBUTING changes): 971 tests, 0 failures, 10 skipped (no display);check_skips.py(10 skips, all expected),check_test_registration.py(730 executables, none new) andcheck_conventions.py --base origin/main --head HEADpass. Not run: Windows and macOS builds.Plugins/PSNCore.prxnow returns 0, the engine load site is reached, no "old version" message. Onmainplus this change alone the title then crashes with SIGSEGV (eboot 0x4430ae,core::string::reserve) while loading Addressables bundles, 2 of 2 runs: this is the guestsceKernelClose(0)/ host fd 0 reuse fixed by #3295 (and also hit with #4296 alone). With #3295 added locally, 2 runs of 240 s hold the title screen at ~59.9 FPS with no crash. Only the title screen was checked, no input sent.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T19:10:25Z.
Code review location:
core/libs/prx/libkernel/File/src/NativeStat.cpp; line 131std::filesystem::exists(file_status)is false whenfile_statusisnot_found, which is whatsymlink_statusreturns for a dangling symlink. That means a dangling original path is not preserved here as the PR description says; if a sibling<path>.guest.prxexists, stat/open/reachability will be redirected to it. Could this test thesymlink_statustype (or otherwise preserve every existing directory entry) and add a regression with a dangling original symlink plus a relinked sibling?Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T22:24:23Z.
Windows test of this PR.
Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON,-j2. Base:a60f52e31(main before thelibusb-cmakesubmodule), this PR's commitf80a2f553on top (fast-forward, no conflict).git merge-treeagainst the currentmainis also conflict-free.Result:
guest_filesystemandguest_posix_filesystempass (2 of 2), including the newTestRelinkedModuleNames(stat, reachability and open ofPlugin.prxresolve toPlugin.prx.guest.prx; a missing file and another name still return0x80020002).Not checked: whether the new test fails without the change to the library code (I ran only the PR as submitted); no title run. I did not build on the current
mainbecause it needs the newlibusb-cmakesubmodule, which is not available here; the result above is for the base named above.AI-assisted (Claude Code).