relinker: ps5-payload-dev SDK ELFs convert but do not load: .sprx DT_NEEDED names and plain-name imports are kept #9180
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 rocklouis055 on 2026-10-21T14:29:30Z.
Description
An ELF built with the ps5-payload-dev SDK converts but does not load. Such an ELF is an ordinary dynamic ELF:
DT_NEEDEDentries namelibSceX.sprxand its undefined symbols are plain names (memset,sceKernelSendNotificationRequest), not NIDs. The relinker keeps both as they are, while the built libraries are namedlibSceX.prxand export NIDs only (mallocis exported asgQX+4GDQjpM, with nomalloc). The loader therefore fails on the first.sprxname and, once that is mapped, on the first plain-name symbol.This is not about a retail title. #8624 covers payloads that do not convert; this covers payloads that convert and then fail to load.
Reproduction
Linux x86-64 (Ubuntu 26.04, GCC 15), Release,
main7280a17ec,libsandrelinkertargets.The SDK's own
samples/hello_world(SDK tagv0.44, built withmakeinsamples/hello_worldagainst thev0.44release zip, clang-18 and lld-18). sha256 ofhello_world.elf:6fef85336910398c242baa1f0bae1bc2c318d4dc5da52817375d8a8defc75d5e.Observed: conversion completes,
app.elfstill importsmemset,sceKernelSendNotificationRequestandstrncpyby name, and:With
libs/libX.sprxsymlinked tolibs/libX.prxfor eachDT_NEEDEDentry:The same happens with a larger payload, LÖVE from the pacbrew-repo v0.41.1
ps5-payload-dev.tar.gz(target/user/homebrew/bin/love, sha25610ccd3ed1253cb92eb0fed3c93af3c474caef2a2e27267b7b6b7980d2fe9693f): 338 plain-name imports, and the load stops atundefined symbol: __stderrp, the firstR_X86_64_GLOB_DATimport.import_audit.pymatches those names and reports 320 implemented, which does not reflect that none of them resolves at load time.Notes
.dynsymunchanged (SysVDynamicSectionBuilder.cpp); nothing maps a plain name to its NID or a.sprxDT_NEEDEDname to the built.prx.Imported from boykopovar/AnyPS5. Originally posted by mossyanwar on 2026-10-21T15:59:31Z.
Opened #9234 for this. I could only check it with the relinker-only build: the output now needs the
.prxlibraries and imports NIDs, but I couldn't run a payload against a fulllibsbuild. If you still have the hello_world or LÖVE setup, could you try the branch?Imported from boykopovar/AnyPS5. Originally posted by kanza-cm on 2026-10-21T17:10:38Z.
I traced both failures on
maincecb540a6with a Windows relinker-only build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, fullctestgreen).The
.sprxnames survive conversion. The executable'sDT_NEEDEDnames are collected verbatim intoneededLibrariesinRelinkerPipeline.cpp(thereadCStrloop) and written back into the output's dynamic section.Domain::NeededLibraryNamealready maps.sprx/.suprx/.debug_prxto.prx, but only the Windows import builder uses it.libs/ships*.prx, solibSceNet.sprxcannot resolve.I tried the unconditional rename, and it is not the project's model. I added a regression case to
test_needed_libraries.py(Party.prx,Party.sprx,Party.suprx,Party.debug_prx, each expected asParty.prx) and appliedNeededLibraryNameto the collected names. The new case passes, butguest_needed_modules,guest_module_identityandguest_needed_nested_modulesfail: they require an unmatchedDT_NEEDEDto stay verbatim, soneeded.debug_prxwith no matching bundled module must stayneeded.debug_prx. A silent rename also cuts against "missing imports fail at startup with a clear error". I reverted it.So the mapping has to be conditional, and the relinker has no list of the system libraries:
libs/is external to the conversion. Which rule do you want?.prxtarget exists next to the output or under the rpath, which makes conversion depend on the filesystem state.libSceX.sprxas a copy or symlink oflibSceX.prx), so payloads load with no relinker change.The second failure is separate. For plain-name imports, should the
.dynsymname be rewritten toNid::ComputeNid(name, "")at conversion time, the way the Windows entry stub searches by that NID at load time, or should the host loader resolve it? I have not checked how the console's payload loader resolves these names.If the answer is 3 or 4, the work is in the release packaging and the docs rather than the relinker, and I can send that instead.
Imported from boykopovar/AnyPS5. Originally posted by rocklouis055 on 2026-10-21T17:27:09Z.
Thanks both. I tried #9234 (
28b31a306) with a fulllibsbuild ofmain7280a17econ Linux; details in https://github.com/boykopovar/AnyPS5/pull/9234#issuecomment-6322186964.With that branch, both failures in this issue are gone for the SDK
hello_worldand for LÖVE: everyDT_NEEDEDis a.prxname, every import is a NID, and both load without any alias inlibs/.Both then stop in the SDK's startup code, which is a separate gap: its
_startexpects the ELF loader to pass apayload_args_t*inrdi(crt/payload.h) and first calls itssys_dynlib_dlsym(crt/syscall.c). Run as a process,rdiis1and the call jumps to0x1. I can open a separate issue for that if it is useful.On @Canzi18's question about the
.sprxrule: I have no view on which option fits the project; #9234 takes the Linux rename throughDomain::NeededLibraryNameand updates the three tests that pinned the old behaviour.Imported from boykopovar/AnyPS5. Originally posted by mossyanwar on 2026-10-21T17:50:42Z.
@Canzi18 two open PRs cover this: #9234 and #9261.
On how the console resolves the names: the SDK's startup linker looks each one up by its NID.
sprx_sym2addrin v0.44 runsnid_encodeon the name and compares the result with the.sprxsymbol table, also accepting an exact match on the first 11 characters of the name. rtld.c sends every.sprxdependency through that path. So rewriting the name to its NID at conversion matches the console. Leaving it told.sobindsmemset,mallocand the rest to glibc, which is also why shipping.sprxaliases (3) wouldn't be enough on its own.On the file names: #6697 already maps
.sprx,.suprxand.debug_prxto.prxon Windows throughDomain::NeededLibraryName, and #9234 does the same on Linux. A library that's really missing still fails at startup, with the.prxname in the error. The three guest-module tests that expect the old name were written before #6697.