Commit Graph
82 Commits
Author SHA1 Message Date
pista 2c22b68133 fix(libs): reject unsupported WebAssembly module unwind queries 2026-10-30 10:50:57 +09:00
Adrià f9a8813b11 Merge pull request #12179 from p3n1cillin/claude/kernel-executable-module-handle
feat(libkernel): add sceKernelGetExecutableModuleHandle
2026-10-30 02:01:01 +01:00
Adrià 5a3c1a2f81 Merge pull request #10627 from maximilianfv/fix/libkernel-dlerror-long-messages
fix(libkernel): keep dlerror messages whole
2026-10-30 01:02:55 +01:00
p3nicillinandClaude Opus 5.5 4cf7411a46 feat(libkernel): add sceKernelGetExecutableModuleHandle
Return the main program's handle, the first one sceKernelGetModuleList
lists and one sceKernelGetModuleInfo accepts. reSOT (PPSA99023) imports
it from libkernel and passes the handle to sceKernelGetModuleInfo to find
its own code segment; before this its eboot failed to load on the
unresolved import.

The PS5 3.20 export lists have it in libkernel as well as libkernel_sys,
and on Windows a libkernel import never reaches libkernel_sys, so the
throwing libkernel_sys stub moves to libkernel as pselect did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 12:17:59 +00:00
Dean 5023cd5a25 Merge pull request #9263 from imellag/fix/libkernel-macos-guest-unwind-info
fix(libkernel): report unwind information for guest and host addresses on macOS
2026-10-27 18:19:28 +13:00
orezraeyandClaude Opus 5.5 19f56c530a fix(libkernel): write the module handles before failing a null count as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 19:04:34 -03:00
memob b9858031a7 refactor(libkernel): declare __tls_get_addr once with its real signature
The public header declared the unimplemented placeholder int __tls_get_addr(void). It now declares void* __tls_get_addr(const KernelTlsIndex*), the tls_index pointer the ABI passes, and the implementation and the test use that declaration and type instead of their own.
2026-10-24 20:30:50 -04:00
memob cf27259538 feat(libkernel): implement __tls_get_addr
Resolve a FreeBSD/ELF tls_index {module, offset} the way the relinker's
DTPMOD64 values are laid out: on Windows through the PE _tls_index the
module word points at and the thread's ThreadLocalStoragePointer, on
Linux through glibc's __tls_get_addr.
2026-10-24 20:29:20 -04:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean Galvin d7e2371a84 Merge main into fix/libkernel-macos-guest-unwind-info 2026-10-25 01:14:01 +13:00
Dean 0fc488a06d Merge pull request #10230 from orezraey/fix/libkernel-module-info-from-addr-measured-ps5
fix(libkernel): answer sceKernelGetModuleInfoFromAddr's flags and failures as measured on a PS5
2026-10-25 00:24:17 +13:00
Maximilian FleckensteinandClaude Opus 5.5 4bf9853dbf fix(libkernel): keep dlerror messages whole
dlerror returned the last loader error from a 512-byte buffer, so a
longer message was cut off. On macOS the reason dyld gives for a failed
dlopen lists every path it tried, and the message for a module that was
not relinked runs to over 1,000 characters; the end of it, the hint to
relink with --module-dir, was lost, and guest_dynamic_loader failed.
Keep the message in a host thread-local string, through
HostThreadLocal so MinGW does not run its destructor on freed
thread-local storage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 06:44:57 -03:00
JJenkx 2d4d55036d test(loader): preserve explicit zero-argument module starts 2026-10-23 11:15:40 -04:00
JJenkx 74878ee102 feat(loader): prototype deferred Linux runtime module lifecycles 2026-10-23 11:15:40 -04:00
orezraeyandClaude Opus 5.5 3717573887 fix(libkernel): answer sceKernelGetModuleInfoFromAddr's flags and failures as measured on a PS5
Flags 1 finds any module and flags 2 only non-system ones; other flags return EINVAL instead of throwing, every failure clears the 0x1A8 bytes, and st_size is left 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 11:49:24 -03:00
Dean 5e9f4b8966 Merge pull request #9832 from johandavidcm/fix/libkernel-dlopen-unrelinked
fix(libkernel): fail dlopen of an unrelinked module without the Windows Bad Image dialog
2026-10-23 23:18:00 +13:00
Johan David dc84bec7b9 fix(libkernel): fail dlopen of an unrelinked module without the Windows Bad Image dialog
On Windows, dlopen passed a module that was never relinked to LoadLibraryExW, which raised the
modal Bad Image hard-error dialog and blocked the calling thread until someone answered it. The
load now runs with SEM_FAILCRITICALERRORS set for that thread only, so it fails at once with the
same result as before. Every failed load is reported once per file on stderr with a [module]
prefix; a file that exists with no relinked .guest.prx names the relinker's --module-dir option.
2026-10-22 13:05:34 -05:00
Yossi Yadgar 36d4939b4e feat(libkernel): fill SceKernelModuleInfoEx by module handle 2026-10-22 15:52:18 +03:00
Emanueleandmugurc bfa5368657 fix(libkernel): report unwind information for guest and host addresses on macOS
Two unwind queries a title makes went wrong on macOS, so a C++ exception the title would catch ended the process instead: God of War Sons of Sparta (PPSA28997) stops on an IL2CPP exception it normally handles.

