Repository navigation
feat: convert a title's other executables and start them with sceSystemServiceLoadExec - #4786
Conversation
|
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.
|
|
Windows test: head AI-assisted (Claude Code). |
…dExec of its own eboot.bin Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emServiceLoadExec The relinker's repeatable --executable converts another executable of the title beside the output, sharing its libs, app0 and guest modules. sceSystemServiceLoadExec maps /app0 paths to those executables, passes the argument list on the new command line and finds the main executable through APS5_EBOOT. RetroArch (PPSA99169) starts its frontend picker this way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e61d9be to
99efb32
Compare
|
Checked on the PR merged onto current |
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 feat(libkernel): select on pipes on Windows #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(feat(libc): export tzname #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 (test(libSceSystemService): retain rejected LoadExec paths in errors #4925 only adds the path to the error message; fix(libSceSystemService): run guest exit handlers first on LoadExec exit #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