relinker: ps5-payload-dev SDK ELFs convert but do not load: .sprx DT_NEEDED names and plain-name imports are kept #9180

Closed
opened 2026-10-21 14:29:30 +00:00 by rocklouis055 · 4 comments
rocklouis055 commented 2026-10-21 14:29:30 +00:00 (Migrated from github.com)
Contributor

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_NEEDED entries name libSceX.sprx and its undefined symbols are plain names (memset, sceKernelSendNotificationRequest), not NIDs. The relinker keeps both as they are, while the built libraries are named libSceX.prx and export NIDs only (malloc is exported as gQX+4GDQjpM, with no malloc). The loader therefore fails on the first .sprx name 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, main 7280a17ec, libs and relinker targets.

The SDK's own samples/hello_world (SDK tag v0.44, built with make in samples/hello_world against the v0.44 release zip, clang-18 and lld-18). sha256 of hello_world.elf: 6fef85336910398c242baa1f0bae1bc2c318d4dc5da52817375d8a8defc75d5e.

$ nm -D --undefined-only hello_world.elf
                 U memset
                 U sceKernelSendNotificationRequest
                 U strncpy
$ readelf -d hello_world.elf | grep NEEDED
 (NEEDED) Shared library: [libkernel_web.sprx]
 (NEEDED) Shared library: [libSceLibcInternal.sprx]
 (NEEDED) Shared library: [libSceNet.sprx]
relinker --to-intel --skip-sce-module --trap-sdk-syscall-stubs --registry src/eboot.elf app.elf
cp -r build/core/libs/libs .
./app.elf

Observed: conversion completes, app.elf still imports memset, sceKernelSendNotificationRequest and strncpy by name, and:

./app.elf: error while loading shared libraries: libkernel_web.sprx: cannot open shared object file: No such file or directory

With libs/libX.sprx symlinked to libs/libX.prx for each DT_NEEDED entry:

./app.elf: symbol lookup error: ./app.elf: undefined symbol: sceKernelSendNotificationRequest

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, sha256 10ccd3ed1253cb92eb0fed3c93af3c474caef2a2e27267b7b6b7980d2fe9693f): 338 plain-name imports, and the load stops at undefined symbol: __stderrp, the first R_X86_64_GLOB_DAT import. import_audit.py matches those names and reports 320 implemented, which does not reflect that none of them resolves at load time.

