ctest loads the unpatched libraries, so an import that nid_patcher renames only fails when a title loads the patched prx #1827

Closed
opened 2026-10-08 20:41:35 +00:00 by LeandroLP23 · 0 comments
LeandroLP23 commented 2026-10-08 20:41:35 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-08T20:41:35Z.


Every test puts libs/unpatched on its path (RUNTIME_OUTPUT_DIRECTORY in core/libs/CMakeLists.txt, PATH=path_list_prepend:$<TARGET_FILE_DIR:...> in the test definitions). Titles load build/core/libs/libs/*.prx, which nid_patcher has rewritten. Its rule (core/libs/nid/src/NidResolver.cpp:40-62) keeps a host export's name only if libc exports it too, it ends in _nid_no_patch, or it starts with SDL_. Every other export is renamed to its hash. On the import side only _nid_postfix and sce* names are rewritten.

So a library that calls a plain C++ helper from another library links, passes every test and CI, and then fails to load for every title. #1613 is an example: libScePosixForWebKit.prx imports _ZN12GuestSockets6IsOpenEi from libkernel. In the patched libkernel that export is renamed, and on Windows the module fails with GetLastError: 127, so OpenGL Showcase (PPSA99005) no longer starts (details in #1613).

On main 4b6ab6bb all 122 patched libraries load on Windows, so nothing is broken today. Nothing checks it, though: tools/import_audit.py checks a title's imports, and nid_patcher_dynamic_strings/nid_patcher_symbol_versions cover one fixture on Linux only.

A test that loads each patched .prx with its imports bound would catch it. PR to follow.

Found with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5768610144 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1827). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-08T20:41:35Z. --- Every test puts `libs/unpatched` on its path (`RUNTIME_OUTPUT_DIRECTORY` in `core/libs/CMakeLists.txt`, `PATH=path_list_prepend:$<TARGET_FILE_DIR:...>` in the test definitions). Titles load `build/core/libs/libs/*.prx`, which `nid_patcher` has rewritten. Its rule (`core/libs/nid/src/NidResolver.cpp:40-62`) keeps a host export's name only if libc exports it too, it ends in `_nid_no_patch`, or it starts with `SDL_`. Every other export is renamed to its hash. On the import side only `_nid_postfix` and `sce*` names are rewritten. So a library that calls a plain C++ helper from another library links, passes every test and CI, and then fails to load for every title. #1613 is an example: `libScePosixForWebKit.prx` imports `_ZN12GuestSockets6IsOpenEi` from libkernel. In the patched libkernel that export is renamed, and on Windows the module fails with `GetLastError: 127`, so OpenGL Showcase (PPSA99005) no longer starts (details in #1613). On `main` 4b6ab6bb all 122 patched libraries load on Windows, so nothing is broken today. Nothing checks it, though: `tools/import_audit.py` checks a title's imports, and `nid_patcher_dynamic_strings`/`nid_patcher_symbol_versions` cover one fixture on Linux only. A test that loads each patched `.prx` with its imports bound would catch it. PR to follow. Found with AI assistance (Claude Code).
Sign in to join this conversation.
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#1827
No description provided.