Commit Graph
23 Commits
Author SHA1 Message Date
Dean 0ce4b82c2d Merge pull request #10243 from orezraey/fix/libkernel-rtld-thread-atexit-measured-ps5
fix(libkernel): answer the thread atexit references as measured on a PS5
2026-10-26 16:23:13 +13:00
Dean 3af09d95e2 Merge pull request #10494 from xXPBSXx/carry/6544-relinked-nested
fix(libc): look in prx, sce_module and sce_modules for a relinked module after its own directory
2026-10-26 14:47:47 +13:00
orezraeyandClaude Opus 5.5 b3b0760369 Merge main into fix/libkernel-rtld-thread-atexit-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 08:05:05 -03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
orezraeyandClaude Opus 5.5 138bde1cd6 test(libkernel): drop the assertion on the unsupported thread atexit decrement
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 03:08:51 -03:00
orezraeyandClaude Opus 5.5 698697cbc7 fix(libkernel): throw for an unmeasured unbalanced thread atexit decrement on a module
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 02:53:35 -03:00
xXPBSXxandClaude Sonnet 5.5 e2dda5eba0 fix(libc): prefer a same-directory relinked module over nested prx folders
RelinkedModulePath looked in prx, sce_module and sce_modules before the
case-insensitive match in the module's own directory, so a stray nested file
could shadow a module next to the title. Check the directory of the module
first, then the nested folders, and match the nested names case-insensitively.

Tests: a same-directory module with a differently cased name wins over an
exact-case nested file, and a nested module is found case-insensitively.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-24 05:26:50 +02:00
notaxeltvandCursor c917d982b1 fix(libc): prefer nested prx/*.guest.prx for RelinkedModulePath
Unbound copies next to eboot concurrently LoadLibrary the same PE and leave Job0 with a null vtable; reuse the already-loaded nested guest module instead.

Co-authored-by: Cursor <[email protected]>
2026-10-24 05:26:50 +02:00
orezraeyandClaude Opus 5.5 e437f33787 fix(libkernel): answer the thread atexit references as measured on a PS5
Increment returns -1 for an address outside every module and Decrement never fails, instead of throwing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:13:07 -03: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
Dean Galvin 0f7241f3a7 Merge origin/main into PR 6519 2026-10-21 21:35:27 +13: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
Ondra97 819eb9bb4c fix(libkernel): preserve RTLD_GLOBAL visibility on Windows 2026-10-15 18:35:19 +02:00
Rishit Vora 2caefdb8ed fix(libkernel): resolve renamed guest exports in the default scope 2026-10-14 04:19:49 +00:00
tototomate123 4a62b6220b fix(build): export the Windows dynamic loader test executable 2026-10-11 11:50:44 +02:00
tototomate123 19b0359f13 fix(loader): support main-module sceKernelDlsym 2026-10-11 11:50:44 +02:00
Adrià FranchandClaude 0ecd75fd54 test(libkernel): put the GuestDefaultScopeOnly assertion on its own line
Co-Authored-By: Claude <[email protected]>
2026-10-08 14:30:59 +02:00
jeffrey12cali 34616c425b fix(module): resolve the default dlsym scope against guest exports only
Titles pass handle 0 (RTLD_DEFAULT) for a process-wide lookup, and the loader rejected it: the handle is
not in the module map, so every such lookup failed even when a loaded module exports the symbol. Handle 0
and -2 now take the default scope, searching the global modules by plain name, NID and `#guest` form, and
then the process-wide scope.

The process-wide scope of the real loader also contains glibc and libstdc++, so an unfiltered fallback
would answer `malloc`, `dlopen` and `pthread_create` where PS5 reports the symbol as missing: handle 0 is
the main program, whose lookup sees the program's exports, not the host C++ runtime. A result from the
process scope is therefore accepted only when `dladdr` attributes it to a converted or replacement module
(a `.prx` library or the executable), which keeps the fallback for guest symbols and removes the host
leak. `guest_dynamic_loader` asserts the three host names are not found; disabling the filter makes that
test fail.

The scripting heap that an earlier revision of this branch added has been dropped: the title reaches the
same boot milestone with the lookup failing honestly, so the export was an inference rather than a
requirement, and prosper's bring-up notes report `ESRCH` for that name on hardware.
2026-10-08 14:30:55 +02:00
alfalfa-starandClaude Opus 5.5 5e009d75ec feat(libkernel): implement the rtld thread atexit reference count
A title's libc.prx passes the dso address of __cxa_thread_atexit to
_sceKernelRtldThreadAtexitIncrement and fails the registration when it
returns nonzero. Increment takes a reference on the loaded image that
contains the address, so it stays mapped while thread_local destructors
are pending, and Decrement releases one. An address outside every
loaded image and a Decrement without a reference throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-06 08:36:23 +02:00
Dean 633459b09c Merge pull request #672 from NahuelGenchi/fix/linux-guest-export-namespace
fix(relinker): keep host prx references out of guest modules on Linux
2026-10-06 13:15:49 +13:00
Nahuel Genchi 5fab03e4e5 fix(relinker): keep host prx references out of guest modules on Linux
On Linux every module resolves its references through one global scope,
and the guest modules are listed ahead of the host prx. When a title
bundles its own libc.prx, the host libc and the other host prx bound
their references to their own NIDs to the guest libc, so the host libc
built its standard streams on top of the guest _Stdout.

The exports of guest modules, and the guest and executable imports that
a guest module satisfies, now carry a #guest suffix. The title's imports
still reach the guest modules first, and a host prx only sees host
definitions, as on Windows. sceKernelDlsym also looks for the suffixed
name.
2026-10-05 19:58:39 -03:00
MerijnandClaude Opus 5.5 de93a9492c feat(libkernel): load the relinked module for a guest module path
dlopen and sceKernelLoadStartModule passed the 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. PPSA12544 loads /app0/Media/Modules/Il2CppUserAssemblies.prx
at startup and resolves IL2CPP functions through it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 19:41:47 +02:00
SamG-Coder 453fec28c5 feat(kernel): add tracked dynamic module loading and NID lookup 2026-09-25 06:48:50 +10:00