feat(libSceSystemService): LoadExec on macOS hosts #6248
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6248"
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 mugurc on 2026-10-15T07:07:42Z.
What
sceSystemServiceLoadExecon macOS hosts. It found the running executable through/proc/self/exeand replaced the process withfexecveafterclose_range, none of which macOS has, so on macOS every call other than"exit"threw. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298)._NSGetExecutablePath, resolved withstd::filesystem::canonical, aslibSceNpEntitlementAccessandlibSceFontalready do on macOS. The rest ofPrepareLaunchis the Linux code.MH_MAGIC_64,CPU_TYPE_X86_64,MH_EXECUTE) that the user may run, as Linux requires an x86-64 ELF.fexecve, so the process is replaced by path withposix_spawnandPOSIX_SPAWN_SETEXEC.POSIX_SPAWN_CLOEXEC_DEFAULTcloses every descriptor except the standard streams, which is whatclose_rangedoes on Linux. The PID stays and the working directory becomes the executable's, as on Linux.LibcStartExit_nid_postfix, thenLibcRunShutdown_nid_postfix), as the Linux and WindowsReplacedo since #6237.execvpath, which macOS has and which already does this.guest_system_exitfinds its own executable the same way on macOS, andguest_system_load_exec_standard_errorfrom #5699 now runs on macOS too. Indocs/dev/debt/libSceSystemService.mdthesceSystemServiceLoadExecentry describes macOS instead of listing it as a host that throws, and the LoadExec descriptors entry says how macOS closes the descriptors.Tested
main385ed71f2with the other macOS branches of the series and the open macOS fixes #6928, #6667, #6668, #6969, #6853, #6836, #6620 and #7524 (the libraries do not link on macOS without the series):guest_system_exit_parameters,guest_system_relaunchandguest_nested_exit, which failed before, pass, and so doesguest_system_load_exec_standard_error; the four passed 10 runs in a row;guest_system_exit,guest_requested_exit,guest_quick_exit,guest_immediate_exit,guest_return_from_main,guest_exit_finalizers_before_shutdown,guest_system_serviceandguest_system_service_languagepass.guest_system_relaunchreplaces the process twice, into a copy namedpicker.picker.binand back to the main executable throughAPS5_EBOOT, and checks the arguments and shutdown handlers of each step.__APPLE__exceptOwnExecutable, which moves the Linux/proc/self/exelookup into a function without changing it.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T07:33:14Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceSystemService/CMakeLists.txtcore/libs/tests/GuestSystemExit.cppcore/libs/prx/libSceSystemService/Export.cppcore/libs/prx/libSceSystemService/Export.cppcore/libs/prx/libSceSystemService/LoadExec.cppcore/libs/tests/GuestSystemExit.cppImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T10:54:31Z.
A heads-up on ordering with #6237. It changes LoadExec's shutdown on Linux and Windows from
LibcRunShutdown_nid_postfix()to a newLibcStartExit_nid_postfix()(whatexitdoes), so a guest thread that calls into a stopped library during it waits for the process to be replaced instead of gettingProcessShutdownback in title code. On Linux, MGS4's launcher and VLC's self-restart abort onmainfrom that.The macOS
Replacehere also callsLibcRunShutdown_nid_postfix()just before the spawn. If #6237 lands first, that call would want to becomeLibcStartExit_nid_postfix()too. If this lands first, I'll change it when I rebase #6237. The two PRs also both edit thesceSystemServiceLoadExecline indocs/dev/debt/libSceSystemService.md.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by mugurc on 2026-10-15T11:42:49Z.
Agreed. If #6237 lands first, I will rebase this and the macOS
Replacewill callLibcStartExit_nid_postfix(). If this lands first, the change is yours in the rebase of #6237. The two edits of the debt line are in different sentences, so either order resolves it by keeping both.