Skip to content

feat: convert a title's other executables and start them with sceSystemServiceLoadExec - #4786

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
p3n1cillin:claude/load-exec-restart
Oct 13, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
p3n1cillin:claude/load-exec-restart

Conversation

@p3n1cillin

@p3n1cillin p3n1cillin commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Closes #4793. sceSystemServiceLoadExec handled only "exit" and threw for every executable. Titles use it in two ways:

  • VLC for PS5 (PPSA85300) restarts its own /app0/eboot.bin with no arguments to see newly mounted drives.
  • RetroArch (PPSA99169, source at bead807) ships three executables. eboot.bin starts /app0/picker/picker.bin with {"", NULL} (read with gdb at the call). The picker then starts eboot.bin with {"--ps5-mode=retroarch", NULL} or /app0/es-de/es-de.bin with {"", 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 whole argv, with no program name: the port says so for the console (main_ps5.cpp#L11-L13), and ES-DE passes every non-empty entry from argv[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.bin becomes picker.picker.bin.exe. It does not go under app0/ because the Windows entry stub sets the working directory to the executable's own directory, and app0/ and libs/ are found from there. Placed beside the output, it shares libs/, app0/ and the guest modules with no loader changes on Windows or Linux.

  • The guest modules are converted for each executable and must come out byte-identical; otherwise the run fails. For RetroArch, libc.prx.guest.prx is identical for all three executables. A module can only differ through deferred initialization of a --module-dir module that one executable needs and another does not; on Windows that is an error rather than a second module tree.
  • main.cpp is 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-diagnostics reports only the main executable.

sceSystemServiceLoadExec:

  • "exit": unchanged.
  • /app0/eboot.bin: starts the main executable. That is the path in APS5_EBOOT, which the first LoadExec sets to its own executable, so the restart works from the picker too.
  • Any other /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 --executable to add. All of this is resolved before the guest shutdown, so a throw leaves the title running.
  • The argument list becomes the new process's whole argv. On Linux it goes straight into execv, whose argv the entry stub hands to the guest unchanged. On Windows CreateProcessW gets the executable as the application name and a command line that starts with the first argument, quoted for CommandLineToArgvW, which the entry stub uses to build the guest argv. CommandLineToArgvW reads argv[0] without escapes, so a first argument containing a double quote throws, and an empty list leaves the host path as argv[0] because a Windows command line cannot be empty.
  • After the guest shutdown, the old process ends through LibcTerminate_nid_no_patch without waiting. It no longer runs host destructors after starting the new process: on Windows the picker spent 60 s in std::exit waiting on a GPU pin lease before aborting, while the new process was already running. That now matches Linux, where execv never ran them.

Recorded in docs/dev/debt/libSceSystemService.md; the option is documented in docs/user/USAGE.md.

Tested

  • RetroArch PPSA99169 v1.0.0-beta.1 (catalog record, sha256 checked), converted with --executable picker/picker.bin --executable es-de/es-de.bin on Windows 11, MinGW GCC 15.2.0:
    • app.exe starts picker.picker.bin.exe, which renders its frontend menu for as long as it is left running (55 s, about 32 submissions/s, no stop).
    • With its own test mode (/app0/picker/picker-test.txt = 120 retroarch) the picker logs picker: retroarch -> LoadExec(/app0/eboot.bin, "--ps5-mode=retroarch"), app.exe starts again in RetroArch mode, and the picker exits at once. RetroArch then stops on select 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.
    • With 120 es-de the picker logs picker: es-de -> LoadExec(/app0/es-de/es-de.bin, "") and es-de.es-de.bin.exe starts. Its load needs tzname (feat(libc): export tzname #5009). With it, ES-DE's own log records start: 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 on last provoking vertex with explicit per-vertex triangle-strip interpolation. When the host path was still argv[0], ES-DE rejected it as Unknown option, which is how the argv layout above was confirmed.
  • guest_system_relaunch now drives the whole chain. The test executable copies itself as picker.picker.bin, its main role calls LoadExec("/app0/picker/picker.bin", {"--secondary", "two words", "quote\"d\\", ""}), and the copy is recognised by argv[0] == "--secondary", records the argv it received and calls LoadExec("/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 exact argv, 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 set APS5_EBOOT. With the previous Export.cpp the relaunch test fails.
  • New relinker_executables test (Linux and Windows output): outputs, layout listing, registry, a shared guest module in the secondary's DT_NEEDED, a module that converts differently (an error on Windows, a separate DT_NEEDED on Linux), and the rejected paths. On Windows both converted fixtures run and return 42. cli_args covers the parser.
  • Windows: all 117 relinker tests and all 11 libSceSystemService tests pass. Linux (Ubuntu in WSL, GCC 15.2.0): Export.cpp and GuestSystemExit.cpp built 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/main and tools/check_test_registration.py pass.

Checklist

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#4140 core/relinker/cli/src/CliArgs.cpp L11
core/relinker/main.cpp L143-168
#4547 core/relinker/cli/src/CliArgs.cpp L11
core/relinker/main.cpp L143-168
#4593 core/relinker/cli/src/CliArgs.cpp L11
core/relinker/main.cpp L143-168
#4802 core/relinker/main.cpp L40, L142-168
#4872 core/libs/prx/libSceSystemService/Export.cpp L41-43
#4916 core/relinker/main.cpp L134-135, L177-179
#4925 core/libs/prx/libSceSystemService/Export.cpp L38-39
core/libs/tests/GuestSystemExit.cpp L7, L65-69

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Windows test: head e61d9bed5 merged onto current main 510a2188c (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter guest_system_exit: guest_system_exit_parameters passed, guest_system_exit passed (2 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

p3nicillin and others added 2 commits October 13, 2026 08:25
…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>
@p3n1cillin p3n1cillin changed the title feat(libSceSystemService): relaunch the title for sceSystemServiceLoadExec of its own eboot.bin feat: convert a title's other executables and start them with sceSystemServiceLoadExec Oct 13, 2026
@p3n1cillin
p3n1cillin force-pushed the claude/load-exec-restart branch from e61d9be to 99efb32 Compare October 13, 2026 07:52
@github-actions

Copy link
Copy Markdown

Progress report (fc1f063 → 99efb32)

📈 System libraries: 87.86% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceSystemService sceSystemServiceLoadExec

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on the PR merged onto current main: build + scoped ctest (libs, libSceSystemService, relinker) 157/157 green, including guest_system_relaunch, guest_system_exit, guest_system_exit_parameters, cli_args and relinker_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 same Export.cpp lines and will need a small rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libSceSystemService: RetroArch (PPSA99169) stops on sceSystemServiceLoadExec("/app0/picker/picker.bin"), a second executable the title ships

3 participants