fix(libkernel_sys): reach rename through a _nid_no_patch export #5025

Merged
0xRickx merged 1 commit from upstream-pr/5025 into main 2026-10-13 09:37:37 +00:00
0xRickx commented 2026-10-13 08:51:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 0xRickx on 2026-10-13T08:51:12Z.


What

Since 2a8e7452 (renameat, #4877), libkernel_sys.prx fails to load on Windows (patched_libraries: libkernel_sys.prx: LoadLibraryEx failed with error 127), and so does every title that imports it: ten catalog titles, among them ProsperoRadio PPSA99001, vkQuake PPSA99010, PS5VR PPSA99177 and Porpoise PPSA99764.

renameat calls rename_nid_postfix when both paths are AT_FDCWD-relative or absolute. libc/src/Rename.cpp is built into both libc and libkernel, and libkernel_sys bound that import to libkernel, which comes first on its link line. The NID patcher then rewrote the import to rename's NID (NN01qLRhiqU). Only libc exports that NID: libkernel keeps its copy under the plain name because libc exports it too. Linux resolves the symbol globally, so only Windows was affected.

rename's body is now RenameGuestPath_nid_no_patch, which both libraries export under that name, and renameat calls it, the way libkernel_sys already reaches GetDirectoryDescriptorPath_nid_no_patch and libkernel's other helpers. rename_nid_postfix forwards to it, so its behaviour is unchanged.

Tested

Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, on main 4bb2c7f3:

  • patched_libraries: on main it fails on libkernel_sys.prx with error 127; with this change "127 patched libraries loaded, 0 failed".
  • guest_kernel_sys, guest_kernel_rename and guest_filesystem pass.
  • ProsperoRadio PPSA99001 01.000.010, relinked with this main's relinker: on main it stops with Failed to load module: ...\libs\libkernel_sys.prx / GetLastError: 127; with this change it loads and runs. Porpoise PPSA99764 loads again and stops at its bring-up stop, VideoOut: port already open (#4863).
  • tools/check_conventions.py --base upstream/main passes.

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
  • Unblocks: PPSA99764 #4854, and PPSA99001 and the other titles that import libkernel_sys.prx, on Windows
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4840762265 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5025). Originally posted by [0xRickx](https://github.com/0xRickx) on 2026-10-13T08:51:12Z. --- ### What Since 2a8e7452 (`renameat`, #4877), `libkernel_sys.prx` fails to load on Windows (`patched_libraries`: `libkernel_sys.prx: LoadLibraryEx failed with error 127`), and so does every title that imports it: ten catalog titles, among them ProsperoRadio PPSA99001, vkQuake PPSA99010, PS5VR PPSA99177 and Porpoise PPSA99764. `renameat` calls `rename_nid_postfix` when both paths are `AT_FDCWD`-relative or absolute. `libc/src/Rename.cpp` is built into both libc and libkernel, and `libkernel_sys` bound that import to libkernel, which comes first on its link line. The NID patcher then rewrote the import to `rename`'s NID (`NN01qLRhiqU`). Only libc exports that NID: libkernel keeps its copy under the plain name because libc exports it too. Linux resolves the symbol globally, so only Windows was affected. `rename`'s body is now `RenameGuestPath_nid_no_patch`, which both libraries export under that name, and `renameat` calls it, the way `libkernel_sys` already reaches `GetDirectoryDescriptorPath_nid_no_patch` and libkernel's other helpers. `rename_nid_postfix` forwards to it, so its behaviour is unchanged. ### Tested Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, on `main` 4bb2c7f3: - `patched_libraries`: on `main` it fails on `libkernel_sys.prx` with error 127; with this change "127 patched libraries loaded, 0 failed". - `guest_kernel_sys`, `guest_kernel_rename` and `guest_filesystem` pass. - ProsperoRadio PPSA99001 01.000.010, relinked with this `main`'s relinker: on `main` it stops with `Failed to load module: ...\libs\libkernel_sys.prx` / `GetLastError: 127`; with this change it loads and runs. Porpoise PPSA99764 loads again and stops at its bring-up stop, `VideoOut: port already open` (#4863). - `tools/check_conventions.py --base upstream/main` passes. ### 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 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: PPSA99764 #4854, and PPSA99001 and the other titles that import `libkernel_sys.prx`, on Windows - [x] AI-assisted: yes
p3n1cillin commented 2026-10-13 09:33:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T09:33:06Z.


Additional Windows validation, based on current main 2a2a3dc650b9245fb0fb9b088afb1a6c27637f7d, WinLibs GCC 15.2.0 / Ninja Release / RTX 5070 / driver 617.42. Applied exact PR head 9ceb6d144d5f35994f4d8488bffb751550c3823e as a clean cherry-pick; integration head 6428632e6.

On unmodified main, the full Windows CTest run registered 1,051 tests: 1,042 passed, eight skipped, one failed (patched_libraries, libkernel_sys.prx loader error 127), 124.92 s. A fresh ProsperoLight PPSA99002 v01.000.100 conversion failed at startup with the same loader error; Windows import diagnostics identify NN01qLRhiqU from libkernel.prx as the unresolved dependency.

With this PR, built the affected runtime and ran patched_libraries, guest_kernel_sys, guest_kernel_rename and guest_filesystem: four passed, 0.35 s. A fresh ProsperoLight conversion then remained running for the entire 60-second diagnostic and was deliberately stopped at the deadline, with no loader failure or fatal message in stderr. Its catalog archive SHA-256 was verified before conversion, and its runtime manifest and source commit were recorded privately. No builds or tests overlapped the title.

This establishes a startup unblock. I did not verify rendered output, interaction or game-streaming functionality and do not claim it playable. Raw title artifacts remain private. AI-assisted validation with Codex; original implementation and authorship preserved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142607790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5025#issuecomment-6142607790). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T09:33:06Z. --- Additional Windows validation, based on current `main` `2a2a3dc650b9245fb0fb9b088afb1a6c27637f7d`, WinLibs GCC 15.2.0 / Ninja Release / RTX 5070 / driver 617.42. Applied exact PR head `9ceb6d144d5f35994f4d8488bffb751550c3823e` as a clean cherry-pick; integration head `6428632e6`. On unmodified main, the full Windows CTest run registered 1,051 tests: 1,042 passed, eight skipped, one failed (`patched_libraries`, `libkernel_sys.prx` loader error 127), 124.92 s. A fresh ProsperoLight PPSA99002 v01.000.100 conversion failed at startup with the same loader error; Windows import diagnostics identify `NN01qLRhiqU` from `libkernel.prx` as the unresolved dependency. With this PR, built the affected runtime and ran `patched_libraries`, `guest_kernel_sys`, `guest_kernel_rename` and `guest_filesystem`: four passed, 0.35 s. A fresh ProsperoLight conversion then remained running for the entire 60-second diagnostic and was deliberately stopped at the deadline, with no loader failure or fatal message in stderr. Its catalog archive SHA-256 was verified before conversion, and its runtime manifest and source commit were recorded privately. No builds or tests overlapped the title. This establishes a startup unblock. I did not verify rendered output, interaction or game-streaming functionality and do not claim it playable. Raw title artifacts remain private. AI-assisted validation with Codex; original implementation and authorship preserved.
dantdmdarealguy commented 2026-10-14 00:32:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-14T00:32:35Z.


Tested on Windows after the merge: it fixes the libkernel_sys.prx load failure for the four catalog titles I have relinked, and patched_libraries passes.

Host: Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON.

Builds: base 4bb2c7f3947440d513b1dbd12143ec55b250495a (this PR's base) and head 9ceb6d144d5f35994f4d8488bffb751550c3823e (pull/5025/head), same build directory, targets relinker libs patched_libraries_tests guest_kernel_sys_tests guest_kernel_rename_tests guest_filesystem_tests.

Tests: ctest --timeout 120 --parallel 2 -R "^(patched_libraries|guest_kernel_sys|guest_kernel_rename|guest_filesystem)$"

base head
patched_libraries fails: libkernel_sys.prx: LoadLibraryEx failed with error 127, 126 patched libraries loaded, 1 failed passes
guest_kernel_sys, guest_kernel_rename, guest_filesystem pass pass

Titles: catalog release ZIPs checked against the catalog sha256; eboot.bin and sce_module/libc.prx unwrapped from their SELF containers; relinked with each build's own relinker (relinker --windows --registry eboot.elf app.exe), that build's libs/*.prx plus the three MinGW DLLs, the package contents as app0/. Run for up to 60 s.

Title base head
PSXS5 PPSA97510 2.2.0 exit 127 after 0.25 s: Failed to load module: ...\libs\libkernel_sys.prx / GetLastError: 127 - The specified procedure could not be found. loads, runs 8 s, opens its pad ([psxs5] pad 1: Player (17 buttons, 6 axes)), then stops at what(): poll: POLLPRI is not supported by WSAPoll
ProsperoRadio PPSA99001 01.000.010 same as above, 0.30 s loads, then stops at what(): poll: POLLPRI is not supported by WSAPoll (2.2 s)
XashPS5 PPSA19111 1.3 same as above, 0.26 s loads and exits 0 at its own data check: XashPS5: the "valve" folder is incomplete (valve/liblist.gam is missing).
vkQuake PPSA99010 1.0 same as above, 0.27 s loads and exits 0: Quake Error: W_LoadWadFile: couldn't load gfx.wad (no game data)

The POLLPRI stop that PSXS5 and ProsperoRadio reach next is the WSAPoll path in Socket/src/Udp.cpp, not this change; #4525, merged after this PR's base, handles it on main.

Code: rename and renameat now both go through RenameGuestPath_nid_no_patch, which libc and libkernel both export under that name, so the import libkernel_sys binds to libkernel resolves by name on Windows; rename_nid_postfix keeps its body through the forward. The helper reports errors through errno, and __error() returns &errno of the shared UCRT, so which of the two copies runs makes no difference to the guest.

Verdict: works as described; no change requested.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158165112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5025#issuecomment-6158165112). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-14T00:32:35Z. --- Tested on Windows after the merge: it fixes the `libkernel_sys.prx` load failure for the four catalog titles I have relinked, and `patched_libraries` passes. **Host:** Windows 11 Pro, Intel Core i9-14900K, 128 GB, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`. **Builds:** base `4bb2c7f3947440d513b1dbd12143ec55b250495a` (this PR's base) and head `9ceb6d144d5f35994f4d8488bffb751550c3823e` (`pull/5025/head`), same build directory, targets `relinker libs patched_libraries_tests guest_kernel_sys_tests guest_kernel_rename_tests guest_filesystem_tests`. **Tests:** `ctest --timeout 120 --parallel 2 -R "^(patched_libraries|guest_kernel_sys|guest_kernel_rename|guest_filesystem)$"` | | base | head | |---|---|---| | `patched_libraries` | fails: `libkernel_sys.prx: LoadLibraryEx failed with error 127`, `126 patched libraries loaded, 1 failed` | passes | | `guest_kernel_sys`, `guest_kernel_rename`, `guest_filesystem` | pass | pass | **Titles:** catalog release ZIPs checked against the catalog sha256; `eboot.bin` and `sce_module/libc.prx` unwrapped from their SELF containers; relinked with each build's own relinker (`relinker --windows --registry eboot.elf app.exe`), that build's `libs/*.prx` plus the three MinGW DLLs, the package contents as `app0/`. Run for up to 60 s. | Title | base | head | |---|---|---| | PSXS5 PPSA97510 2.2.0 | exit 127 after 0.25 s: `Failed to load module: ...\libs\libkernel_sys.prx` / `GetLastError: 127 - The specified procedure could not be found.` | loads, runs 8 s, opens its pad (`[psxs5] pad 1: Player (17 buttons, 6 axes)`), then stops at `what(): poll: POLLPRI is not supported by WSAPoll` | | ProsperoRadio PPSA99001 01.000.010 | same as above, 0.30 s | loads, then stops at `what(): poll: POLLPRI is not supported by WSAPoll` (2.2 s) | | XashPS5 PPSA19111 1.3 | same as above, 0.26 s | loads and exits 0 at its own data check: `XashPS5: the "valve" folder is incomplete (valve/liblist.gam is missing).` | | vkQuake PPSA99010 1.0 | same as above, 0.27 s | loads and exits 0: `Quake Error: W_LoadWadFile: couldn't load gfx.wad` (no game data) | The `POLLPRI` stop that PSXS5 and ProsperoRadio reach next is the `WSAPoll` path in `Socket/src/Udp.cpp`, not this change; #4525, merged after this PR's base, handles it on `main`. **Code:** `rename` and `renameat` now both go through `RenameGuestPath_nid_no_patch`, which libc and libkernel both export under that name, so the import `libkernel_sys` binds to libkernel resolves by name on Windows; `rename_nid_postfix` keeps its body through the forward. The helper reports errors through `errno`, and `__error()` returns `&errno` of the shared UCRT, so which of the two copies runs makes no difference to the guest. Verdict: works as described; no change requested.
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!5025
No description provided.