- sceKernelGetModuleInfoForUnwind found a relinked image and its PT_GNU_EH_FRAME header but left eh_frame_addr and eh_frame_size at zero, so the title's unwinder found no FDE for its own frame. The tables are now read with EhFrame::ReadTables over the image's load segments, as ModuleInfo does on Linux, and eh_frame_size includes the zero terminator, as on Linux.
- sceSysmoduleGetModuleInfoForUnwind read /proc/self/maps outside Windows and threw on every call on macOS. It now answers from mach_vm_region, with the image path from dladdr, as the Linux branch answers from the mapping.

guest_unwind_module_info now runs on macOS: the test executable carries the __APS5DATA,__meta program headers that the macOS dl_iterate_phdr reads from a relinked image. guest_sysmodule checks the macOS answers against mach_vm_region.

Co-authored-by: mugurc <[email protected]>
2026-10-21 18:39:48 +02:00
Dean Galvin 0f7241f3a7 Merge origin/main into PR 6519 2026-10-21 21:35:27 +13:00
MarcZX10 05cc68cd95 style(libkernel): keep regression comments out of code 2026-10-20 20:52:44 +00:00
MarcZX10 e1e20f0f2e fix(libkernel): match module info segment records 2026-10-20 20:50:05 +00:00
Adrià 324e0e48e0 Merge pull request #6482 from Ondra97/codex/team-20261015-worker-1-ready
fix(libkernel): preserve RTLD_GLOBAL visibility on Windows
2026-10-19 03:39:21 +02:00
Get-fix ca75c94cc2 feat(libkernel): load system libraries from their console paths
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. The path
was opened as a guest file and the load failed with ENOENT.

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. Names with a directory part are
not mapped, so such a path cannot leave libs/.
2026-10-17 04:46:19 +03:00
Adrià 5b70a50680 Merge pull request #5955 from fma-rc/fix/libkernel-linux-guest-module-protect
fix(libkernel): register a relinked guest module's image when Linux protects its pages
2026-10-16 23:29:46 +02:00
Ondra97 819eb9bb4c fix(libkernel): preserve RTLD_GLOBAL visibility on Windows 2026-10-15 18:35:19 +02:00
Adrià 3751c55111 Merge pull request #5700 from specbug/fix/default-scope-guest-symbols
fix(libkernel): resolve renamed guest exports in the default scope
2026-10-15 17:04:10 +02:00
fma-rc c1783f9d64 fix(libkernel): register a relinked guest module's image when Linux protects its pages 2026-10-14 18:24:45 +02:00
Renan Pires 13b1113d93 fix(libkernel): find main-program symbols when the executable is not position independent 2026-10-14 12:35:22 +02:00
JAB-devandClaude Sonnet 5.5 19c55dc804 fix(libkernel): drop the unwind cache's freshness check and let a failed forget throw
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-14 07:41:54 +02:00
Rishit Vora 2caefdb8ed fix(libkernel): resolve renamed guest exports in the default scope 2026-10-14 04:19:49 +00:00
JAB-devandClaude Sonnet 5.5 05bf752bfa fix(libkernel): clear the unwind cache when forgetting unloaded images fails
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-14 02:57:39 +02:00
JAB-devandClaude Sonnet 5.5 434e0b9edf fix(libkernel): forget unwind images only when their module is unloaded and read tables outside the lock
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-14 02:49:16 +02:00
JAB-devandClaude Sonnet 5.5 cf8c63b9b8 perf(libkernel): find a cached module's unwind tables without VirtualQuery on Windows
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-13 21:40:15 +02:00
JAB-devandClaude Sonnet 5.5 61ed25d9ed fix(libkernel): drop the cached unwind tables when the loader frees a module
The cache key of relinked images has no time stamp or check sum, so a
different module of the same size loaded at the same base was served the
old tables. The loader now forgets the image when it frees the module, the
cache has a separate valid flag, and the sysmodule name cache is left out
of this change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-13 18:13:12 +02:00
JAB-devandClaude Sonnet 5.5 5339c084e8 perf(libkernel): cache the unwind tables and image name per module on Windows
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-13 08:14:53 +02:00
Dean 88f48fddef Merge pull request #4688 from eliyarson/fix/kernel-stat-relinked-prx
fix(libkernel): resolve original .prx names to relinked .guest.prx in stat, open and reachability
2026-10-13 17:48:42 +13:00
jagrat Singh ea03a22c7f feat(libkernel): implement sceKernelInternalMemoryGetModuleSegmentInfo 2026-10-13 04:29:25 +05:30
Eli Yarson f80a2f5535 fix(libkernel): resolve original .prx names to relinked .guest.prx in stat, open and reachability
Titles check for a plugin with sceKernelStat before loading it through the engine path. The relinker emits only X.prx.guest.prx, so the check failed and PSNCore started with the raw (0, NULL) arguments. Share the dlopen mapping with sceKernelStat, read-only sceKernelOpen and sceKernelCheckReachability when the original name is absent.
2026-10-12 16:02:14 -03:00
jagrat Singh dbce47244b feat(libkernel): implement sceKernelGetLibkernelTextLocation 2026-10-13 00:30:15 +05:30
Dean 9df77462cc Merge pull request #4544 from poonasor/feat/libkernel-module-info2
feat(libkernel): implement sceKernelGetModuleList2 and sceKernelGetModuleInfo2
2026-10-13 07:33:08 +13:00
poonasorandClaude Opus 5.5 08824f3b90 feat(libkernel): implement sceKernelGetModuleList2 and sceKernelGetModuleInfo2
The title-module variants of sceKernelGetModuleList and
sceKernelGetModuleInfo, following shadPS4: the list leaves out system
libraries and the info call answers EPERM for one. A system library is
a loaded .prx image that is not a relinked title module.

