Commit Graph

443 Commits

Author SHA1 Message Date
Dean 71c3dbb722
Merge pull request #4190 from ArchitDewan/fix/relinker-empty-path
fix(relinker): reject empty positional paths
2026-10-13 01:29:30 +13:00
Dean f8dee05957
Merge pull request #4091 from jweidenh/codex/guest-noop-relocations
fix(relinker): ignore no-op relocations in guest modules
2026-10-13 01:27:26 +13:00
Dean 253ec3ffee
Merge pull request #4084 from hawwwwwk/pr/relinker-suprx-guest-alias-current
fix(relinker): resolve .suprx guest module aliases
2026-10-13 01:27:08 +13:00
Dean a46ffb5e75
Merge pull request #4066 from hawwwwwk/pr/relinker-ff-callsite-current
fix(relinker): filter non-reference RIP-relative FF operations
2026-10-13 01:25:57 +13:00
Dean c99cc11cf5
Merge pull request #4194 from fable-void/pr/rosetta-store-split
feat(relinker): split unaligned 256-bit stores for Rosetta
2026-10-13 01:22:45 +13:00
Dean 4d5fcef15b
Merge pull request #4203 from saxopa/fix/relinker-relative-section-symbol
fix(relinker): accept RELATIVE relocations against a zero-value section symbol
2026-10-13 01:21:34 +13:00
Dean 8b06e64176
Merge pull request #3854 from aryan0078/fix/relinker-debug-module
fix(relinker): resolve debug PRX dependencies by module identity
2026-10-12 20:27:31 +13:00
Dean 5161070e67
Merge pull request #4273 from poonasor/fix/relinker-move-tls-branch-from-short-access
fix(relinker): move a short guest TLS access's follower branch into its stub
2026-10-12 20:26:47 +13:00
Dean 66ab8753bf
Merge pull request #3780 from MrMha/fix/unwind-record-bounds
fix(relinker): validate file-backed unwind record ranges
2026-10-12 17:35:37 +13:00
poonasor c6f934a3d0 fix(relinker): move a short guest TLS access's follower branch into its stub
A short fs-prefixed TLS access is patched with a 5-byte jump by
relocating the following instructions into the stub, but any branch
there was rejected outright. NHL 27 hits this on every stack-protector
epilogue: fs:xor rax,[rbx] immediately followed by jne __stack_chk_fail.