Notes

  • The relinker writes each import's name into .dynsym unchanged (SysVDynamicSectionBuilder.cpp); nothing maps a plain name to its NID or a .sprx DT_NEEDED name to the built .prx.
  • Not verified: how the console's payload loaders resolve these names. Found with AI assistance; the commands and outputs above were run locally.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5962505435 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9180). Originally posted by [rocklouis055](https://github.com/rocklouis055) on 2026-10-21T14:29:30Z. --- ### Description An ELF built with the [ps5-payload-dev SDK](https://github.com/ps5-payload-dev/sdk) converts but does not load. Such an ELF is an ordinary dynamic ELF: `DT_NEEDED` entries name `libSceX.sprx` and its undefined symbols are plain names (`memset`, `sceKernelSendNotificationRequest`), not NIDs. The relinker keeps both as they are, while the built libraries are named `libSceX.prx` and export NIDs only (`malloc` is exported as `gQX+4GDQjpM`, with no `malloc`). The loader therefore fails on the first `.sprx` name 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, `main` `7280a17ec`, `libs` and `relinker` targets. The SDK's own `samples/hello_world` (SDK tag `v0.44`, built with `make` in `samples/hello_world` against the `v0.44` release zip, clang-18 and lld-18). sha256 of `hello_world.elf`: `6fef85336910398c242baa1f0bae1bc2c318d4dc5da52817375d8a8defc75d5e`. ```text $ nm -D --undefined-only hello_world.elf U memset U sceKernelSendNotificationRequest U strncpy $ readelf -d hello_world.elf | grep NEEDED (NEEDED) Shared library: [libkernel_web.sprx] (NEEDED) Shared library: [libSceLibcInternal.sprx] (NEEDED) Shared library: [libSceNet.sprx] ``` ```sh relinker --to-intel --skip-sce-module --trap-sdk-syscall-stubs --registry src/eboot.elf app.elf cp -r build/core/libs/libs . ./app.elf ``` Observed: conversion completes, `app.elf` still imports `memset`, `sceKernelSendNotificationRequest` and `strncpy` by name, and: ```text ./app.elf: error while loading shared libraries: libkernel_web.sprx: cannot open shared object file: No such file or directory ``` With `libs/libX.sprx` symlinked to `libs/libX.prx` for each `DT_NEEDED` entry: ```text ./app.elf: symbol lookup error: ./app.elf: undefined symbol: sceKernelSendNotificationRequest ``` The same happens with a larger payload, LÖVE from the [pacbrew-repo v0.41.1](https://github.com/ps5-payload-dev/pacbrew-repo/releases/tag/v0.41.1) `ps5-payload-dev.tar.gz` (`target/user/homebrew/bin/love`, sha256 `10ccd3ed1253cb92eb0fed3c93af3c474caef2a2e27267b7b6b7980d2fe9693f`): 338 plain-name imports, and the load stops at `undefined symbol: __stderrp`, the first `R_X86_64_GLOB_DAT` import. `import_audit.py` matches those names and reports 320 implemented, which does not reflect that none of them resolves at load time. ### Notes - The relinker writes each import's name into `.dynsym` unchanged ([SysVDynamicSectionBuilder.cpp](https://github.com/boykopovar/AnyPS5/blob/7280a17ec/core/relinker/relinker/src/output/SysVDynamicSectionBuilder.cpp)); nothing maps a plain name to its NID or a `.sprx` `DT_NEEDED` name to the built `.prx`. - Not verified: how the console's payload loaders resolve these names. Found with AI assistance; the commands and outputs above were run locally.
mossyanwar commented 2026-10-21 15:59:31 +00:00 (Migrated from github.com)
Author
Contributor

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 .prx libraries and imports NIDs, but I couldn't run a payload against a full libs build. If you still have the hello_world or LÖVE setup, could you try the branch?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6320403527 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9180#issuecomment-6320403527). Originally posted by [mossyanwar](https://github.com/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 `.prx` libraries and imports NIDs, but I couldn't run a payload against a full `libs` build. If you still have the hello_world or LÖVE setup, could you try the branch?
kanza-cm commented 2026-10-21 17:10:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by kanza-cm on 2026-10-21T17:10:38Z.


I traced both failures on main cecb540a6 with a Windows relinker-only build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, full ctest green).

The .sprx names survive conversion. The executable's DT_NEEDED names are collected verbatim into neededLibraries in RelinkerPipeline.cpp (the readCStr loop) and written back into the output's dynamic section. Domain::NeededLibraryName already maps .sprx/.suprx/.debug_prx to .prx, but only the Windows import builder uses it. libs/ ships *.prx, so libSceNet.sprx cannot 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 as Party.prx) and applied NeededLibraryName to the collected names. The new case passes, but guest_needed_modules, guest_module_identity and guest_needed_nested_modules fail: they require an unmatched DT_NEEDED to stay verbatim, so needed.debug_prx with no matching bundled module must stay needed.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?

  1. Rename only a known set of system library names. Where would that set live?
  2. Rename only when the .prx target exists next to the output or under the rpath, which makes conversion depend on the filesystem state.
  3. Leave the names alone and ship the Linux libraries under both names in the release (libSceX.sprx as a copy or symlink of libSceX.prx), so payloads load with no relinker change.
  4. Keep the current behaviour and document the alias as a user step.

The second failure is separate. For plain-name imports, should the .dynsym name be rewritten to Nid::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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321925168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9180#issuecomment-6321925168). Originally posted by [kanza-cm](https://github.com/kanza-cm) on 2026-10-21T17:10:38Z. --- I traced both failures on `main` `cecb540a6` with a Windows relinker-only build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`, full `ctest` green). **The `.sprx` names survive conversion.** The executable's `DT_NEEDED` names are collected verbatim into `neededLibraries` in `RelinkerPipeline.cpp` (the `readCStr` loop) and written back into the output's dynamic section. `Domain::NeededLibraryName` already maps `.sprx`/`.suprx`/`.debug_prx` to `.prx`, but only the Windows import builder uses it. `libs/` ships `*.prx`, so `libSceNet.sprx` cannot 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 as `Party.prx`) and applied `NeededLibraryName` to the collected names. The new case passes, but `guest_needed_modules`, `guest_module_identity` and `guest_needed_nested_modules` fail: they require an unmatched `DT_NEEDED` to stay verbatim, so `needed.debug_prx` with no matching bundled module must stay `needed.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? 1. Rename only a known set of system library names. Where would that set live? 2. Rename only when the `.prx` target exists next to the output or under the rpath, which makes conversion depend on the filesystem state. 3. Leave the names alone and ship the Linux libraries under both names in the release (`libSceX.sprx` as a copy or symlink of `libSceX.prx`), so payloads load with no relinker change. 4. Keep the current behaviour and document the alias as a user step. The second failure is separate. For plain-name imports, should the `.dynsym` name be rewritten to `Nid::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.
rocklouis055 commented 2026-10-21 17:27:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rocklouis055 on 2026-10-21T17:27:09Z.


