Commit Graph
22 Commits
Author SHA1 Message Date
Adrià bcdc5f6b3e Merge pull request #6702 from karimibrahim07/fix/relinker-weak-guest-imports
fix(relinker): leave weak imports of bundled modules unbound on Windows
2026-10-19 10:49:10 +02:00
Karim Ibrahim ea61baec62 fix(relinker): resolve symbol-name imports through NIDs on Windows
Homebrew built with the ps5-payload-dev SDK imports by symbol name and
names its system libraries with .sprx, while the libraries in libs/
are .prx files that export NIDs. Quake from the websrv launcher
stopped with 457 unresolved imports such as strlen and malloc.

An import without a module that no searched library exports under its
name is now looked up again under the NID of that name. A dependency
named with .sprx, .suprx or .debug_prx loads the .prx library of the
same stem, and libkernel_web also loads libkernel.prx, as
libSceLibcInternal already loads libc.prx.
2026-10-17 22:40:09 -04:00
Karim Ibrahim 18ecee64d2 fix(relinker): leave weak imports of bundled modules unbound on Windows
Domain::GuestImport had no weak flag, so WindowsPePatcher handed every
import of a bundled module to the entry stub as a strong one, and a
weak import that no library exports stopped the title with
"unresolved ELF import". The executable's own weak imports already
bind to null there. libOSMesa.so.8 of the Quake homebrew has ten weak
imports that nothing provides, such as ZSTD_trace_compress_begin and
the SDK's __dlopen.

The guest relocation writer now records the ELF weak binding, and the
stub binds such an import to null when no library exports it.
2026-10-16 01:17:32 -04:00
Kang, Harry Zixuan b2c9e91102 fix(relinker): audit dependencies without imported functions 2026-10-14 20:57:16 +02:00
Nixitov b9acf34801 fix(tools): do not report weak imports as a title's current stop
A weak import is optional: the entry stub leaves it unresolved and the loader sees null, so the title runs. The relinker now records the symbol binding in the call registry and import_audit skips weak imports when computing the current stop. regie5 (PPSA99520) weak-links sceLncUtilLaunchApp and was reported as stopping there while it runs past it.
2026-10-14 04:27:55 +02:00
codingreapermapsandClaude Opus 5.5 430e5c833e feat(relinker): add --trace-imports for Windows executables
With --trace-imports the entry stub resolves TraceImport_nid_no_patch
in libc.prx and passes each function import through it before writing
the slot: every PLT slot, and a GOT slot only when the original symbol
is a function, so data imports such as __stdoutp keep their address.
Without the option the output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 16:55:31 +02:00
boykopovar 6224febfb0 feat(relinker): report instruction conversion progress for executables and modules 2026-10-13 12:57:54 +03:00
boykopovar b42aa8c540 feat(relinker): expose in-memory conversion through a portable core library 2026-10-13 12:57:53 +03:00
boykopovar 04ca1721e5 feat(relinker): add progress interface and console reporter 2026-10-13 12:55:34 +03:00
SimoneandClaude Opus 5.5 cb1c18d552 fix(relinker): keep weak undefined imports weak
Weak undefined imports in the input ELF became STB_GLOBAL in the relinked
output, so a title that weak-imports a function no module exports stopped
at startup instead of binding the import to null.

Keep STB_WEAK on the relinked dynamic symbols. On Windows, write 0 plus
the addend to the slot of a weak import that no searched module exports.

Fixes #4497

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:48:50 +02:00
Aryan singhandClaude Opus 5.5 7c1b64b0ca fix(relinker): share module suffixes between identity and import matching
The guest identity predicate accepted .debug_prx while Domain::ImportModule
did not: a dependency named libGuest.debug_prx normalised to
libGuest_debug_prx, so a qualified import declared in module libGuest was
left unscoped. When another guest module exported the same symbol, the
conversion failed with an ambiguous guest import, while .prx, .sprx and
.suprx resolved to the declaring module.

Module suffixes are now one list in the domain layer, used by the identity
predicate, import module normalisation and the default .prx suffix.
Needed-name stem aliasing keeps its own list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 03:38:07 +05:30
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
DariusHQ e720d3cd61 fix(relinker): skip zero-return guest libc exports for internal libc imports
Since #1454, a libSceLibcInternal import that no native library exports
on Windows falls back to the title's own libc.prx. The loader shim that
ps5-native-app-boilerplate builds into homebrew titles exports 1874
functions at three addresses whose code is `xor eax, eax; ret` or
`pxor xmm0, xmm0; xor eax, eax; ret`. Such an import then binds to a
function that returns 0, and the title starts instead of stopping with
`unresolved ELF import`.

The Windows guest module writer records the exported functions whose
code is one of these two sequences, and the entry stub leaves the guest
libc.prx out of the search for those names. A guest export with code of
its own still provides a missing libSceLibcInternal function, and native
libraries keep their priority.
2026-10-11 09:20:00 +02:00
Abdulrahman Elkordy 87ca3a2cf1 fix(relinker): count unnamed imports only against the library they declare
An import whose module matches no needed library has no library name,
and the Windows startup stub counted it against every library, so a
missing library with nothing imported from it was still never skipped.
Every such import in the executables of Record of Lodoss War, Resident
Evil 4, PRAGMATA and Returnal declares a module that exists under
another file name (libSceJson for libSceJson2.prx, for example), and
none declares libSceXml or Party.

The relinker now keeps the declared module names of those imports, for
the executable and each guest module, and the stub counts a host
library as imported from when its name up to the first dot matches one
of them, ignoring case. A module declared as libGuest still keeps a
missing libGuest.xyz required, as guest_module_identity checks.
Imports without a module ID declare nothing and count against no
library. The rule and the title data are from xXPBSXx.
2026-10-10 17:49:47 -05:00
eliasbruno124-dev 98c47df9e5 fix(relinker): discover required guest module identities 2026-10-09 13:53:48 +02:00
Nicolas AboschandClaude Opus 5.5 b12ef2cf20 fix(relinker): fall back to unqualified lookup for unmatched import modules
A qualified import whose module name matches no DT_NEEDED entry now uses
the unqualified search order instead of failing with "Import module is
not a dependency". Restore the Linux rejection of duplicate exports
within one guest module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 16:48:10 -03:00
Nicolas Abosch e96e9c18cc fix(relinker): map module name aliases to declared dependencies 2026-10-05 22:47:35 -03:00
Nicolas Abosch bf0ee4019d fix(relinker): bind Windows imports to their declared modules 2026-10-05 22:43:25 -03:00
QDarkRex 47f0bf93ef fix(relinker): identify unsupported Windows TLS instructions
The unsupported-instruction error now lists the instruction bytes, and the relink failure names the input file, the main executable or the guest module, on an extra Input: line.
2026-10-04 19:09:10 +07:00
SamG-Coder ad6b37ed42 fix(relinker): resolve guest dependencies and lifecycle arrays 2026-10-01 11:57:13 +03:00
boykopovar 1379ec001b feat(relinker): add native guest module loading with export priority 2026-09-27 11:43:28 +03:00
boykopovar 4b643c6655 refactor(core): seprated folders for relinker and libs 2026-09-11 14:53:01 +03:00