NHL 27 (PPSA34063) imports both and fails to load without them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 11:15:26 -04:00
Ondra97 ec5688a666 fix(libkernel): bind deferred initialization to the loaded image 2026-10-12 12:34:35 +02:00
Adrià 32f6414314 Merge pull request #3713 from SleglJan/fix/libkernel-flexible-module-charge
fix(libkernel): count guest module segments against the flexible memory budget
2026-10-11 23:54:59 +02:00
gookie 28320acf2c perf(libkernel): read a loaded image's unwind tables once in sceKernelGetModuleInfoFromAddr
sceKernelGetModuleInfoFromAddr found the size of the image's .eh_frame
on every call by walking all of its CIE and FDE records, checking each
against every PT_LOAD header. The guest libc's unwinder calls it for
each frame it unwinds, so a title that unwinds often walked its whole
.eh_frame hundreds of times per second.

The tables read from a .eh_frame_hdr are now kept per header address
and reused while the image stays loaded. The cache is dropped whenever
dl_iterate_phdr reports that an object was unloaded (dlpi_subs), so an
address reused by another image is read again.

guest_module_info queries a module twice and expects the same tables,
then unloads it, loads it again and expects tables of the same size at
the same offset in the new image.

PPSA16827 (Harmony's Odyssey), title screen, over 500 calls per second
counted under gdb, which slows the title: the process used 9269 CPU
samples per 10 s, 53.7% of them in this walk, and 3306 with this change,
3.2% in the lookup. The title still runs at 27 FPS; its frame rate is
limited elsewhere.
2026-10-11 19:07:37 +02:00
Jan ŠléglandClaude Opus 5.5 e753080391 fix(libkernel): count guest module segments against the flexible memory budget
sceKernelAvailableFlexibleMemorySize and the flexible maps counted only
explicit flexible mappings, so the full 448 MiB was reported while the
title's executable and modules were loaded. A title that derives its code
and data size from the budget minus the available size got an unsigned
underflow.

The segments of the main executable and of every .guest.prx module that
the title's ELF gives permissions now count, rounded to 16 KiB pages, as
shadPS4 maps every non-system module segment as flexible memory. The
relinker's own blocks and the host system libraries do not count. The
charge ends when a module is unloaded.

Refs #2883

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq
2026-10-11 17:48:05 +02:00
tototomate123 19b0359f13 fix(loader): support main-module sceKernelDlsym 2026-10-11 11:50:44 +02:00
Adrià 71dda5b333 Merge pull request #3297 from SynnZer0/fix/libkernel-module-info-st-size
fix(libkernel): ignore the input st_size of sceKernelGetModuleInfoFromAddr
2026-10-11 10:45:21 +02:00
Merijn 1c6eac425d feat(relinker): add --module-dir for modules loaded at run time
Relinks the ELF modules of extra directories under the module parent directory. Modules the executable or another module needs start with the executable; the others are initialized when the title loads them with sceKernelLoadStartModule, with its start arguments (Windows: __aps5_guest_initialize export; Linux: left out of DT_NEEDED).

Squashed onto main by the reviewer (history had a merge commit).
2026-10-11 10:11:31 +02:00
SynnZer0andClaude Opus 5.5 8ad1bcb589 fix(libkernel): ignore the input st_size of sceKernelGetModuleInfoFromAddr
The bundled libc.prx of PPSA21703 calls sceKernelGetModuleInfoFromAddr
with a 0x1A8-byte stack buffer and never sets st_size, so the field holds
whatever was on the stack (983040 in one run) and the call threw. The
console cannot require the field on input. The full size is still
written back. The flags check is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-11 02:02:38 -04:00