feat(libkernel): implement system #1859

Merged
overlordxrz-source merged 1 commit from upstream-pr/1859 into main 2026-10-09 21:55:09 +00:00
overlordxrz-source commented 2026-10-08 22:15:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-08T22:15:58Z.


What

libkernel does not export system (Jc6E7N+dHz0). Yamagi Quake II (PPSA99007) stops on it at load on main, and ccleste (PPSA59322) imports it too.

In both titles the only caller is the bundled Mesa. A small function runs system("clrxdisasm --version > /dev/null 2>&1") and returns whether the result is 0, which tells Mesa whether the CLRX disassembler is installed. It sits on the shader-disassembly dump path, at 0x4608d0 in the PPSA99007 executable and 0x826270 in PPSA59322 (the single call [system] site in each).

system now follows FreeBSD 11's lib/libc/stdlib/system.c (source) for a process with no /bin/sh:

  • A null command returns 1. That version returns 1 without checking for the shell (if (!command) return(1);).
  • Any other command runs nothing and returns 0x7f00. In FreeBSD, the child that cannot execl(_PATH_BSHELL, ...) calls _exit(127), and system returns its wait status. So WIFEXITED is true and WEXITSTATUS is 127, and Mesa's probe sees that CLRX is not available.
  • The guest errno is not touched.

No host command is ever run. A new line in docs/dev/TechnicalDebt.md says what is assumed: that the console's application sandbox has no shell, and that vfork succeeds there (FreeBSD returns -1 when it fails).

Log

I don't have a console, and I couldn't run the titles here: the host is aarch64 and the project needs x86-64. The stop is from @SleglJan's run of the homebrew catalog on main 4b6ab6bb in #1578 (comment). Each title was relinked with --registry and run for 8 s on Linux. In the table of first stops, system is the stop for PPSA99007 Yamagi Quake II, with no open PR. That run reports the stop as app.elf: symbol lookup error: app.elf: undefined symbol: Jc6E7N+dHz0. Closed #3 also reported a Quake II build stopping at Jc6E7N+dHz0 (system) before guest entry.

The call sites come from the unwrapped eboot.bin of each release: the relocation for Jc6E7N+dHz0, then the only call qword ptr [rip+…] through that slot.

