feat(libkernel): load system libraries from their console paths #6519

Merged
Get-fix merged 2 commits from upstream-pr/6519 into main 2026-10-21 10:07:22 +00:00
Get-fix commented 2026-10-15 18:36:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T18:36:40Z.


What

PS4 programs load system libraries with sceKernelLoadStartModule and their console path. The OpenOrbis piglet sample loads /<sandbox word>/common/lib/libScePigletv2VSH.sprx and libScePrecompiledShaders.sprx, the sandboxed form of /system/common/lib/ that sceKernelGetFsSandboxRandomWord names. AnyPS5 opened that path as a guest file, so the load failed with ENOENT and the sample stopped with:

Module prefix = /gkbHtXc3Wq/common/lib/
Failed to load the Piglet module, err=0x80020002
Module load failed.

A path in /system/common/lib/ or in the sandboxed /<word>/common/lib/ whose file name ends in .sprx now loads the host libs/<name>.prx, as libSceSysmodule does for module IDs. A name with a directory part is not mapped, so such a path cannot leave libs/. Any other path is opened as before. The new line in docs/dev/debt/libkernel.md records that a host library has no module_start, so res is 0, and that other system directories, such as /system/priv/lib, are not mapped. Part of the PS4 homebrew work tracked in #3093.

Overlap with open pull requests that change Module.cpp or docs/dev/debt/libkernel.md, checked with git merge-file against main 03c4cb5e7:

  • #4972 adds #include <mutex> on the line where this adds #include <optional>; whichever merges second keeps both includes.
  • #5993 (mine) also appends an entry at the end of docs/dev/debt/libkernel.md; whichever merges second keeps both entries.
  • #6149 merges cleanly with this.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on main 03c4cb5e7:

  • guest_dynamic_loader now copies its fixture module into libs/ and loads it through /system/common/lib/<name>.sprx and /gkbHtXc3Wq/common/lib/<name>.sprx (gkbHtXc3Wq is AnyPS5's sandbox word). It calls the module's export and unloads it each time. A missing name and a .prx name return 0x80020002, and so does /gkbHtXc3Wq/common/lib/../<name>.sprx, even though the file exists one directory up.
  • Each of these makes the test fail: the mapped path not passed to the loader, the sandboxed prefix not mapped, the /system/common/lib/ prefix not mapped, a name with a directory part mapped.
  • The OpenOrbis piglet sample on main 03c4cb5e7 with this, #6520, #6521, #5990 to #5994, #6376, #5138 and a change that answers the Linux TIOCGWINSZ with ENOTTY, as #5569 did: it prints Module prefix = /gkbHtXc3Wq/common/lib/ and Modules loaded OK., and draws its rotating textured square at 59.96 FPS. With Module.cpp from main instead, it stops with the lines above.
  • Full ctest of that build: 1304 of 1306 pass; agc_driver_gpu_indirect_arguments_misaligned_writer_ahead does not compile with MinGW on main (#6452 fixes it), and prx_thread_local_destructors fails as it did on main 92cdc7b62 on this machine without my changes.
  • tools/check_conventions.py passes.

Not tested on Linux or macOS.

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 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 for the code; the piglet sample also needs #6520 and #6521
  • Unblocks: OpenOrbis PS4 toolchain sample piglet, #3093
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4878092638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6519). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-15T18:36:40Z. --- ### What PS4 programs load system libraries with `sceKernelLoadStartModule` and their console path. The OpenOrbis piglet sample loads `/<sandbox word>/common/lib/libScePigletv2VSH.sprx` and `libScePrecompiledShaders.sprx`, the sandboxed form of `/system/common/lib/` that `sceKernelGetFsSandboxRandomWord` names. AnyPS5 opened that path as a guest file, so the load failed with `ENOENT` and the sample stopped with: ``` Module prefix = /gkbHtXc3Wq/common/lib/ Failed to load the Piglet module, err=0x80020002 Module load failed. ``` A path in `/system/common/lib/` or in the sandboxed `/<word>/common/lib/` whose file name ends in `.sprx` now loads the host `libs/<name>.prx`, as libSceSysmodule does for module IDs. A name with a directory part is not mapped, so such a path cannot leave `libs/`. Any other path is opened as before. The new line in `docs/dev/debt/libkernel.md` records that a host library has no `module_start`, so `res` is 0, and that other system directories, such as `/system/priv/lib`, are not mapped. Part of the PS4 homebrew work tracked in #3093. Overlap with open pull requests that change `Module.cpp` or `docs/dev/debt/libkernel.md`, checked with `git merge-file` against `main` `03c4cb5e7`: - #4972 adds `#include <mutex>` on the line where this adds `#include <optional>`; whichever merges second keeps both includes. - #5993 (mine) also appends an entry at the end of `docs/dev/debt/libkernel.md`; whichever merges second keeps both entries. - #6149 merges cleanly with this. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on `main` `03c4cb5e7`: - `guest_dynamic_loader` now copies its fixture module into `libs/` and loads it through `/system/common/lib/<name>.sprx` and `/gkbHtXc3Wq/common/lib/<name>.sprx` (`gkbHtXc3Wq` is AnyPS5's sandbox word). It calls the module's export and unloads it each time. A missing name and a `.prx` name return `0x80020002`, and so does `/gkbHtXc3Wq/common/lib/../<name>.sprx`, even though the file exists one directory up. - Each of these makes the test fail: the mapped path not passed to the loader, the sandboxed prefix not mapped, the `/system/common/lib/` prefix not mapped, a name with a directory part mapped. - The OpenOrbis piglet sample on `main` `03c4cb5e7` with this, #6520, #6521, #5990 to #5994, #6376, #5138 and a change that answers the Linux `TIOCGWINSZ` with `ENOTTY`, as #5569 did: it prints `Module prefix = /gkbHtXc3Wq/common/lib/` and `Modules loaded OK.`, and draws its rotating textured square at 59.96 FPS. With `Module.cpp` from `main` instead, it stops with the lines above. - Full ctest of that build: 1304 of 1306 pass; `agc_driver_gpu_indirect_arguments_misaligned_writer_ahead` does not compile with MinGW on `main` (#6452 fixes it), and `prx_thread_local_destructors` fails as it did on `main` `92cdc7b62` on this machine without my changes. - `tools/check_conventions.py` passes. Not tested on Linux or macOS. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 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 for the code; the piglet sample also needs #6520 and #6521 - [x] Unblocks: OpenOrbis PS4 toolchain sample piglet, #3093 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-15 19:30:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T19:30:57Z.


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
PR 7447 docs/dev/debt/libkernel.md L235

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/Module/src/Module.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestDynamicLoader.cpp
PR 6149 core/libs/prx/libkernel/Module/src/Module.cpp
docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6544 core/libs/tests/GuestDynamicLoader.cpp
PR 6740 docs/dev/debt/libkernel.md
PR 6879 core/libs/prx/libkernel/Module/src/Module.cpp
docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/Module/src/Module.cpp
PR 7509 docs/dev/debt/libkernel.md
PR 7532 docs/dev/debt/libkernel.md
PR 8520 docs/dev/debt/libkernel.md
PR 8523 docs/dev/debt/libkernel.md
PR 8553 docs/dev/debt/libkernel.md
PR 8658 docs/dev/debt/libkernel.md
PR 8726 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6200572236 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6519#issuecomment-6200572236). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T19:30:57Z. --- <!-- 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 | |---|---|---|---| | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `docs/dev/debt/libkernel.md` [L235](https://github.com/boykopovar/AnyPS5/blob/b6fe513b9abbfe78d6a9fed442113538fa75939c/docs/dev/debt/libkernel.md#L235) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/Module/src/Module.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestDynamicLoader.cpp` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `core/libs/prx/libkernel/Module/src/Module.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libkernel.md` | | [PR 6544](https://www.github.com/boykopovar/AnyPS5/pull/6544) | `core/libs/tests/GuestDynamicLoader.cpp` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/Module/src/Module.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/Module/src/Module.cpp` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7532](https://www.github.com/boykopovar/AnyPS5/pull/7532) | `docs/dev/debt/libkernel.md` | | [PR 8520](https://www.github.com/boykopovar/AnyPS5/pull/8520) | `docs/dev/debt/libkernel.md` | | [PR 8523](https://www.github.com/boykopovar/AnyPS5/pull/8523) | `docs/dev/debt/libkernel.md` | | [PR 8553](https://www.github.com/boykopovar/AnyPS5/pull/8553) | `docs/dev/debt/libkernel.md` | | [PR 8658](https://www.github.com/boykopovar/AnyPS5/pull/8658) | `docs/dev/debt/libkernel.md` | | [PR 8726](https://www.github.com/boykopovar/AnyPS5/pull/8726) | `docs/dev/debt/libkernel.md` |
jotitadev commented 2026-10-15 20:04:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T20:04:11Z.

Review: COMMENTED


Linux run (Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests), head 57dbfcadd merged onto main 44df21632.

  • Builds; guest_dynamic_loader and guest_dynamic_loader_fixed_base pass.
  • With Module.cpp from main and the PR's test, both abort at GuestDynamicLoader.cpp:106 (the /gkbHtXc3Wq/common/lib/<name>.sprx load), so the test protects the change on Linux too.

Non-GPU suite (ctest -E "^agc"): same result as main; only file_writer_binary and file_writer_text fail, and they fail on main too on this machine (Ubuntu 26.04 coreutils).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5539186157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6519#pullrequestreview-5539186157). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T20:04:11Z. **Review:** COMMENTED --- Linux run (Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests), head `57dbfcadd` merged onto `main` `44df21632`. - Builds; `guest_dynamic_loader` and `guest_dynamic_loader_fixed_base` pass. - With `Module.cpp` from `main` and the PR's test, both abort at `GuestDynamicLoader.cpp:106` (the `/gkbHtXc3Wq/common/lib/<name>.sprx` load), so the test protects the change on Linux too. Non-GPU suite (`ctest -E "^agc"`): same result as `main`; only `file_writer_binary` and `file_writer_text` fail, and they fail on `main` too on this machine (Ubuntu 26.04 coreutils). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Get-fix commented 2026-10-15 23:26:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T23:26:27Z.


Thanks for the Linux run, @jotitadev, including the check that the test fails at the sandboxed-path load without the change.

About the overlap the bot lists with #6544: I merged #6544 with git merge-file against main 5d9dcc42d, with and without this change. The only conflict is in core/libs/tests/GuestDynamicLoader.cpp, where each pull request adds an independent block of test code at the same place: this one its console-path loads, #6544 its nested prx/*.guest.prx case. Keeping both blocks resolves it. The production changes, Module.cpp here and General.cpp in #6544, do not overlap.

AI-assisted: yes (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6204394885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6519#issuecomment-6204394885). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-15T23:26:27Z. --- Thanks for the Linux run, @jotitadev, including the check that the test fails at the sandboxed-path load without the change. About the overlap the bot lists with #6544: I merged #6544 with `git merge-file` against `main` `5d9dcc42d`, with and without this change. The only conflict is in `core/libs/tests/GuestDynamicLoader.cpp`, where each pull request adds an independent block of test code at the same place: this one its console-path loads, #6544 its nested `prx/*.guest.prx` case. Keeping both blocks resolves it. The production changes, `Module.cpp` here and `General.cpp` in #6544, do not overlap. AI-assisted: yes (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
xXPBSXx commented 2026-10-20 18:19:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T18:19:51Z.


Rebase handoff — this PR conflicts with main only in docs/dev/debt/libkernel.md (two entries appended at the end of the file). I rebased it onto main 892a4f1328: the original commit and its author are unchanged, the only difference is the conflict resolution in the debt file (both entries kept). Nothing in the code or the test was changed.

Windows data (Windows 10 19045, MinGW-w64 GCC 15.2.0, Release): guest_dynamic_loader fails with Module.cpp taken back to main (GuestDynamicLoader.cpp:176, exit code 0xc0000409) and passes with this change, 3 of 3 runs; guest_sysmodule and guest_module_info pass; python tools/check_conventions.py --base upstream/main passes. Not run: Linux, macOS, the piglet sample. The relinker Python tests guest_module_* did not run in my build (relinker binary not built), so they are not covered.

To pick it up:

git fetch https://github.com/xXPBSXx/AnyPS5 fix/system-library-console-paths
git checkout <your branch>
git reset --hard FETCH_HEAD

(fdacba6338 on top of 892a4f1328.) I did not open a second pull request.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297991300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6519#issuecomment-6297991300). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T18:19:51Z. --- **Rebase handoff** — this PR conflicts with `main` only in `docs/dev/debt/libkernel.md` (two entries appended at the end of the file). I rebased it onto `main` `892a4f1328`: the original commit and its author are unchanged, the only difference is the conflict resolution in the debt file (both entries kept). Nothing in the code or the test was changed. Windows data (Windows 10 19045, MinGW-w64 GCC 15.2.0, Release): `guest_dynamic_loader` fails with `Module.cpp` taken back to `main` (`GuestDynamicLoader.cpp:176`, exit code `0xc0000409`) and passes with this change, 3 of 3 runs; `guest_sysmodule` and `guest_module_info` pass; `python tools/check_conventions.py --base upstream/main` passes. Not run: Linux, macOS, the piglet sample. The relinker Python tests `guest_module_*` did not run in my build (relinker binary not built), so they are not covered. **To pick it up:** ``` git fetch https://github.com/xXPBSXx/AnyPS5 fix/system-library-console-paths git checkout <your branch> git reset --hard FETCH_HEAD ``` (`fdacba6338` on top of `892a4f1328`.) I did not open a second pull request. AI-assisted (Claude Code).
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!6519
No description provided.