Thanks both. I tried #9234 (28b31a306) with a full libs build of main 7280a17ec on 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_world and for LÖVE: every DT_NEEDED is a .prx name, every import is a NID, and both load without any alias in libs/.

Both then stop in the SDK's startup code, which is a separate gap: its _start expects the ELF loader to pass a payload_args_t* in rdi (crt/payload.h) and first calls its sys_dynlib_dlsym (crt/syscall.c). Run as a process, rdi is 1 and the call jumps to 0x1. I can open a separate issue for that if it is useful.

On @Canzi18's question about the .sprx rule: I have no view on which option fits the project; #9234 takes the Linux rename through Domain::NeededLibraryName and updates the three tests that pinned the old behaviour.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322261516 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9180#issuecomment-6322261516). Originally posted by [rocklouis055](https://github.com/rocklouis055) on 2026-10-21T17:27:09Z. --- Thanks both. I tried #9234 (`28b31a306`) with a full `libs` build of `main` `7280a17ec` on 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_world` and for LÖVE: every `DT_NEEDED` is a `.prx` name, every import is a NID, and both load without any alias in `libs/`. Both then stop in the SDK's startup code, which is a separate gap: its `_start` expects the ELF loader to pass a `payload_args_t*` in `rdi` ([crt/payload.h](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/payload.h)) and first calls its `sys_dynlib_dlsym` ([crt/syscall.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/syscall.c)). Run as a process, `rdi` is `1` and the call jumps to `0x1`. I can open a separate issue for that if it is useful. On @Canzi18's question about the `.sprx` rule: I have no view on which option fits the project; #9234 takes the Linux rename through `Domain::NeededLibraryName` and updates the three tests that pinned the old behaviour.
mossyanwar commented 2026-10-21 17:50:42 +00:00 (Migrated from github.com)
Author
Contributor

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_sym2addr in v0.44 runs nid_encode on the name and compares the result with the .sprx symbol table, also accepting an exact match on the first 11 characters of the name. rtld.c sends every .sprx dependency through that path. So rewriting the name to its NID at conversion matches the console. Leaving it to ld.so binds memset, malloc and the rest to glibc, which is also why shipping .sprx aliases (3) wouldn't be enough on its own.

On the file names: #6697 already maps .sprx, .suprx and .debug_prx to .prx on Windows through Domain::NeededLibraryName, and #9234 does the same on Linux. A library that's really missing still fails at startup, with the .prx name in the error. The three guest-module tests that expect the old name were written before #6697.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322731149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9180#issuecomment-6322731149). Originally posted by [mossyanwar](https://github.com/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_sym2addr`](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/rtld_sprx.c#L312-L331) in v0.44 runs `nid_encode` on the name and compares the result with the `.sprx` symbol table, also accepting an exact match on the first 11 characters of the name. [rtld.c](https://github.com/ps5-payload-dev/sdk/blob/v0.44/crt/rtld.c#L292-L297) sends every `.sprx` dependency through that path. So rewriting the name to its NID at conversion matches the console. Leaving it to `ld.so` binds `memset`, `malloc` and the rest to glibc, which is also why shipping `.sprx` aliases (3) wouldn't be enough on its own. On the file names: #6697 already maps `.sprx`, `.suprx` and `.debug_prx` to `.prx` on Windows through `Domain::NeededLibraryName`, and #9234 does the same on Linux. A library that's really missing still fails at startup, with the `.prx` name in the error. The three guest-module tests that expect the old name were written before #6697.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#9180
No description provided.