With this PR applied, @CouchRiv ran PPSA99007 on Linux (NVIDIA, main f1451396 plus this PR, 90 s timeout) (comment). On main it stops at load with undefined symbol: Jc6E7N+dHz0, exit 127. With the PR, system resolves and the next stop is mkstemp (uEtgPWgPxOk, claimed by #1613):

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk

The LD_BIND_NOW trace goes from 21 to 20 unresolved imports, with nothing new.

Tested

aarch64 Debian 13 host. The full project cannot be built here because it needs x86-64.

  • New core/libs/tests/GuestSystemCommand.cpp (guest_system_command) checks:
    • a null command returns 1
    • Mesa's probe string, exit 0 and an empty command each return a status with WIFEXITED true and exit status 127
    • errno is unchanged
  • It passes natively on aarch64 (Zig 0.17 clang, glibc 2.36), and on x86_64-linux-musl under qemu-user. Both builds link the export's body with a guest errno stand-in.
  • Negative check: without the change the test does not link. A mutant that returns 0 for a command aborts, and so does one that returns 0 for a null command.
  • Process.cpp and the test compile for x86_64-linux-gnu and x86_64-windows-gnu with -Wall -Wextra. The only warnings are the existing -Wreturn-type-c-linkage ones from General.hpp and Shutdown.hpp.
  • python3 tools/check_conventions.py --base origin/main passes. tools/progress.py: libkernel goes from 426 to 427 implemented.
  • Title run by @CouchRiv: PPSA99007 on Linux/NVIDIA gets past system and stops next at mkstemp (#1613). See Log.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4793438317 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-08T22:15:58Z. --- ### What `libkernel` does not export `system` (`Jc6E7N+dHz0`). Yamagi Quake II (PPSA99007) stops on it at load on `main`, and ccleste (PPSA59322) imports it too. In both titles the only caller is the bundled Mesa. A small function runs `system("clrxdisasm --version > /dev/null 2>&1")` and returns whether the result is 0, which tells Mesa whether the CLRX disassembler is installed. It sits on the shader-disassembly dump path, at 0x4608d0 in the PPSA99007 executable and 0x826270 in PPSA59322 (the single `call [system]` site in each). `system` now follows FreeBSD 11's `lib/libc/stdlib/system.c` ([source](https://github.com/freebsd/freebsd-src/blob/stable/11/lib/libc/stdlib/system.c)) for a process with no `/bin/sh`: - A null command returns 1. That version returns 1 without checking for the shell (`if (!command) return(1);`). - Any other command runs nothing and returns `0x7f00`. In FreeBSD, the child that cannot `execl(_PATH_BSHELL, ...)` calls `_exit(127)`, and `system` returns its wait status. So `WIFEXITED` is true and `WEXITSTATUS` is 127, and Mesa's probe sees that CLRX is not available. - The guest `errno` is not touched. No host command is ever run. A new line in `docs/dev/TechnicalDebt.md` says what is assumed: that the console's application sandbox has no shell, and that `vfork` succeeds there (FreeBSD returns -1 when it fails). ### Log I don't have a console, and I couldn't run the titles here: the host is aarch64 and the project needs x86-64. The stop is from @SleglJan's run of the homebrew catalog on `main` 4b6ab6bb in #1578 ([comment](https://github.com/boykopovar/AnyPS5/issues/1578#issuecomment-6068281866)). Each title was relinked with `--registry` and run for 8 s on Linux. In the table of first stops, `system` is the stop for PPSA99007 Yamagi Quake II, with no open PR. That run reports the stop as `app.elf: symbol lookup error: app.elf: undefined symbol: Jc6E7N+dHz0`. Closed #3 also reported a Quake II build stopping at `Jc6E7N+dHz0` (`system`) before guest entry. - PPSA99007: [ps5-yamagi-quake2 v0.2.0-alpha.1](https://github.com/blackbearreloaded/ps5-yamagi-quake2/releases/tag/v0.2.0-alpha.1), `PPSA99007.zip`, sha256 `4fa5da07…9a70`, matching the [catalog record](https://github.com/blackbearreloaded/ps5-homebrew-catalog/blob/main/apps/PPSA99007.json) - PPSA59322: [PS5_Celeste 1.00](https://github.com/darkxex/PS5_Celeste/releases/tag/1.00), `PPSA59322.zip`, sha256 `96861b81…fb43`. It stops earlier, on `shm_open` (separate PR). The call sites come from the unwrapped `eboot.bin` of each release: the relocation for `Jc6E7N+dHz0`, then the only `call qword ptr [rip+…]` through that slot. With this PR applied, @CouchRiv ran PPSA99007 on Linux (NVIDIA, `main` f1451396 plus this PR, 90 s timeout) ([comment](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6074519487)). On `main` it stops at load with `undefined symbol: Jc6E7N+dHz0`, exit 127. With the PR, `system` resolves and the next stop is `mkstemp` (`uEtgPWgPxOk`, claimed by #1613): ``` /work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk ``` The `LD_BIND_NOW` trace goes from 21 to 20 unresolved imports, with nothing new. ### Tested aarch64 Debian 13 host. The full project cannot be built here because it needs x86-64. - New `core/libs/tests/GuestSystemCommand.cpp` (`guest_system_command`) checks: - a null command returns 1 - Mesa's probe string, `exit 0` and an empty command each return a status with `WIFEXITED` true and exit status 127 - `errno` is unchanged - It passes natively on aarch64 (Zig 0.17 clang, glibc 2.36), and on x86_64-linux-musl under qemu-user. Both builds link the export's body with a guest `errno` stand-in. - Negative check: without the change the test does not link. A mutant that returns 0 for a command aborts, and so does one that returns 0 for a null command. - `Process.cpp` and the test compile for x86_64-linux-gnu and x86_64-windows-gnu with `-Wall -Wextra`. The only warnings are the existing `-Wreturn-type-c-linkage` ones from `General.hpp` and `Shutdown.hpp`. - `python3 tools/check_conventions.py --base origin/main` passes. `tools/progress.py`: libkernel goes from 426 to 427 implemented. - Title run by @CouchRiv: PPSA99007 on Linux/NVIDIA gets past `system` and stops next at `mkstemp` (#1613). See Log. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-08 22:16:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T22:16:23Z.


Progress report (ae91d97 → 8f09ec3)

➖ System libraries: 84.76% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel system_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6070130354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6070130354). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T22:16:23Z. --- <!-- progress-report --> ### Progress report (ae91d97 → 8f09ec3) ➖ **System libraries**: 84.76% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `system_nid_postfix` | </details>
CouchRiv commented 2026-10-09 04:52:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T04:52:55Z.


Ran Yamagi Quake II 0.2.0-alpha.1 (PPSA99007, homebrew catalog release) on Linux with this PR merged onto main f1451396, in a sandbox, NVIDIA, 90 s timeout.

On main it stops at load, exit 127:

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: Jc6E7N+dHz0

With this PR system resolves and the next stop is mkstemp (claimed by #1613), exit 127:

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk

The LD_BIND_NOW load trace goes from 21 to 20 unresolved imports, with nothing new.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074519487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6074519487). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-09T04:52:55Z. --- Ran Yamagi Quake II 0.2.0-alpha.1 (PPSA99007, homebrew catalog release) on Linux with this PR merged onto `main` f1451396, in a sandbox, NVIDIA, 90 s timeout. On `main` it stops at load, exit 127: ``` /work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: Jc6E7N+dHz0 ``` With this PR `system` resolves and the next stop is `mkstemp` (claimed by #1613), exit 127: ``` /work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: uEtgPWgPxOk ``` The `LD_BIND_NOW` load trace goes from 21 to 20 unresolved imports, with nothing new.
overlordxrz-source commented 2026-10-09 05:23:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-09T05:23:07Z.


@CouchRiv thanks, that's the run this PR was missing. I've added it to Log and Tested. The next stop, mkstemp, belongs to #1613, so I'm leaving it out of this one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074856360 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6074856360). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-09T05:23:07Z. --- @CouchRiv thanks, that's the run this PR was missing. I've added it to Log and Tested. The next stop, `mkstemp`, belongs to #1613, so I'm leaving it out of this one.
popcoder565 commented 2026-10-09 10:03:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:03:57Z.


First Windows run, since the description says it wasn't tested on Windows.

Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto main b7218b3c together with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1685, #1676, #1675, #1641, #1656, #1807.

  • guest_system_command passes.
  • Full ctest: 510/510 (one GPU test skipped for a device limit).

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078728990 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6078728990). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T10:03:57Z. --- First Windows run, since the description says it wasn't tested on Windows. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto `main` b7218b3c together with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1685, #1676, #1675, #1641, #1656, #1807. - `guest_system_command` passes. - Full ctest: 510/510 (one GPU test skipped for a device limit). _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-09 21:55:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:55:06Z.


Checked the system semantics against FreeBSD 11 lib/libc/stdlib/system.c (null → 1, otherwise the wait status of a child that couldn't exec the shell, 127 << 8), the guest errno being left alone, the test registration in ctest and the TechnicalDebt entry. guest_system_command passes locally on Linux and fails to link without the change; Linux and Windows CI are green. Also confirmed by @CouchRiv (PPSA99007 on Linux/NVIDIA gets past system) and @popcoder565 (Windows, MinGW); merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089904602 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1859#issuecomment-6089904602). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:55:06Z. --- Checked the `system` semantics against FreeBSD 11 `lib/libc/stdlib/system.c` (null → 1, otherwise the wait status of a child that couldn't exec the shell, `127 << 8`), the guest errno being left alone, the test registration in ctest and the TechnicalDebt entry. `guest_system_command` passes locally on Linux and fails to link without the change; Linux and Windows CI are green. Also confirmed by @CouchRiv (PPSA99007 on Linux/NVIDIA gets past `system`) and @popcoder565 (Windows, MinGW); merging.
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!1859
No description provided.