Guest module conversion collapses 1872 SDK libc exports (snprintf, atexit, abs, ...) into one shared return-0 stub, so homebrew titles silently no-op #2652

Closed
opened 2026-10-10 10:01:36 +00:00 by StarMrGamer · 4 comments
StarMrGamer commented 2026-10-10 10:01:36 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by StarMrGamer on 2026-10-10T10:01:36Z.


What

When the relinker converts a ps5-payload-dev SDK libc.prx module from a catalog homebrew title, most of its exports end up bound to a single stub that just returns 0. Calls like snprintf succeed silently but do nothing. The title then runs on uninitialized memory instead of failing loudly.

This is the root cause of the garbage open() calls in the DOOM Native Port run reported in #2010, and it likely affects every catalog homebrew title, since they all ship this module.

The evidence chain (DOOM Native Port 1.1.1, PPSA99666, Linux)

  1. The title's launcher probes candidate IWAD paths and calls open() 55 times with a garbage path (raw stack bytes) and a garbage mode. Logging the return addresses in sceKernelOpen pins the calls to one probe loop in the game binary (file offset 0x3866a).
  2. That loop builds each path with snprintf(buf, 0x200, "%s/%s", ...) through a runtime-bound function-pointer slot. The buffer is never written, so %s/%s output cannot appear — the calls print raw stack contents.
  3. At runtime that slot (and two neighbouring slots for other libc calls) points at offset 0x50 in the converted app0/sce_module/libc.prx.guest.prx. The code there is seven bytes: pxor xmm0,xmm0; xor eax,eax; ret — return 0, write nothing.
  4. In the original SDK module's symbol table, 1872 of 2669 exports carry the same placeholder value 0x50 (the bytes at 0x50 in the original file are zeros). They include snprintf (eLdDw6l0-bU), atexit (8G2LB+A3rzg), abs (Ye20uNnlglA), __cxa_finalize and _malloc_init. Names resolved with tools/nid_names.py.
  5. The conversion materializes one shared return 0 stub for all of them. Everything else in the module converts normally (2566 exports parse, dependencies resolve, the title starts and reaches file I/O).

Why it matters

  • Every catalog homebrew title ships this SDK libc.prx, so all of them inherit silent no-op libc calls. This is probably why only one title in #2010 "ran" — and even it was broken.
  • Per the project rules, a function should do exactly what it is supposed to or throw. A snprintf that returns 0 without writing is the kind of silent failure that sends investigations (like this one) down long wrong paths.

