feat: convert a title's other executables and start them with sceSystemServiceLoadExec #4786
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4786"
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 p3n1cillin on 2026-10-12T21:52:26Z.
What
Closes #4793.
sceSystemServiceLoadExechandled only"exit"and threw for every executable. Titles use it in two ways:/app0/eboot.binwith no arguments to see newly mounted drives.eboot.binstarts/app0/picker/picker.binwith{"", NULL}(read with gdb at the call). The picker then startseboot.binwith{"--ps5-mode=retroarch", NULL}or/app0/es-de/es-de.binwith{"", NULL}(picker.cpp#L444-L446), and ES-DE goes back with{..., "--ps5-mode=quit", NULL}(frontends/es-de/ps5/main_ps5.cpp:180). The list becomes the new process's wholeargv, with no program name: the port says so for the console (main_ps5.cpp#L11-L13), and ES-DE passes every non-empty entry fromargv[0]on to its own options.This implements the plan from the issue comment, with the module question settled by measurement (below).
Relinker:
--executable <path>(repeatable, relative to the module parent like--module-dir) converts another executable of the title in the same run. It is written beside the output, named after its path with/replaced by.and given the output's extension:picker/picker.binbecomespicker.picker.bin.exe. It does not go underapp0/because the Windows entry stub sets the working directory to the executable's own directory, andapp0/andlibs/are found from there. Placed beside the output, it shareslibs/,app0/and the guest modules with no loader changes on Windows or Linux.libc.prx.guest.prxis identical for all three executables. A module can only differ through deferred initialization of a--module-dirmodule that one executable needs and another does not; on Windows that is an error rather than a second module tree.main.cppis split so each executable goes through the same relink, guest-module and patch steps. Every input/output collision check still runs before anything is patched or written.--windows-diagnosticsreports only the main executable.sceSystemServiceLoadExec:"exit": unchanged./app0/eboot.bin: starts the main executable. That is the path inAPS5_EBOOT, which the firstLoadExecsets to its own executable, so the restart works from the picker too./app0/...path: starts the converted executable beside the running one. A path outside/app0, a path with an empty,.or..component, or an executable that wasn't converted throws, and the message says which--executableto add. All of this is resolved before the guest shutdown, so a throw leaves the title running.argv. On Linux it goes straight intoexecv, whoseargvthe entry stub hands to the guest unchanged. On WindowsCreateProcessWgets the executable as the application name and a command line that starts with the first argument, quoted forCommandLineToArgvW, which the entry stub uses to build the guestargv.CommandLineToArgvWreadsargv[0]without escapes, so a first argument containing a double quote throws, and an empty list leaves the host path asargv[0]because a Windows command line cannot be empty.LibcTerminate_nid_no_patchwithout waiting. It no longer runs host destructors after starting the new process: on Windows the picker spent 60 s instd::exitwaiting on a GPU pin lease before aborting, while the new process was already running. That now matches Linux, whereexecvnever ran them.Recorded in
docs/dev/debt/libSceSystemService.md; the option is documented indocs/user/USAGE.md.Tested
--executable picker/picker.bin --executable es-de/es-de.binon Windows 11, MinGW GCC 15.2.0:app.exestartspicker.picker.bin.exe, which renders its frontend menu for as long as it is left running (55 s, about 32 submissions/s, no stop)./app0/picker/picker-test.txt=120 retroarch) the picker logspicker: retroarch -> LoadExec(/app0/eboot.bin, "--ps5-mode=retroarch"),app.exestarts again in RetroArch mode, and the picker exits at once. RetroArch then stops onselect on descriptor 4 (not a libSceNet socket), its web server's wake-up pipe; with #5013 it runs its XMB menu with the controller configured.120 es-dethe picker logspicker: es-de -> LoadExec(/app0/es-de/es-de.bin, "")andes-de.es-de.bin.exestarts. Its load needstzname(#5009). With it, ES-DE's own log recordsstart: arguments for ES-DE 1(its program name and--gamelist-only), and ES-DE creates its device and swapchain before stopping in the AGC translator onlast provoking vertex with explicit per-vertex triangle-strip interpolation. When the host path was stillargv[0], ES-DE rejected it asUnknown option, which is how theargvlayout above was confirmed.guest_system_relaunchnow drives the whole chain. The test executable copies itself aspicker.picker.bin, its main role callsLoadExec("/app0/picker/picker.bin", {"--secondary", "two words", "quote\"d\\", ""}), and the copy is recognised byargv[0] == "--secondary", records theargvit received and callsLoadExec("/app0/eboot.bin", {"--relaunched"}), which the relaunched process must see as its only argument. The relaunched process must be the original executable (APS5_EBOOT). The marker must read the main shutdown, the exactargv, the secondary shutdown and the relaunch, in that order. The parameter test rejects a path outside/app0,.., an empty component and an unconverted executable, and checks that none of them setAPS5_EBOOT. With the previousExport.cppthe relaunch test fails.relinker_executablestest (Linux and Windows output): outputs, layout listing, registry, a shared guest module in the secondary'sDT_NEEDED, a module that converts differently (an error on Windows, a separateDT_NEEDEDon Linux), and the rejected paths. On Windows both converted fixtures run and return 42.cli_argscovers the parser.Export.cppandGuestSystemExit.cppbuilt with small stubs for the libc shutdown hooks; the parameter and relaunch tests pass. The full Linux build was not run locally.python tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.Checklist
main; no other open PR implements the same functions (#4925 only adds the path to the error message; #4872 changes the"exit"path, which this leaves alone)NotImplemented_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 github-actions[bot] on 2026-10-13T01:10:30Z.
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/relinker/cli/src/CliArgs.cppL11core/relinker/main.cppL143-168core/relinker/cli/src/CliArgs.cppL11core/relinker/main.cppL143-168core/relinker/cli/src/CliArgs.cppL11core/relinker/main.cppL143-168core/relinker/main.cppL40, L142-168core/libs/prx/libSceSystemService/Export.cppL41-43core/relinker/main.cppL134-135, L177-179core/libs/prx/libSceSystemService/Export.cppL38-39core/libs/tests/GuestSystemExit.cppL7, L65-69Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T02:24:46Z.
Windows test: head
e61d9bed5merged onto currentmain510a2188c(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_system_exit: guest_system_exit_parameters passed, guest_system_exit passed (2 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T07:54:06Z.
Progress report (
fc1f063→99efb32)📈 System libraries: 87.86% (+0.03%, +1 implemented functions)
✅ 1 implemented
sceSystemServiceLoadExecImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T08:02:46Z.
Checked on the PR merged onto current
main: build + scoped ctest (libs, libSceSystemService, relinker) 157/157 green, includingguest_system_relaunch,guest_system_exit,guest_system_exit_parameters,cli_argsandrelinker_executables; without the code changes the new tests do not build. Debt line, USAGE.md and template are in order. Windows behaviour with a real title rests on the author's run and @xXPBSXx's Windows test. Merging once CI is green; #4872 and #4925 touch the sameExport.cpplines and will need a small rebase.