feat(libSceLibcInternal): return from eleven runtime hooks as firmware 13.42 does #15588
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15588"
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 BunnyFl on 2026-11-03T20:44:36Z.
What
Eleven libSceLibcInternal runtime hooks threw. In firmware 13.42 each one returns at once, reading none of its arguments, and this change does the same:
_init_tls6NCOqr3cD74void (void), FreeBSD 11.4lib/libc/gen/tls.c:423_thread_initPJW+-O4pj6Ivoid (void), weak alias of_thread_init_stub(lib/libc/gen/_thread_init.c:34)_thread_init_stub1kIpmZX1jw8void (void),_thread_init.c:41_rtld_atfork_prei-7v8+UGglcvoid (int* locks),libexec/rtld-elf/rtld_lock.c:373_rtld_atfork_postR2QKo3hBLkwvoid (int* locks),rtld_lock.c:397_rtld_errordmHEVUqDYGwvoid (const char* format, ...),libexec/rtld-elf/rtld.c:876_rtld_get_stack_protAdYYKgtPlqgint (void),rtld.c:53077_rtld_addr_phdr5FoE+V3Aj0cint (const void*, struct dl_phdr_info*),rtld.c:36320_malloc_thread_cleanupSopthb9ztZIvoid (void),contrib/jemalloc/src/tsd.c:40_malloc_finalize_lv2RnqlvEmvkdw0in all ofrax_sceLibcGetMallocParam1nZ4Xfnyp380in all ofraxNames and NIDs match
tools/nid_names.py. The prototypes are the FreeBSD 11.4 definitions at the lines given (release/11.4.0)._malloc_finalize_lv2and_sceLibcGetMallocParamhave none. They returnstd::uint64_t0: the firmware'sxor %eax,%eaxat0xe7e0and0x12b10clears all ofrax, and a 64-bit 0 matches that for any integer or pointer return type. The debt entry says the type is unverified.core/libs/prx/libSceLibcInternal/InventoryExports.cpp(6) andInventoryExports6.cpp(5). The six keep their one declaration ininclude/InventoryExports.hpp, changed to match. The five get one each ininclude/Api.hpp.docs/dev/debt/libSceLibcInternal.md:InventoryExports6.cppare removed: their gaps are closed.InventoryExports.cppand the two unverified return types.Source
Firmware 13.42
system/common/lib/libSceLibcInternal.sprx(sha256a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285), read from disassembly, not run on a console. Each body, to its return:No argument is read and nothing is written; the
retonly returns to the caller. A null or invalid pointer is never dereferenced, here or in firmware.Tested
b85d7c5df4(which carriesmaincdf371df68) into the branch; the head is now699de01970. It conflicted in two places, both neighbours:mainregistered itsguest_libc_internal_memory_resourcetest incore/libs/prx/libSceLibcInternal/CMakeLists.txtwhere this branch registersguest_libc_internal_runtime_hooks(both are kept), andmainremoved the_ZNSt8ios_baseD1Evdebt entry next to this branch's removed_malloc_thread_cleanupentry (both stay removed). On top of #15584 the branch still changes the same 7 files with only its own eleven hooks, their test and their debt entries.699de01970, Windows 11 Pro 10.0.26300, WinLibs GCC, Release: 81 of 81 pass, none Not Run, with the test executables rebuilt: the 16guest_libc_internal_*andguest_errtests registered at this head,public_headersand the 64public_headers_compile_*batches.tools/check_conventions.py --base upstream/mainon the committed head699de01970: all checks pass.a5de116566(mainb96af01bebmerged in): 76 of 76 pass, none Not Run, with the 11 test executables built at this head. That is the 11guest_libc_internal_*andguest_errtests registered at this head (the newguest_libc_internal_runtime_hooksand #15584'sguest_libc_internal_empty_facet_membersincluded),public_headersand the 64public_headers_compile_*batches.core/libs/tests/GuestLibcInternalRuntimeHooks.cpp(registered afterguest_err_testsincore/libs/prx/libSceLibcInternal/CMakeLists.txt):dl_phdr_infostand-in passed to_rtld_addr_phdr, are unchanged.NotImplemented_nid_no_patch(__func__)back at the top of the six bodies inInventoryExports.cpp, which ismain's behaviour, and kept this branch's signatures and test. The new test then aborts withlibSceLibcInternalInventory_268_nid_no_patch not implemented(1 of 1 failed).tools/check_conventions.py --base upstream/mainon the committed heada5de116566: all checks pass.mainb96af01bebconflicted wheremainhad implemented__vfprintf(yAZ5vOpmBus) inFormat.cpp, next to this branch's_268and_269: itsInventoryExports.cppplaceholder, export line and declaration go.InventoryExports.cppnow has 287APS5_EXPORTlines, as onmain.tools/pr_overlap.py --branch feat/libcinternal-runtime-hook-returns --jobs 8at this head, against 1,867 open pull requests: 48 share files or exports with the branch, and the run failed closed. It lists 10 with line conflicts (#13881, #14664, #14796, #14836, #14903, #15582, #15852, #16004, #16009, #16356) and 6 more in its "Some comparisons could not be completed" table, which it does not compare line by line. I searched the added and removed lines of all 16 for the eleven helper and hook names and their NIDs: GitHub's diff for 15 of them, and for #5021, whose diff is too large for GitHub to serve, a local diff of its head against its merge base withmain(324 files). None of them names any of the eleven.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T20:57:39Z.
Review: APPROVED
Reviewed — approved
The 11 libSceLibcInternal runtime hooks now return as the firmware 13.42 disassembly in the description shows, instead of throwing. Because this PR is stacked on #15584, the same diff also brings in that PR's 52 empty facet members. Checks, build and focused tests pass, and both new tests fail when the throws are put back.
What I ran
Head
db4caa09b797b052b8a7371cd08aca73a05a5d8a,main086c0686c8adff3ee648fdbe34e0b0b647e1d511, merged with--no-ffinto tree19ef719b472de20ee17591c54606b5aa67224155. Debian 13 VM, GCC 14.2.0, Release, Ninja.I also mapped each changed NID to its name in the debt table, to check that every signature fits its mangled name.
D1,D2and_Tidytakevoid* self._Init(const _Locinfo&)takesselfandlocinfo. The hook names match the description's table.Results
git diff --checkcheck_conventions.pylibs(script)mainand are not related to this change.guest_net_ctlwas skipped for an unexpected reason, and that also happens onmain.guest_libc_internal_runtime_hooksguest_libc_internal_empty_facet_membersguest_errpublic_headersNegative control
I kept this branch's signatures and tests and put
NotImplemented_nid_no_patch(__func__);back at the top of every changed body:InventoryExports.cpp(39 facet members and 6 hooks);InventoryExports6.cpp(13 facet members and 5 hooks).Then I rebuilt both test executables. Both tests failed:
output
Then I restored both files from the merged tree and rebuilt. Both tests pass again, and
git status --porcelainis empty.Each test aborts at the first call that throws, so this control proves only one export per test. The other exports are covered because the test calls every one of them in sequence.
Findings
Blocking
None.
Non-blocking
docs/dev/debt/libSceLibcInternal.md:10-11both linkInventoryExports.cpp. They record that the behaviour comes from firmware 13.42 disassembly and was not run on a console. They cover 39 facet members and 6 hooks.InventoryExports6.cpp: 13 facet members (for exampletime_putD1/D2) and the 5 hooks_thread_init,_thread_init_stub,_malloc_thread_cleanup,_rtld_atfork_postand_rtld_addr_phdr.time_put, which the commit message names. The reason is that its members are only inInventoryExports6.cpp.InventoryExports6.cppmembers, or drop the caveat from both files.Not verified
libSceLibcInternal.sprx(singleret,mov $0x7,%eax,xor %eax,%eax). I also could not check the matching single-retclaim for the 52 facet and exception members. The firmware is the only source for these behaviours.APS5_VABIdefinition of_rtld_error, although the same pattern already exists inErr.cppand other libraries.main, including those commits.