Linux: titles that bundle libc.prx fail to load, and the host libc binds its own exports to the title's libc #476
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 ThisIsAkill on 2026-10-03T19:26:39Z.
Summary
When a title ships its own
sce_module/libc.prx, two things go wrong on Linux that do not happen on Windows:Load failure.
GuestModuleBuilderdrops host dependencies whose name matches a guest module (addHost), so the executable never lists the hostlibc.prx. Every host prx needslibc.prx, but theirDT_RUNPATHis empty (the CMake build path is blanked after NID patching) andDT_RUNPATHis not inherited, so the loader searches only system paths:error while loading shared libraries: libc.prx: cannot open shared object fileWindows already covers this:
WindowsImportBuilder::ReadLibrariesappendslibc.prxwhenlibSceLibcInternal.prxis imported without it (f146a3d0).Symbol interposition. With the host
libc.prxmade loadable (LD_LIBRARY_PATH), the title's libc and ours export the same NIDs. ELF resolves every reference through one global scope, and the guest libc comes first (guest modules are listed ahead of host prx, as intended for the title's own imports, see9cfdbff1). So the host libc's own references to its exports bind to the guest libc too.LD_DEBUG=bindingsshows 34 such references from the hostlibc.prx:_Stdin/_Stdout/_Stderr, typeinfo and vtables of the std exceptions,__gxx_personality_v0(NID),_sceLibcClassicLocale. Six other host prx bind their weak inlinestd::ctype<char>::do_widen/do_narrowinstantiations (exported under the PS5 NIDs) to the guest libc as well.On Windows this cannot happen: a DLL binds references to its own definitions internally, and only the title's imports go through the ordered
GetProcAddresssearch.Observed failure
PPSA21567 (Linux, GCC 16.2,
maind3ec1f15,LD_LIBRARY_PATHworkaround): SIGSEGV in the guest libc'smemcpy, called fromfputs/putsin the title's startup code. The title's_Stdoutholds whatFileStream _Stdout_nid_postfix{stdout}writes: flags 8 and descriptor 1 at offsets 16/18, null position and buffer, and glibc's_IO_2_1_stdout_at offset 256. The host libc's static initializer built its stream on top of the guestFILE.Experiment
Host
libc.prxlinked with-Wl,-Bsymbolic(only that target, via a deferredtarget_link_options; nothing else changed):-Bsymbolicdo_widen,do_narrow)__error,__stack_chk_*, twosceLibcInternal*ForGame; expected imports)Result:
putsbefore any output.-Bsymbolic: boots; the title logs, mounts save data and submits GPU work, then stops at the first unsupported shader feature (unsupported descriptor role Gds).Proposed direction
libSceLibcInternal.prxand no hostlibc.prxremains, appendlibc.prxas the lastDT_NEEDED. Lowest priority keeps the guest-first order for the title's imports.-Wl,-Bsymbolicso a library's references to its own exports resolve inside it, which matches PE semantics. Required for libc; applying it to all prx would also keep the weakstd::ctypecopies internal. Protected visibility would need annotating every export, and protected data symbols conflict with copy relocations, so-Bsymbolicfits the build better.DT_RUNPATH=$ORIGINon the built prx would also fix the load failure, independent of the executable's run path. But it changes nothing about (2), the patcher would have to write it in place of the blanked build path, and it diverges from Windows, where the library list is explicit. It could be a separate hardening change.Questions:
9cfdbff1) the intended order on Linux too?AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-03T20:00:17Z.
Correction to the proposed direction:
-Wl,-Bsymbolicon libc, as proposed above, breaks two existing tests onmaind3ec1f15(Linux, GCC 16.2). Both pass again with the normal libc (same test binaries, library swapped withLD_LIBRARY_PATH).guest_standard_streams: the host test executable hasR_X86_64_COPYrelocations for_Stdout,_Stderr,__stdoutp,__stderrp,__stdinp,__isthreaded. With-Bsymbolic, libc keeps using its own definitions while the test reads the copies.guest_memory: aborts withfixed mapping … overlaps a registered guest allocation …, thrown from libkernel's flexible-memory mapping path and expected to be caught by the test. The test executable links libstdc++ statically and exports its own__gxx_personality_v0. With-Bsymbolic, libc's frames use libc's personality routine and the other frames use the executable's, and the handler is no longer found. I have not traced why mixing the two loses the handler.Bisected by relinking libc with
--dynamic-list(everything else bound locally, as with-Bsymbolic):guest_memoryguest_standard_streams-Bsymbolic)__gxx_personality_v0__gxx_personality_v0+ those 6 symbols +_StdinThe last row only passes because
_Stdoutis preemptible again, and that is the binding that crashes the bundled-libc title.-Bsymbolic-functionsalone would not fix that crash either, since the crash comes from data (_Stdout), not functions.The relinked title has no copy relocations (
app.elfand both guest modules: 0R_X86_64_COPY), so the conflict shows up only in host-built executables such as the tests.Options for you to weigh (I am not picking one):
-fPIC, or-mno-direct-extern-accesson GCC 12+), keeping-Bsymbolic(or a--dynamic-list) on libc.-Bsymbolicto libc and fix the two tests to match: no copy relocations of libc data, and one personality routine.The relinker part of the proposal (append host
libc.prxas the lastDT_NEEDED) is unaffected.Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-03T22:48:29Z.
Follow-up on the
guest_memoryfailure with-Bsymbolic(my earlier comment left the mechanism open). #478 makes it clear: libc's unwinder dispatches on the frame's personality pointer (CallPersonalityinexception/Unwind.cpp) by comparing it with libc's own reference to__gxx_personality_v0.-Bsymbolic, that reference and the frames' CIE personality pointers all resolve, through global lookup, to the test executable's statically linked__gxx_personality_v0, so they match.-Bsymbolic, libc's reference binds to libc's own definition, while frames of the executable and libkernel still point at the executable's copy. The comparison fails, the frame is treated as a foreign personality, phase 1 fails, and the exception reachesterminate.#478 handles
__gcc_personality_v0only, so it does not change this. A libc that binds its own references locally would also have to recognise the C++ personality the host test executables link statically.Imported from boykopovar/AnyPS5. Originally posted by Amielle-Inside on 2026-10-04T08:52:11Z.
PPSA16951 (Tales of Xillia Remastered, Unity IL2CPP) is a second data point for the bundled-libc pattern, with some additional findings.
Dump: clean PS5 App Dumper v1.09 output;
eboot.binand all ofsce_module/plus the Unity modules (Il2cppUserAssemblies.prx89 MB,cri_ware_unity.prx,lib_burst_generated.prx,PSN.prx,SaveData.prx,toxr_dlc_plugin.prx) are SELF/FSELF containers (magic4F 15 3D 1D, second variant54 14 F5 EEseen on one module). Extracted ELFs by parsing the SELF header per PR #28's algorithm (ELF base at32 + n*32, all segments uncompressed).With
main(post-#358, so thelibcCyberUnknownstubs exist),LD_LIBRARY_PATHworkaround and the relinked executable loading, the failure is the same host-libc-binds-to-guest-libc family described here, and additionally:_ZNSt8__sce_v24coutE->__cxa_demangle->operator new) before abad_alloc(uncaught,_ZSt14_Throw_C_erroripath), i.e. the guest allocator returns null during stream init — no video/system module init happens before this point._Cnd_init/_Mtx_init/__cxa_atexitahead of the host libc changed nothing about the crash, and the missing-export set the title actually hits at runtime is small (a dozen C11/C++ABI imports plus twolibSceAudiodec/libSceMsgDialogNIDs).libcCyberUnknown10/12etc. turn out to be_Cnd_init/_Mtx_init).Something the experiment here may also want to account for: this title runs Unity IL2CPP, so the module count and
Il2cppUserAssemblies.prxsize stress the guest-module loader far more than PPSA21567 apparently does. Happy to provide the extracted import tables or the relinker diagnostics if useful.(This investigation was AI-assisted — GLM 5.3 via Hermes Agent — and the writeup was reviewed by me.)
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-04T17:41:59Z.
Two more titles that hit this on Linux, both bundling
sce_module/libc.prx:main2cf901bcit segfaults in the guest libc'smemcpyat startup, the same_Stdoutcrash.LD_DEBUG=bindingsshows the same 34 host-libc → guest-libc bindings. With only libc linked-Bsymbolic(nothing else changed) it boots through the logos and title into gameplay with no skipped draws, so this binding is the only blocker for it.-Bsymbolic-functionsalone does not help, confirming_Stdoutis the one that matters here.__gxx_personality_v0reference bound to the guest libc's personality while unwinding a host exception;-Bsymbolicgot it past that.I can reproduce the
guest_memory/guest_once/guest_standard_streamsfailures with-Bsymbolichere too, so I'm not proposing it as the fix; happy to test a proper one against both titles.Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-04T18:39:09Z.
One more test for the
-Bsymboliclist: on oneandonlydean'sastrobotbranch (159b633d),guest_system_fontfails the same way when libc is linked-Bsymbolic. A deliberately thrownstd::runtime_error(ANYPS5_SYSTEM_FONTS is not a directory) ends interminateinstead of reaching the test'scatch. In a default build of the same commit, it passes, as doguest_standard_streamsandguest_memory. So any proper fix here should keep exceptions thrown across the libc boundary catchable.Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-04T21:43:25Z.
Another data point for this issue: oneandonlydean's
astrobotbranch (159b633d, default build) does not start PPSA21567 either. It crashes in the bundledlibc.prxwithin 2 s, in two launches. With the-Bsymboliclibc it boots. Details: https://github.com/boykopovar/AnyPS5/discussions/357#discussioncomment-18749699Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T07:41:06Z.
One more data point. PPSA21564 (Astro Bot, the other region's release of PPSA21567) also ships
sce_module/libc.prx. My Linux runs of it have always had that file left out of the guest conversion, so the host libc serves every libc import, and the title runs through the intro, the Crash Site tutorial, the world map and the levels I've tried. That's why theastrobotbranch never hit the_Stdoutcrash. It isn't a fix (excluding modules is a deprecated debugging option, and a title that imports a libc NID the host libc lacks would fail at load), but it fits the picture here: for these titles the startup crash is the binding, not a missing libc feature.I've opened #618 for the load-failure half (part 1 above): on Linux, when the executable imports
libSceLibcInternal.prxand no hostlibc.prxremains as a dependency, the relinker appends the hostlibc.prxas the lastDT_NEEDED, mirroringWindowsImportBuilder. It keeps the guest-first order for the title's own imports and doesn't touch the interposition (part 2), which still needs its own fix.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:25:21Z.
Both halves of this are now on
main:ceeab79c). When the executable importslibSceLibcInternal.prxand no hostlibc.prxis left as a dependency, the relinker appends the hostlibc.prxas the lastDT_NEEDED.633459b0). It doesn't use-Bsymbolic. On Linux every guest-module export gets a#guestsuffix, and so does every import that a guest module satisfies. The title's own imports still bind to the bundled libc first, and host prx can only bind to host definitions.sceKernelDlsymalso tries the suffixed name. The-Bsymbolictest failures listed above (guest_memory,guest_standard_streams,guest_once,guest_system_font) don't apply, because the host prx are built as before.On #672's branch, @Pacuka reported Dreaming Sarah (PPSA02929) booting to the menu with sound instead of segfaulting, and @alfalfa-star reported LEGO Horizon Adventures (PPSA14632) getting past the
_Stdoutcrash.Could you confirm on
mainat633459b0or later, withoutLD_LIBRARY_PATH,--exclude-sce-module libc.prxor a-Bsymboliclibc?If the startup crash is gone for these titles, I'd suggest closing this and opening new issues for anything later in startup. One example is #693, where both libc instances run the heap handshake.
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-06T13:22:13Z.
Confirmed on PPSA21567 (Astro Bot), with the caveat about
libSceKeyboard.prxbelow.Setup:
mainat5895ea72(contains #618 and #672), default build (no-Bsymbolic), PPSA21567 relinked with that tree's relinker, noLD_LIBRARY_PATH, no--exclude-sce-module. Linux, RTX 3070 8 GB, virtual display. Separate build, relink and library folders.libc.prxload failure) and part 2 (interposition): fixed. Thelibc.prx: cannot open shared object fileerror is gone, and_Stdoutnever appears. Two of two runs, 0 occurrences of_Stdoutor of any loader orundefined symbolerror.mainalone, for another library:libSceKeyboard.prx.libSceVideoOut.prxneeds it, and the host prx still have an emptyDT_RUNPATH(readelf -dshowsLibrary runpath: []onlibSceVideoOut.prx,libSceKeyboard.prxandlibkernel.prx). WithoutLD_LIBRARY_PATHthe executable stops withlibSceKeyboard.prx: cannot open shared object file. It's the same cause as part 1 (the runpath isn't inherited), now hit through a host prx that isn't libc. #732 targets it: with #732 merged locally on top ofmain(1d52422d, local merge, nothing pushed), the host prx report$ORIGINand the loader finishes.main+ #732 the game then starts rendering and ends 6 to 11 s in withAGC graphics: unsupported descriptor role Gds, in 2 of 2 runs. That is the GDS support from #285, not this issue.Limits: the clean window is 6 to 11 s (until the
Gdserror), not a long boot. I haven't tested with #285 stacked.So, from my side, #476 as filed is resolved. The
LD_LIBRARY_PATHworkaround only goes away for this title once #732 (or an equivalent) is onmain.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-07T16:46:53Z.
Confirmation for PPSA21567 on
main1e5bb880(includes #618 and #672). Linux (CachyOS, kernel 7.2.8, GCC 16.2.1), RX 9070 XT (RADV).Relinked with the bundled
sce_module/libc.prxconverted as a guest module, default libc build, noLD_LIBRARY_PATH, no--exclude-sce-module, no-Bsymbolic. The title loads, has no_Stdoutcrash, reachesmain(), and runs to GPU submission. It stops later on an unrelated shader issue (unsupported descriptor role Gds, #285).AI-assisted: yes (Claude Code ran the build and wrote this report; the run is on my machine).
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-07T17:26:08Z.
With #732 merged, the last workaround is gone for this title too. On
main, #618 and #672 fix the libc load and the interposition, and #732 gives the host prx a$ORIGINrunpath, solibSceKeyboard.prxnow loads withoutLD_LIBRARY_PATH. @EdouardSence's run above confirms PPSA21567 onmain1e5bb880(RADV) with none of the workarounds. My own runs with #732 merged locally showed the same (NVIDIA). Closing. The later stops (Gds, then the #479 class) have their own PRs. Other startup problems belong in new issues, such as #693, where both libc instances run the application-heap handshake.