feat(libkernel): load the relinked module for a guest module path #717

Merged
merwie merged 1 commit from upstream-pr/717 into main 2026-10-05 23:18:56 +00:00
merwie commented 2026-10-05 17:53:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-05T17:53:39Z.


What

dlopen (and so sceKernelLoadStartModule) passed the resolved guest path to the host loader, which cannot load the original ELF module. When a relinked module <path>.guest.prx exists beside it, that module is loaded instead. For a module the executable already loaded at startup, the host loader returns the same module, so the handle refers to the instance the title already uses.

PPSA12544 (Hollow Knight: Silksong, Unity) calls sceKernelLoadStartModule("/app0/Media/Modules/Il2CppUserAssemblies.prx") and .../PS5Util.prx at startup and resolves IL2CPP functions through the returned handle (il2cpp_set_find_plugin_callback and others). Both loads returned 0x80020002 (unable to load ..., error:0x80020002 on stdout), the resolved function pointers stayed null and the title later called through a null il2cpp_set_find_plugin_callback.

  • guest_dynamic_loader: a placeholder ELF anyps5-relinked-module-for-test.prx with the fixture module copied beside it as .guest.prx opens through the ELF path and resolves GuestModuleAdd. With the loader change reverted the test aborts.

The relinked modules are placed beside the originals by #716 for modules outside sce_module; modules in sce_module already are.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Ryzen 7 9800X3D, Radeon RX 9070 XT.

  • ctest: 288/290 passed, including guest_dynamic_loader. agc_driver_lds_atomics64 and agc_driver_vopc_compare_table fail on this machine on main as well (Vulkan device tests).
  • PPSA12544 with #716: both loads succeed, the unable to load lines are gone and IL2CPP initialisation opens Media/Metadata/global-metadata.dat.

Not tested on Linux.

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 (useful for modules outside sce_module together with #716)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4748859895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/717). Originally posted by [merwie](https://github.com/merwie) on 2026-10-05T17:53:39Z. --- ### What `dlopen` (and so `sceKernelLoadStartModule`) passed the resolved guest path to the host loader, which cannot load the original ELF module. When a relinked module `<path>.guest.prx` exists beside it, that module is loaded instead. For a module the executable already loaded at startup, the host loader returns the same module, so the handle refers to the instance the title already uses. PPSA12544 (Hollow Knight: Silksong, Unity) calls `sceKernelLoadStartModule("/app0/Media/Modules/Il2CppUserAssemblies.prx")` and `.../PS5Util.prx` at startup and resolves IL2CPP functions through the returned handle (`il2cpp_set_find_plugin_callback` and others). Both loads returned `0x80020002` (`unable to load ..., error:0x80020002` on stdout), the resolved function pointers stayed null and the title later called through a null `il2cpp_set_find_plugin_callback`. - `guest_dynamic_loader`: a placeholder ELF `anyps5-relinked-module-for-test.prx` with the fixture module copied beside it as `.guest.prx` opens through the ELF path and resolves `GuestModuleAdd`. With the loader change reverted the test aborts. The relinked modules are placed beside the originals by #716 for modules outside `sce_module`; modules in `sce_module` already are. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Ryzen 7 9800X3D, Radeon RX 9070 XT. - `ctest`: 288/290 passed, including `guest_dynamic_loader`. `agc_driver_lds_atomics64` and `agc_driver_vopc_compare_table` fail on this machine on `main` as well (Vulkan device tests). - PPSA12544 with #716: both loads succeed, the `unable to load` lines are gone and IL2CPP initialisation opens `Media/Metadata/global-metadata.dat`. Not tested on Linux. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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 (useful for modules outside `sce_module` together with #716) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-05 18:15:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T18:15:26Z.


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
#722 core/libs/tests/GuestDynamicLoader.cpp L2, L39
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6000391194 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/717#issuecomment-6000391194). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T18:15:26Z. --- <!-- 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 | |---|---|---|---| | #722 | `core/libs/tests/GuestDynamicLoader.cpp` [L2](https://github.com/boykopovar/AnyPS5/blob/44b3778ce9d7468517661f000510769a0ba21b7d/core/libs/tests/GuestDynamicLoader.cpp#L2), [L39](https://github.com/boykopovar/AnyPS5/blob/44b3778ce9d7468517661f000510769a0ba21b7d/core/libs/tests/GuestDynamicLoader.cpp#L39) | | |
merwie commented 2026-10-05 20:49:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-05T20:49:21Z.


On the overlap note: #722 adds unrelated rtld thread-atexit checks to GuestDynamicLoader.cpp; both append to the end of main and add includes, so whichever merges second needs a small rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6002656091 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/717#issuecomment-6002656091). Originally posted by [merwie](https://github.com/merwie) on 2026-10-05T20:49:21Z. --- On the overlap note: #722 adds unrelated rtld thread-atexit checks to `GuestDynamicLoader.cpp`; both append to the end of `main` and add includes, so whichever merges second needs 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!717
No description provided.