Commit Graph
45 Commits
Author SHA1 Message Date
Adrià e0adc075a2 Merge pull request #6697 from karimibrahim07/feat/relinker-named-host-imports
fix(relinker): resolve symbol-name imports through NIDs on Windows
2026-10-19 10:49:05 +02:00
Adrià Franch da5b7e3334 docs(debt): note that macOS output traps GS-prefixed instructions without a memory operand too 2026-10-19 02:06:49 +02:00
David 414c1f96a6 docs(debt): record that guest GS accesses trap in macOS output 2026-10-19 02:06:44 +02:00
Adrià 2c2abc453b Merge pull request #6354 from SandstromPL/fix/relinker-plt-before-code
fix(relinker): find the PLT before the code in PS4 modules
2026-10-19 01:32:36 +02:00
Adrià 64b57d1b02 Merge pull request #6328 from aaro56/fix/relinker-preserve-input-hardlinks
fix(relinker): preserve inputs behind Windows executable hard links
2026-10-19 01:17:35 +02:00
Adrià 9121a9e455 Merge pull request #6327 from HilalElusive/patch-1
docs(debt): correct Windows GUI logging description
2026-10-19 01:08:04 +02:00
Dean Galvin c3b9001592 revert(relinker): run guest preinit arrays before the module initializer (#6112)
This reverts commit 376c040294.
2026-10-19 09:38:31 +13:00
SandstromPLandClaude Opus 5.5 81561867fc Merge upstream/main into fix/relinker-plt-before-code
Resolve the docs/dev/debt/relinker.md conflict with #5994: keep its
sce_module syscall-scan entry, which now also stops at the end of the
last unwind function when the PLT comes before the code (it calls the
same FindSceCodeEnd), and its /libexec/ld-elf.so.1 start in the code
analysis entry, with this PR's end for a PLT before the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 22:51:57 +05:30
Ayamullah Khan 9c43211664 fix(relinker): run guest preinit arrays before the module initializer
Converted guest modules never ran their DT_PREINIT_ARRAY entries: the
reader validated the array and the unused-NID filter kept its targets,
but no writer emitted or ran it. ld.so runs a shared object's preinit
array only for the main executable, so the Linux output runs the
entries from the DT_INIT stub before the module initializer; the macOS
and Windows outputs run them before the initializer in their startup
stubs, and the deferred Windows output exports a thunk that runs them
before the initializer for runtime-loaded modules. A module with a
preinit array and no initializer is still rejected, since the Linux
stub exists only with one.
2026-10-18 19:09:46 +02:00
Adrià f890e21a81 Merge pull request #6111 from Kernel-Hunter/fix/rosetta-rdtscp-processor
fix(relinker): report processor 0 from RDTSCP under --to-rosetta
2026-10-18 19:00:12 +02:00
Adrià aff1f7190d Merge pull request #6102 from DavidSamir/fix/relinker-trap-windows-guest-gs
fix(relinker): trap guest GS accesses in Windows output instead of refusing the module
2026-10-18 18:29:03 +02:00
Karim Masmoudi 57e52c1f03 fix(relinker): report processor 0 from RDTSCP under --to-rosetta
Rosetta sets RDTSCP's ECX to its constant TSC_AUX, 0xAAAAAAAB, which is
not a processor index. --to-rosetta already makes RDPID return processor
0 for the same reason, so code reading the processor through RDTSCP saw
a different value from code reading it through RDPID.

--to-rosetta now moves RDTSCP into an optional stub that runs the
instruction unchanged and then loads 0 into ECX with a MOV, which
leaves the counter in EDX:EAX and the flags as they were. A site with no
movable instruction after it for the jump is kept, as for RDPID. The
Intel target and a plain relink are unchanged.
2026-10-18 18:27:15 +02:00
Adrià e00260b6b3 Merge pull request #5994 from Get-fix/ps4/sce-module-code-extent
fix(relinker): stop module syscall scans at the PLT and skip the PS4 loader path
2026-10-18 16:45:24 +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
Dean 5b7ec4a9bd Merge pull request #7272 from OskarLGS/fix/relinker-decoder-osize-branches
fix(relinker): decode near branches with an operand-size prefix as AM…
2026-10-18 12:56:40 +13:00
oskarlgsandClaude Opus 5.5 206aaa56cb fix(relinker): decode near branches with an operand-size prefix as AMD does
66 E8, 66 E9 and 66 0F 80-8F without REX.W take a 16-bit displacement on
AMD processors, the console included. Every near relative branch with that
prefix truncates its target to 16 bits, so the decoder reports no branch
target for it and stubs refuse to move it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016TFMtUC4L4wMS4eeEqaNSR
2026-10-17 20:58:29 +00:00
Destroyers212xandClaude Opus 5.5 10c1c24cea docs(relinker): record Rosetta instruction support on an M1 with macOS 26.6.2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 11:22:28 -04:00
javierUDP b38f146ce6 docs(relinker): record what Rosetta executes on an M5
The Rosetta conversion limits were measured on an M1 running macOS 15.3.1
and an M5 Max. A survey on an M5 running macOS 26.4 executes ANDN, RDRAND,
the rest of BMI1 and BMI2, LZCNT, PREFETCHW, CLFLUSHOPT, AVX, AVX2, FMA,
F16C and MOVBE while CPUID reports none of them, and raises an illegal
instruction for RDSEED, CLWB, RDPID, ADCX and ADOX.
2026-10-17 10:31:23 -03:00
inmert f91e53d595 fix(relinker): list libc.prx with libkernel.prx in macOS executables 2026-10-17 14:06:01 +05:30
SandstromPLandClaude Opus 5.5 051dac94ee fix(relinker): find the PLT before the code in PS4 modules
FindSceCodeEnd looked for the PLT only after the last function of the
unwind table and failed with "PLT not found after the last unwind
function" otherwise. The libSceFios2.prx and libc.prx that Until Dawn
(CUSA02636) bundles have their PLT at 0xc8, at the start of the text
segment, before the code. In both, the last unwind function is
followed by the module's DT_FINI routine, which has no unwind entry,
and then by read-only data.

When no PLT follows the last unwind function, the search now also looks
before it. A PLT found there must not overlap an unwind function, and
the code extent then ends at the last unwind function, so what follows
it stays out of the scans and the code analysis, including code
without an unwind entry such as the DT_FINI routine of both modules
(recorded in the debt file). A missing PLT now fails with "PLT not
found before or after the unwind functions".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:43:51 +05:30
HILAL El MehdiandClaude Opus 5.5 2a9390aa11 docs(debt): correct Windows GUI logging description
Since ab3e92605 the entry stub gives each missing standard handle
anyps5.log beside the executable, and the crash report writes to the
standard error handle, so it reaches the log too. The entry now records
only what is still lost: the stub's errors about the executable path or
about waiting for the previous LoadExec process, written before the log
is opened, and output to the missing handles when the log cannot be
created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0154rPujpieMaCnZ6WMobg7M
2026-10-15 21:39:42 +02:00
Get-fix 8c34587598 fix(relinker): search libc.prx for libkernel-only Windows executables
AnyPS5 exports some libkernel functions, such as __error, from
libc.prx, which libkernel.prx links. On Linux they resolve through that
dependency. On Windows, the import stubs search only the listed
modules, and libc.prx was listed only when libSceLibcInternal.prx was
needed. A PS4 homebrew that needs libkernel.prx but no C library (the
OpenOrbis graphics sample) failed with "unresolved ELF import
9BcDykPmo1I". libc.prx is now also listed when libkernel.prx is needed.
PS5 executables need libSceLibcInternal.prx and convert unchanged.
2026-10-15 21:02:31 +03:00
Adrià 3bb409b603 Merge pull request #5784 from gguerra26/fix/macos-m1-andn
fix(relinker): lower ANDN in Rosetta conversion
2026-10-15 19:25:06 +02:00
Adrià 5c0cc1bba4 Merge pull request #5755 from AlexOfTheForest/fix/decoder-rip-far-indirect
fix(relinker): report RIP-relative operands of far indirect CALL and JMP
2026-10-15 15:58:16 +02:00
gguerra26 9b92c55edf fix(relinker): lower ANDN in Rosetta conversion 2026-10-15 15:00:43 +02:00
Adrià 7bb2b1f973 Merge pull request #5598 from JJenkx/fix/guest-declared-host-import-registry
fix(relinker): record declared host imports in guest registries
2026-10-15 13:58:59 +02:00
aaroandCodex 5054b67b42 fix(relinker): preserve inputs behind Windows executable hard links
Co-authored-by: Codex <noreply@openai.com>
2026-10-15 17:23:14 +05:30
JJenkx d94000a096 fix(relinker): load guest providers used by executable imports 2026-10-15 01:40:33 -04:00
David 84f72fc057 docs(debt): record that guest GS accesses trap in Windows output 2026-10-15 01:57:53 +04:00
Get-fix 8997cac1b8 fix(relinker): stop module syscall scans at the PLT and skip the PS4 loader path
OpenOrbis modules keep read-only data after their code, as executables
do. The syscall scan of sce_module modules decoded it, and the module of
the OpenOrbis library sample (libExample.prx) failed with "Forbidden
syscall instruction". For modules with a PT_SCE_DYNLIBDATA segment, the
scan now stops at the end of the PLT after the last unwind function,
found by FindSceCodeEnd as for executables.

The same modules begin their executable segment with the
/libexec/ld-elf.so.1 string but have no PT_INTERP header, so code
analysis decoded the string and failed with "Unsupported Windows guest
TLS instruction (bytes: 64 2d 65 6c 66 2e)", which is the text "d-elf.".
When no PT_INTERP header covers the start of a PS4 code segment, code
analysis now starts after that exact string.
2026-10-14 20:52:02 +03:00
Alexej Szpevák 8e812f4b73 fix(relinker): report RIP-relative operands of far indirect CALL and JMP
DecodeInstruction returned before reading the ModRM of FF /3 and FF /5,
so a far CALL or JMP through a RIP-relative pointer had no RIP-relative
displacement. A stub that moved such a JMP copied the displacement
without relocating it.

The decoder was compared with iced-x86 (AMD decoding) over 3.99 million
encodings: every opcode of the legacy, 0F, 0F38 and 0F3A maps under 34
prefix combinations and the VEX 0F, 0F38 and 0F3A maps, each with 48
ModRM forms. Apart from this, it agrees on length, RIP-relative offset,
control flow kind and branch target for every valid Zen 2 instruction
except near branches with a 66 prefix, recorded as technical debt, and
kernel-only returns, which it treats as sequential.

Add the comparison's metadata as cases: one RIP-relative encoding per
opcode, map and immediate size, every FF /r form, and the branch forms
with their flow kind and target. The existing cases check lengths only;
a loop or jrcxz decoded as an unconditional jump passed the whole suite.
2026-10-14 11:33:59 +02:00
JJenkx 48685f40e1 Merge remote-tracking branch 'origin/main' into fix/guest-declared-host-import-registry
# Conflicts:
#	docs/dev/debt/relinker.md
2026-10-14 01:25:14 -04:00
Dean 75690a117e Merge pull request #4237 from MarcZX100/codex/carry-fixed-base-3043
fix(relinker): load Windows executables at a fixed low base
2026-10-14 17:49:45 +13:00
Dean Galvin bf6b6c0a17 docs(relinker): describe fixed-base default for Windows executables 2026-10-14 17:39:48 +13:00
Dean f5cda839ec Merge pull request #4717 from Ondra97/codex/fix-relro-unused-filter
fix(relinker): map standalone RELRO in unused import filtering
2026-10-14 16:05:01 +13:00
Dean d1b3aa1372 Merge pull request #5195 from SandstromPL/fix/relinker-sce-code-analysis-extent
fix(relinker): keep code analysis inside the code extent of PS4 executables
2026-10-14 15:49:02 +13:00
JJenkx 4414bca721 docs(relinker): separate registry debt from startup and alias entries 2026-10-13 20:35:37 -04:00
JJenkx 2f7b33521f Merge commit '30f961266ade83b41d5c9de7dec1393e7fcecfb7' into fix/guest-declared-host-import-registry 2026-10-13 18:59:59 -04:00
Leandro Soares e5c782c54f fix(relinker): load converted Windows executables at a fixed low base 2026-10-13 19:11:54 +00: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
SandstromPLandClaude Opus 5.5 78f620cf9e fix(relinker): keep code analysis inside the code extent of PS4 executables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:10:51 +05:30
Ondra97 bde680c855 fix(relinker): map standalone RELRO in unused import filtering 2026-10-13 11:19:36 +02:00
JJenkx d6728f4e51 fix(relinker): record declared host imports in guest registries 2026-10-12 20:05:34 -04:00
LeandroLP23andClaude Opus 5.5 3e3b0a27ca docs(debt): mention --windows-gui and its lost output on the console entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:02:32 +02:00
Adrià FranchandClaude 342a8c4590 docs(debt): move library entries to one file per library
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 20:38:29 +02:00