Allow relative conditional branches and short jumps: re-encode rel8
forms as their rel32 equivalents, rebase the displacement when the
stub is emitted, and keep rejecting loop/jrcxz, calls, returns, and
segment-prefixed followers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 23:44:54 -04:00
Dean 26d87eec20
Merge pull request #3850 from SandstromPL/fix/relinker-module-dir-root
fix(relinker): accept the input's directory as a module directory
2026-10-12 16:07:27 +13:00
fablevoid c763a78b67 feat(relinker): split unaligned 256-bit stores for Rosetta
Rosetta 2 ends the process when an unaligned 256-bit store crosses into
a page the store may not write ("rosetta error: unexpectedly need to
EmulateForward on a synchronous exception") instead of raising the
fault. A store inside such a page, and a 128-bit store across one,
fault normally. The macOS write watch keeps watched pages read-only
between collections, so a guest that stores 32 bytes across the start
of a watched page ends the process.

--to-rosetta now lowers VMOVUPS, VMOVUPD and VMOVDQU with a 256-bit
memory destination to a stub that stores the low half with the same
instruction at VEX.L=0 and the high half with VEXTRACTF128 at the
operand plus 16, so each half faults like any other store. RIP-relative
operands are relocated from the instruction's place in the site. A
store whose upper half has no 32-bit displacement fails the conversion.
Aligned stores (VMOVAPS, VMOVAPD, VMOVDQA and the non-temporal forms)
cannot cross a page and are left alone.

Every store is lowered. A 4-byte store has no room for the jump to its
stub, so its stub also takes one neighbouring instruction. The
following one: a return ends the stub, a call pushes its original
return address and jumps, a jump or conditional branch is re-encoded
with a 32-bit displacement, and another 256-bit store is lowered in the
same stub. Otherwise the preceding one, unless it is a call, a jump, a
return or a trap. Register calls, LOOP, JRCXZ and branches with a
prefix that changes them do not move. When neither neighbour can move,
the store becomes a short jump to an island: a run of movable
instructions within reach is moved to its own stub, and the bytes it
frees hold the jump to the store's stub. A store with neither fails the
conversion.

The converter tests compare the halves with clang's encodings for base,
SIB, disp8 overflowing to disp32, disp32, RSP-relative, FS-absolute,
r13-based and RIP-relative operands, and check that aligned stores,
loads, register forms and masked stores are not split. They check the
stub of a short store followed by a return, a call (direct, with an
address-size prefix, and through a RIP-relative pointer), short, near
and RIP-relative jumps, short and near conditional branches and another
store; that a following register call, LOOP, JRCXZ, prefixed branch or
CLWB makes the store take the instruction before it; islands past
instructions already moved, a store that needs its own stub, a branch
target, a register call and the short-jump reach; and that a store with
no room fails.

PPSA12544: 55295 stores split in the executable, 278 of them in the
stub of the store before them; every module converts with none kept.

AI-assisted: yes
2026-10-12 02:48:33 +00:00
Dean 2263cefe25
Merge pull request #3601 from Scramblrrrr/codex/legacy-sse-reciprocals
fix(relinker): lower legacy packed reciprocal register instructions
2026-10-12 15:43:20 +13:00
saxopa cded9ba8c3 fix(relinker): accept RELATIVE relocations against a zero-value section symbol
OpenOrbis create-fself adds one to the symbol index of every relocation it
copies from .rela.dyn, so each R_X86_64_RELATIVE entry of a homebrew built
with the OpenOrbis toolchain names symbol 1, a local STT_SECTION symbol with
value 0. FreeBSD rtld computes RELATIVE as base + addend without reading the
symbol. The pipeline, the code analysis and the strict filter now accept
index 0 or a STT_SECTION symbol with value 0, and still throw for any other
symbol. The relocation is written with symbol index 0, where the pipeline
previously dropped RELATIVE entries with a nonzero index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 03:12:02 +02:00
Archit Dewan 5eb22de16d fix(relinker): reject empty positional paths 2026-10-11 20:28:56 -04:00
jweidenh 72d5b8ce90 fix(relinker): ignore no-op relocations in guest modules 2026-10-11 19:02:06 -04:00
ethan 0a324d8ccb fix(relinker): resolve .suprx guest module aliases 2026-10-11 15:45:27 -07:00
ethan 409f53eaed fix(relinker): filter non-reference RIP-relative FF operations 2026-10-11 15:24:53 -07:00
MrMha 3687b2e214 perf(relinker): use a flat sorted call-site index 2026-10-12 00:11:00 +02:00
Aryan singh 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
Aryan singh d3fc14a50c fix(relinker): resolve debug PRX dependencies by module identity 2026-10-12 03:38:07 +05:30
Adrià 66e87807d5
Merge pull request #3804 from MarcZX100/codex/relinker-trap-sdk-syscalls-2136
feat(relinker): trap exact SDK syscall stubs on request
2026-10-12 00:05:38 +02:00
Adrià 3929c21fb9
Merge pull request #3782 from MrMha/fix/rewrite-instruction-boundaries
fix(codegen): reject rewrites inside instructions
2026-10-12 00:01:46 +02:00
Adrià 6566c9c8c6
Merge pull request #3784 from MrMha/fix/param-json-utf8
fix(libkernel): reject malformed UTF-8 in param JSON
2026-10-12 00:01:32 +02:00
Adrià bb48d60fc6
Merge pull request #3774 from MrMha/fix/program-layout-ranges
fix(relinker): validate program layout ranges before writing
2026-10-12 00:00:46 +02:00
Adrià 7ee8992714
Merge pull request #3776 from MrMha/fix/section-header-ranges
fix(relinker): validate complete allocated section ranges
2026-10-12 00:00:39 +02:00
Adrià 05c2509c61
Merge pull request #3678 from Ondra97/codex/relinker-desktop-input-preservation
fix(relinker): preserve inputs when writing desktop assets
2026-10-11 23:49:58 +02:00
Adrià 50d3f0691f
Merge pull request #3529 from oguzhanozfe/codex/windows-identical-function-export-aliases
fix(relinker): allow identical Windows function export aliases
2026-10-11 23:41:27 +02:00
Adrià da07b30b26
Merge pull request #3589 from MrMha/fix/relinker-elf-reader-validation
fix(relinker): validate ELF section tables and file mappings
2026-10-11 23:39:02 +02:00
Adrià 2ebe73da53
Merge pull request #3543 from Lorkydey/fix/relinker-none-relocations
fix(relinker): ignore no-op executable relocations
2026-10-11 23:32:26 +02:00
MrMha 3742fa136e test(relinker): cover extra block bounds and header address overflow 2026-10-11 23:11:42 +04:00
MrMha 5740cd6c20 fix(build): separate UTF-8 and control-flow test registration 2026-10-11 22:52:58 +04:00
SandstromPL 7f0c5d9d4d fix(relinker): accept the input's directory as a module directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 23:21:34 +05:30
lorkydey 329b9d63bb fix(relinker): normalize additional module directory paths 2026-10-11 19:12:52 +02:00
MarcZX100 0a6247532e feat(relinker): trap exact SDK syscall stubs on request 2026-10-11 16:54:02 +00:00
MrMha 474c2b9ff1 fix(libkernel): reject malformed UTF-8 in param JSON 2026-10-11 19:56:55 +04:00
MrMha e5c280fed4 fix(codegen): reject rewrites inside instructions 2026-10-11 19:56:00 +04:00
MrMha b443760ca4 fix(relinker): validate file-backed unwind record ranges 2026-10-11 19:55:09 +04:00
MrMha 653eb704c2 fix(relinker): validate complete allocated section ranges 2026-10-11 19:52:18 +04:00
MrMha d85d1c268f fix(relinker): validate program layout ranges before writing 2026-10-11 19:51:17 +04:00
Ondra97 1f34f6e8d4 fix(relinker): preserve inputs when writing desktop assets 2026-10-11 17:11:26 +02:00
Adrià Franch a1d11ba4a2 test(relinker): drop unregistered evidence script for export aliases
The script needs a stock and a patched converter binary as arguments and is not
run by ctest; the C++ test covers the same cases.
2026-10-11 16:43:10 +02:00
Oguzhan Ozdemir 5ea9ce2e40 fix(relinker): allow identical Windows function export aliases 2026-10-11 16:43:07 +02:00
Scramblrrrr 363d17985e fix(relinker): lower legacy packed reciprocal register instructions 2026-10-11 10:58:14 -03:00
MrMha 2eed99e770 fix(relinker): validate ELF section tables and file mappings 2026-10-11 17:47:50 +04:00
lorkydey cb9932007a fix(relinker): ignore no-op executable relocations 2026-10-11 14:53:59 +02:00
Adrià 03708282b3
Merge pull request #3495 from Lorkydey/fix/relinker-registry-input-preservation
fix(relinker): preserve input binaries when writing registries
2026-10-11 13:56:53 +02:00
lorkydey 0cfdc79e59 fix(relinker): preserve input binaries when writing registries 2026-10-11 13:38:27 +02:00
fablevoid 1b865fc3ea fix(relinker): pass module start arguments to macOS guest initializers
The macOS image initializer called a guest module's DT_INIT with no
arguments, so a module started with sceKernelLoadStartModule never saw
its args and argp, and its result was dropped. The Linux writer already
calls DT_INIT through libkernel's pending argument handoff. On the
macOS port, the PSN plugin of PPSA12544 refuses to start without its
argument block ("PSN is an old version that cannot be used by the
current player runtime") and the title then crashes.

A guest module with DT_INIT now gets two slots bound to
__aps5_get_pending_module_args_nid_no_patch and
__aps5_set_module_init_result_nid_no_patch, and its initializer calls
DT_INIT with the args and argp that sceKernelLoadStartModule records,
as on Linux, then hands the result back. The TechnicalDebt sentence
about the missing arguments on macOS is removed.

guest_module_args also relinks its fixture with --macos and checks the
two binds; on x86-64 macOS it loads the module and checks that DT_INIT
receives the arguments and that its result is returned.

AI-assisted: yes
2026-10-11 11:22:38 +00:00
Adrià Franch 33a1ca5d33 fix(relinker): skip the desktop entry for macOS output and use native paths
The Linux desktop entry was written for every non-Windows output, macOS
included since --macos landed. It is now written only for Linux output,
and its paths go through Io::NativePath/Utf8Path like the rest of the
relinker. An end-to-end test relinks for Linux, macOS and Windows.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-11 12:55:22 +02:00