feat(libkernel): start runtime-loaded modules with their arguments on Linux #2323
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2323"
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 hugodearaujo on 2026-10-09T15:30:18Z.
What
Depends on #846. This branch contains its two commits. Only the last commit,
feat(libkernel): start runtime-loaded modules with their arguments on Linux, belongs to this PR.#846 starts
--module-dirmodules fromsceKernelLoadStartModulewith the call'sargs/argpon Windows. On Linux, the host loader runs theirDT_INITatdlopenwith zeroed arguments, so #846 throws there when start arguments are given. This PR does on Linux what #846 does on Windows, with the same table:--module-dirgets noDT_INIT,DT_INIT_ARRAY,DT_FINIorDT_FINI_ARRAY. Like the Windows.ginitsection, it exports__aps5_guest_initialize: the initializer's address, the number ofINIT_ARRAYslots, and each slot's address. The symbol is added to the module's dynamic symbol table and hash. Modules fromsce_module/prxare written as before.dlopen,OpenModulelooks up__aps5_guest_initialize. It takes the module's load bias fromdl_iterate_phdrand calls the initializer once with(args, argp, nullptr). It stores the return value in*res, then runs theINIT_ARRAYslots. The table walk and the "only once per module" set are now shared with the Windows path, which keeps its behavior. TheNotImplementedfor start arguments on Linux is removed.Evidence: Hollow Knight: Silksong (PPSA12544) on Linux
Unity loads its plugins from
/app0/Media/PluginswithsceKernelLoadStartModule, andPSN.prxis started with start arguments. All runs below are relinked with--module-dir Media/Plugins, onmaind70b89989+ #1836 + #1431 (the title stops before the plugins without them) + #846:terminate ... what(): sceKernelLoadStartModule with start arguments not implemented.PSN.prxstarts. The next stop is in the title's bundledlibSceNpCppWebApi:CppWebApi::Common::initialize() failed. ret = 0x80553504, then an uncaughtUnity.PSN.PS5.PSNExceptionwith that code.Common::initializemaps flexible memory and passes it to the bundled libc'ssceLibcMspaceCreate, which refuses the address on Linux. That is the address-window problem of #861, not this change.Tested
ctest464/464 on this branch.guest_module_dirgains a Linux case. A--module-dirmodule withDT_INIT,DT_FINIand oneINIT_ARRAYslot is written without those tags. It exports__aps5_guest_initializeas a 12-byte object holding(0x1000, 1, 0x2380). The same module undersce_modulekeeps its tags and has no such symbol. The test fails on #846 without this commit.guest_dynamic_loadergains a Linux case with a host fixture module that exports the table.GuestLoadStartModule_nid_no_patchwith 16 bytes of arguments must call its start function once with thoseargs/argp, store its return value (7) in*res, and run theINIT_ARRAYslot once. Loading the module a second time must not run either again. The test aborts on #846 without this commit, on itsNotImplemented.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)@merwie: you mentioned you can't build the Linux path. If you'd rather carry this in #846, take the commit and I'll close this one.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T16:31:57Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/Module/src/Module.cppL157-158, L162-163core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppL57, L76-77core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppL57-58core/relinker/cli/src/CliArgs.cppL59, L68core/relinker/main.cppL94core/relinker/relinker/include/relinker/guest/GuestImage.hppL58core/relinker/relinker/src/guest/GuestModuleBuilder.cppL34, L273core/relinker/cli/src/CliArgs.cppL66-70core/relinker/cli/src/CliArgs.cppL59, L68core/relinker/main.cppL94core/relinker/relinker/include/relinker/guest/GuestImage.hppL58core/relinker/relinker/src/guest/GuestModuleBuilder.cppL34dlopen_nid_postfixcore/relinker/relinker/tests/test_guest_module_dir.pyImported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:53:13Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
b076f0f2:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).DynamicLoader.cppandGuestDynamicLoader.cpp.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T22:34:35Z.
Closing as a duplicate of #1102, which passes
args/argpto runtime-loaded modules on Linux on current main without needing #846. If PPSA12544 still stops at module start once #1102 and #846 are both in, please reopen with that log line.Pull request closed