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

Merged
p3n1cillin merged 2 commits from upstream-pr/4786 into main 2026-10-13 08:02:51 +00:00
p3n1cillin commented 2026-10-12 21:52:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-12T21:52:26Z.


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 #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 (#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

  • Based on current 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)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: RetroArch (PPSA99169) frontend picker (#4793); VLC for PS5 (PPSA85300) restart
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835417366 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4786). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-12T21:52:26Z. --- ### What Closes #4793. `sceSystemServiceLoadExec` handled only `"exit"` and threw for every executable. Titles use it in two ways: - [VLC for PS5](https://github.com/ZiZc3/VLC/blob/86bb7d474a303f62bb3c2fc12f728db4846085b8/src/platform_ps5.c#L565-L571) (PPSA85300) restarts its own `/app0/eboot.bin` with no arguments to see newly mounted drives. - RetroArch (PPSA99169, [source at bead807](https://github.com/mihawk-99/PS5_RetroArch/tree/bead80725cc11e3c5c65bd9424b0a4494ae36d45)) 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](https://github.com/mihawk-99/PS5_RetroArch/blob/bead80725cc11e3c5c65bd9424b0a4494ae36d45/frontends/picker/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](https://github.com/mihawk-99/PS5_RetroArch/blob/bead80725cc11e3c5c65bd9424b0a4494ae36d45/frontends/es-de/ps5/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](https://github.com/boykopovar/AnyPS5/issues/4793#issuecomment-6140428068), 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 #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` (#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 - [x] Based on current `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) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: RetroArch (PPSA99169) frontend picker (#4793); VLC for PS5 (PPSA85300) restart - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 01:10:30 +00:00 (Migrated from github.com)

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.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135888310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4786#issuecomment-6135888310). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T01:10:30Z. --- <!-- pr-overlap --> 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](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/cli/src/CliArgs.cpp#L11)<br>`core/relinker/main.cpp` [L143-168](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L143-L168) | | | | #4547 | `core/relinker/cli/src/CliArgs.cpp` [L11](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/cli/src/CliArgs.cpp#L11)<br>`core/relinker/main.cpp` [L143-168](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L143-L168) | | | | #4593 | `core/relinker/cli/src/CliArgs.cpp` [L11](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/cli/src/CliArgs.cpp#L11)<br>`core/relinker/main.cpp` [L143-168](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L143-L168) | | | | #4802 | `core/relinker/main.cpp` [L40](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L40), [L142-168](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L142-L168) | | | | #4872 | `core/libs/prx/libSceSystemService/Export.cpp` [L41-43](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/libs/prx/libSceSystemService/Export.cpp#L41-L43) | | | | #4916 | `core/relinker/main.cpp` [L134-135](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L134-L135), [L177-179](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/relinker/main.cpp#L177-L179) | | | | #4925 | `core/libs/prx/libSceSystemService/Export.cpp` [L38-39](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/libs/prx/libSceSystemService/Export.cpp#L38-L39)<br>`core/libs/tests/GuestSystemExit.cpp` [L7](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/libs/tests/GuestSystemExit.cpp#L7), [L65-69](https://github.com/boykopovar/AnyPS5/blob/4834930ea63ce053c0a2d09d137160bdac576290/core/libs/tests/GuestSystemExit.cpp#L65-L69) | | |
xXPBSXx commented 2026-10-13 02:24:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T02:24:46Z.


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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6136837591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4786#issuecomment-6136837591). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T02:24:46Z. --- 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).
github-actions[bot] commented 2026-10-13 07:54:06 +00:00 (Migrated from github.com)

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
Library Name
libSceSystemService sceSystemServiceLoadExec
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140965982 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4786#issuecomment-6140965982). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T07:54:06Z. --- <!-- progress-report --> ### Progress report (fc1f063 → 99efb32) 📈 **System libraries**: 87.86% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceSystemService | `sceSystemServiceLoadExec` | </details>
adriadam10 commented 2026-10-13 08:02:46 +00:00 (Migrated from github.com)

Imported 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, 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141101343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4786#issuecomment-6141101343). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T08:02:46Z. --- 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 in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4786
No description provided.