fix(build): keep libc.prx needed by every executable that links a prx #3684
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3684"
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 zmeizy on 2026-10-11T15:19:50Z.
What
guest_kernel_stack_protectaborts on Linux (Ubuntu 24.04, GCC 13.3, the CI configuration) at its last check: anmprotectthat spans the page below a thread stack must return -1. The abort comes from_Unwind_Resumein libc.prx. Cause:--as-needed.GuestKernelStackProtect.cppcalls nothing in libc.prx directly, so the linker drops libc.prx from the test'sDT_NEEDED. It then satisfies libkernel.prx's references to__cxa_allocate_exception,__cxa_begin_catch,__cxa_init_primary_exceptionand__gxx_personality_v0from the static libstdc++ (-static-libstdc++). The link map showseh_throw.o,eh_alloc.o,eh_catch.oandeh_personality.oincluded "to satisfy reference by libkernel.prx".throwinside libc.prx and libkernel.prx then uses libstdc++'s__cxa_throwand libgcc's search phase._Unwind_Resume, which is libc.prx's guest unwinder, because the executable's static libgcc keeps its own hidden. The guest unwinder continues an exception that libgcc searched. libgcc identifies the handler frame by its stack pointer (uw_identify_context), the guest unwinder by its CFA, and the guest personality cannot match the types of a libstdc++ exception, so the cleanup phase fails and_Unwind_Resumeaborts.On current
main, 55 test executables that link a prx are missing libc.prx fromDT_NEEDED. 38 of them carry their own copy of the C++ exception runtime, so they test the libraries with a different runtime than titles get.guest_kernel_stack_protectis the one whose test currently fails because of it.The fix is two lines in
core/libs/CMakeLists.txt:libcadds--no-as-neededto its consumers' link options on Linux.guest_module_fixturealready links with--no-as-needed.libcPUBLICinstead ofPRIVATE, so a test that links only, say, libSceHttp also gets libc.prx on its link line.Only targets in
core/libslink prx libraries.Tested
Ubuntu 24.04, GCC 13.3, lavapipe, on
maina11c8f7f.guest_kernel_stack_protectaborts onmainand passes with the change. Relinking it by hand with-Wl,--no-as-neededon unchangedmainalso makes it pass.DT_NEEDED, and none defines__cxa_throwor__gxx_personality_v0itself. Before: 55 without libc.prx, 38 with their own runtime.ctest --timeout 120 --parallel 4: 832 tests. All pass except three that also fail onmainhere:guest_truncate(the container runs as root, which ignores the read-only bit) and two lavapipe image-sampling tests. No test over 30 s.PUBLIClinking only adds libc's import library to the link lines of prx consumers there.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:50:29Z.
Checked
core/libsbuild + ctest (19/19) on the PR merged onto main; every relinked test now lists libc.prx inDT_NEEDED, includingguest_kernel_stack_protect_tests. The--as-neededfailure itself is Ubuntu/GCC 13 specific and doesn't reproduce on our toolchain; relying on the described link-map evidence. Merging.