fix(relinker): resolve symbol-name imports through NIDs on Windows #6697
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6697"
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 karimibrahim07 on 2026-10-16T05:08:34Z.
What
Homebrew built with the ps5-payload-dev SDK for the websrv launcher imports functions by symbol name (
strlen,pthread_create,scePadOpen), and names its system librarieslibSceLibcInternal.sprx,libkernel_web.sprxand so on. On Windows nothing of that resolved:libs\libSceLibcInternal.sprx, whilelibs/holds.prxfiles.libs/export NIDs (strlenisj4ViWNHEgww), soGetProcAddressby name found nothing.libc.prx, where AnyPS5 implements the C runtime, was not searched either. The rule that adds it only matchedlibSceLibcInternal.prx.The Quake homebrew stopped before its entry point with 457
FAIL: unresolved ELF importlines (331 names). #6239 reports the same wall for Mari0 from the same launcher ("this fix enables diagnosis, not successful loading").On Windows:
GetProcAddressloop for those imports, after the existing one. A name that a library exports as written still binds there first, so native libraries with plain exports (unscoped-native-importinwindows_import_modules) behave as before. Qualified imports (name#L#M) and imports with a module are unchanged..sprx,.suprxor.debug_prxloads the.prxlibrary of the same stem (Domain::NeededLibraryName). An import's module name is compared the same way.libkernel_webalso loadslibkernel.prx, next to the existinglibSceLibcInternal→libc.prxrule. AnyPS5'slibkernel_web.prxexports two functions, and 121 of Quake's names (open,pthread_create,clock_gettime…) are inlibkernel.prx.core/libs/nid'sComputeNid, whichrelinker_corenow compiles. The relinker already compilesParamJsonParser.cppfrom../libs.Unresolved imports are still reported by name. Linux and macOS resolve these imports through the host loader and are unchanged. The new entry in
docs/dev/debt/relinker.mdrecords this.Tested
Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Ninja Release,
BUILD_TESTING=ON, onmain5d9dcc42d:New
windows_named_importstest. A relinked provider exports the NID ofsharedand is installed aslibs/available.prx. An executable that importssharedwithout a module:available.prxand through aDT_NEEDEDofavailable.sprxsharedas written, still takes that exportshared#A#B(qualified), still fails asunresolved ELF import shared from available.prxunresolved ELF import absentWith the source changes reverted it fails at the first case with
FAIL: unresolved ELF import shared.The relinker tests pass, 131 of 131, and the full suite passes, 1301 tests (one
conventions_function_bodiesshard timed out while the machine was busy and passed alone).python tools/check_conventions.py --base origin/mainpasses.Quake (homebrew
q1from gen04177/q1-ps5,q1.7zSHA-2569692254071d5a90b5f4d7fb316960ae1f4e586f944eb1d4641a79a914fd834fb, with the sharewarepak0.pakit ships).quake.elf(b2f667f8…8ca5c) and itslibOSMesa.so.8(255b57aa…08ba) are plain ELFs. They were relinked with--windows --to-intel --trap-sdk-syscall-stubs --registry, withlibOSMesa.so.8placed insce_module/:On
main: 457FAIL: unresolved ELF importlines, among themstrlen,malloc,pthread_createandscePadOpen. Only OSMesa's owngl*exports resolve.With this PR, 11 imports stay unresolved, all from
libOSMesa.so.8:ZSTD_trace_*, the SDK's__dlopen,__dlsym,__dladdr,__dlclose,__dlerror, andkernel_mprotectqsort_sA weak import of a bundled module still stops a Windows title, because
Domain::GuestImporthas no weak flag. That's a separate change, and so isqsort_s.Linux and macOS not tested; their code paths are unchanged.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T05:15:07Z.
The relinker CI has now completed successfully on Ubuntu (GCC), macOS (Clang) and Windows (GCC); conventions, eligibility and intake also pass. Platform build jobs were skipped for this PR.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T05:32:30Z.
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.
core/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtdocs/dev/debt/relinker.mdcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/elfpatcher/src/windows/WindowsEntryStubBuilder.cppImported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-16T11:11:24Z.
Cross-validation on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2, PR head
55408512con main5d9dcc42d(fast-forward, no conflicts). This is the Windows-only path, so the checks are on the relinker; I did not run Quake or Mari0 (not available here).windows_named_imports,--repeat until-fail:3: 3 of 3.ImportModule.hpp,WindowsEntryStubBuilder.cppandWindowsImportBuilder.cppfrom main (test and CMake kept) the test fails at the first case withFAIL: unresolved ELF import shared(exit0xC0000139,GetLastError: 127). With the changes it passes. Same result as your description.windows_import_modules,guest_module_dir,windows_dependency_diagnosticsincluded). Merging #6697 and #6702 has no conflict.tools/check_conventions.py --base origin/mainandgit diff --check: pass.eboot.elf, main's relinker against this PR's (same flags, no runs): the same outcome for every title (50 relink, PPSA99995 stops in both withFAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00)), no otherFAIL, noWARN, the registries are byte-identical.app.exechanges in 3 titles (PPSA28319 +3 072 bytes, PPSA99109 +2 048, PPSA99110 +1 024); the other 48 are byte-identical.unresolvedline; the logs differ only in addresses and paths.No local title has an import by plain name without a module, so none of them exercises the new NID search; I cannot confirm the Quake result (457 down to 11 unresolved imports).
Not checked: Quake, Mari0, Linux, macOS, a full-tree build (relinker targets only).
Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:50:51Z.
Checked the second
GetProcAddressloop (NID fallback runs only after the by-name search, only for unqualified imports without a module; everyresolvedbranch is patched), the.sprx/.suprx/.debug_prx→.prxmapping, thelibkernel_web→libkernel.prxrule, the debt entry andwindows_named_imports(covered by the relinker Windows job and screamm's negative control onmain). Merged.