Notes for whoever picks this up

  • The symbol-table bytes are exactly what the PS5 loader sees (I verified the fSELF unwrap preserves every load-segment byte of the module; only PT_NOTE and the SCE version tag are absent from the container, and their ranges are not in any load segment). So the question is what the 0x50 placeholder means in SCE modules on hardware and how conversion should treat it: resolve the export against the system library's implementation of the same NID, generate a per-NID throwing stub, or something else. That choice is above my pay grade here.
  • A plain-ELF module with real symbol values converts and runs correctly (the project's own provider.prx tests call into a converted module and get real results), so the trigger is the placeholder-value export style, not the container format.

Tested

Linux, main 256b8ed4 plus #2206. Chain verified end to end with logging in sceKernelOpen, a runtime memory dump of the function-pointer slots, and a parse of the module's symbol table. Could not verify: real-hardware meaning of the 0x50 placeholder, Windows.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5790194030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2652). Originally posted by [StarMrGamer](https://github.com/StarMrGamer) on 2026-10-10T10:01:36Z. --- ### What When the relinker converts a ps5-payload-dev SDK `libc.prx` module from a catalog homebrew title, most of its exports end up bound to a single stub that just returns 0. Calls like `snprintf` succeed silently but do nothing. The title then runs on uninitialized memory instead of failing loudly. This is the root cause of the garbage `open()` calls in the DOOM Native Port run reported in #2010, and it likely affects every catalog homebrew title, since they all ship this module. ### The evidence chain (DOOM Native Port 1.1.1, PPSA99666, Linux) 1. The title's launcher probes candidate IWAD paths and calls `open()` 55 times with a garbage path (raw stack bytes) and a garbage `mode`. Logging the return addresses in `sceKernelOpen` pins the calls to one probe loop in the game binary (file offset 0x3866a). 2. That loop builds each path with `snprintf(buf, 0x200, "%s/%s", ...)` through a runtime-bound function-pointer slot. The buffer is never written, so `%s/%s` output cannot appear — the calls print raw stack contents. 3. At runtime that slot (and two neighbouring slots for other libc calls) points at offset 0x50 in the converted `app0/sce_module/libc.prx.guest.prx`. The code there is seven bytes: `pxor xmm0,xmm0; xor eax,eax; ret` — return 0, write nothing. 4. In the original SDK module's symbol table, 1872 of 2669 exports carry the same placeholder value `0x50` (the bytes at 0x50 in the original file are zeros). They include `snprintf` (`eLdDw6l0-bU`), `atexit` (`8G2LB+A3rzg`), `abs` (`Ye20uNnlglA`), `__cxa_finalize` and `_malloc_init`. Names resolved with `tools/nid_names.py`. 5. The conversion materializes one shared `return 0` stub for all of them. Everything else in the module converts normally (2566 exports parse, dependencies resolve, the title starts and reaches file I/O). ### Why it matters - Every catalog homebrew title ships this SDK `libc.prx`, so all of them inherit silent no-op libc calls. This is probably why only one title in #2010 "ran" — and even it was broken. - Per the project rules, a function should do exactly what it is supposed to or throw. A `snprintf` that returns 0 without writing is the kind of silent failure that sends investigations (like this one) down long wrong paths. ### Notes for whoever picks this up - The symbol-table bytes are exactly what the PS5 loader sees (I verified the fSELF unwrap preserves every load-segment byte of the module; only PT_NOTE and the SCE version tag are absent from the container, and their ranges are not in any load segment). So the question is what the `0x50` placeholder means in SCE modules on hardware and how conversion should treat it: resolve the export against the system library's implementation of the same NID, generate a per-NID throwing stub, or something else. That choice is above my pay grade here. - A plain-ELF module with real symbol values converts and runs correctly (the project's own `provider.prx` tests call into a converted module and get real results), so the trigger is the placeholder-value export style, not the container format. ### Tested Linux, main 256b8ed4 plus #2206. Chain verified end to end with logging in `sceKernelOpen`, a runtime memory dump of the function-pointer slots, and a parse of the module's symbol table. Could not verify: real-hardware meaning of the `0x50` placeholder, Windows. Written with AI assistance.
ArjenS-LA commented 2026-10-10 10:36:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-10T10:36:10Z.


This looks closely related to #1497 and its fix in #1529. That investigation found that DOOM declares these imports from libSceLibcInternal, but Linux binds them to the bundled libc shim because the NIDs match. #1529 changes binding to respect the declared module; the thread includes an A/B run where the same title starts finding its WAD.

Could you repeat the failing case with #1529 applied and check the import’s declared module and resolved provider? That would distinguish the known binding bug from a separate conversion bug. A shared export address alone doesn’t establish that the relinker generated the placeholder code.

Made with AI Assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096623153 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2652#issuecomment-6096623153). Originally posted by [ArjenS-LA](https://github.com/ArjenS-LA) on 2026-10-10T10:36:10Z. --- This looks closely related to \#1497 and its fix in \#1529. That investigation found that DOOM declares these imports from `libSceLibcInternal`, but Linux binds them to the bundled libc shim because the NIDs match. \#1529 changes binding to respect the declared module; the thread includes an A/B run where the same title starts finding its WAD. Could you repeat the failing case with \#1529 applied and check the import’s declared module and resolved provider? That would distinguish the known binding bug from a separate conversion bug. A shared export address alone doesn’t establish that the relinker generated the placeholder code. Made with AI Assistance.
DavidSamir commented 2026-10-10 11:31:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-10T11:31:30Z.


The A/B asked for above, on macOS, where --macos takes the same non-Windows binding path as Linux.

DOOM PPSA99666 v1.1.1, same libraries, only the relinker differing:

  • without #1529: 70 of 171 executable imports are bound to the bundled libc.prx (#guest). Two empty notifications, /app0/test.cfg opened with a garbage mode, doom1.wad never opened, exit after 7 s.
  • with #1529's GuestModuleBuilder.cpp change: 0 of 171. Debug text is printed, doom1.wad opens and the demo loop runs.

For Linux output the same count goes from 70 of 170 to 0 (converted on macOS, not run).

So for this title the placeholder exports are reached through the binding in #1497, not through the conversion of the module itself. This does not answer what the 0x50 placeholder exports should become for an import that does declare the bundled module.

Run details: https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6096952968. #1529 rebased onto main b5f5362d with a macOS test: DavidSamir:fix/relinker-declared-host-imports.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097046523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2652#issuecomment-6097046523). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-10T11:31:30Z. --- The A/B asked for above, on macOS, where `--macos` takes the same non-Windows binding path as Linux. DOOM PPSA99666 v1.1.1, same libraries, only the relinker differing: - without #1529: 70 of 171 executable imports are bound to the bundled `libc.prx` (`#guest`). Two empty notifications, `/app0/test.cfg` opened with a garbage mode, `doom1.wad` never opened, exit after 7 s. - with #1529's `GuestModuleBuilder.cpp` change: 0 of 171. Debug text is printed, `doom1.wad` opens and the demo loop runs. For Linux output the same count goes from 70 of 170 to 0 (converted on macOS, not run). So for this title the placeholder exports are reached through the binding in #1497, not through the conversion of the module itself. This does not answer what the `0x50` placeholder exports should become for an import that does declare the bundled module. Run details: https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6096952968. #1529 rebased onto `main` b5f5362d with a macOS test: [`DavidSamir:fix/relinker-declared-host-imports`](https://github.com/DavidSamir/AnyPS5/tree/fix/relinker-declared-host-imports). AI-assisted: yes
ArjenS-LA commented 2026-10-10 11:42:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-10T11:42:17Z.


@DavidSamir Thanks, this answers the binding A/B I requested. Your macOS runtime result and the Linux-output import counts support #1497 as the cause for this DOOM case. I checked #1529 at abb5c46d: its declaresHost guard applies on the non-Windows path, and the added fixtures check that an import declaring libSceLibcInternal stays host-bound even when a bundled module exports the same symbol.

The remaining placeholder question needs a separate reproducer: an import that actually declares the bundled module, with its NID, declared module, resolved provider, and observed call behavior. That would let this issue track the residual case without treating the DOOM binding failure as evidence of faulty module conversion. The Linux conversion counts are useful, but a Linux runtime result remains unverified.

AI-assisted review of the linked code and your reported results; I have not independently reproduced the macOS or Linux runs.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097129102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2652#issuecomment-6097129102). Originally posted by [ArjenS-LA](https://github.com/ArjenS-LA) on 2026-10-10T11:42:17Z. --- @DavidSamir Thanks, this answers the binding A/B I requested. Your macOS runtime result and the Linux-output import counts support #1497 as the cause for this DOOM case. I checked #1529 at `abb5c46d`: its `declaresHost` guard applies on the non-Windows path, and the added fixtures check that an import declaring `libSceLibcInternal` stays host-bound even when a bundled module exports the same symbol. The remaining placeholder question needs a separate reproducer: an import that actually declares the bundled module, with its NID, declared module, resolved provider, and observed call behavior. That would let this issue track the residual case without treating the DOOM binding failure as evidence of faulty module conversion. The Linux conversion counts are useful, but a Linux runtime result remains unverified. AI-assisted review of the linked code and your reported results; I have not independently reproduced the macOS or Linux runs.
oneandonlydean commented 2026-10-11 05:06:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:06:11Z.


Closing: the DOOM case here was the binding from #1497, fixed by #1529 (DavidSamir's A/B above: 70 of 171 imports bound to the bundled libc before, 0 after, and doom1.wad opens). Please reopen with an import that declares the bundled module and still lands on the 0x50 stub on current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105685730 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2652#issuecomment-6105685730). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T05:06:11Z. --- Closing: the DOOM case here was the binding from #1497, fixed by #1529 (DavidSamir's A/B above: 70 of 171 imports bound to the bundled libc before, 0 after, and `doom1.wad` opens). Please reopen with an import that declares the bundled module and still lands on the `0x50` stub on current main.
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#2652
No description provided.