Commit Graph
200 Commits
Author SHA1 Message Date
Dean 3288b21f88 Merge pull request #15370 from oneandonlydean/fix/windows-deferred-dependency-start
fix(relinker): restore the Windows deferral of #12621 and start deferred dependencies first
2026-11-05 08:18:30 +13:00
Dean 18a6629e2d Merge pull request #10662 from shurhundo/fix/linux-relro-enforcement
fix(relinker): emit PT_GNU_RELRO for Linux output instead of leaving RELRO writable
2026-11-05 06:35:23 +13:00
Dean 0c31a0e326 Merge pull request #11432 from muhmuhkuh/codex/windows-executable-exports
fix(relinker): export Windows executable symbols
2026-11-04 18:33:35 +13:00
Dean Galvin 065c29f6c9 docs(relinker): the deferred sweep is best effort 2026-11-04 03:35:57 +13:00
Dean Galvin 29178b2917 fix(relinker): start the deferred modules others depend on at the first load of any deferred module
A deferred module that only another deferred module names (PSNCommon, needed by
PSNCore) started after the plugins that use it (SPFXUnityPlugin) and crashed
Soul Hackers 2 on Windows. The first title load of any deferred module now starts
every deferred module some module depends on, in dependency order, with that
load's start arguments, and logs the sweep. Boot is unchanged.
2026-11-04 03:29:14 +13:00
Dean Galvin 83a287cb2f docs(relinker): say the deferred dependency start is transitive 2026-11-04 02:39:30 +13:00
Dean Galvin 62aec71ad8 fix(relinker): start what a deferred module the executable needs depends on, and log each deferred start
On Windows a module the executable needs or imports from stays deferred, but its
dependencies were deferred too and started only when the title loads it, so a title
that calls it first ran them uninitialised (Soul Hackers 2, #15370 rerun). They start
at startup again, as on main. The loader prints one line per deferred start.
2026-11-04 02:36:53 +13:00
Dean Galvin f17fd26885 Merge commit '4f41f4c375f5abb487dbd184fbc150f31994d762' into HEAD
# Conflicts:
#	docs/dev/debt/relinker.md
2026-11-03 21:17:37 +13:00
Dean 7af9b1c691 Merge pull request #14139 from JJenkx/fix/relinker-absent-unused-dependency
fix(relinker): optionally leave out a module dependency nothing provides or imports from on Linux
2026-11-03 21:08:25 +13:00
Dean fffa45ebe5 Merge pull request #14855 from ken00H/fix/relinker-windows-entry-stub-parent-log
fix(relinker): wait for the LoadExec parent after opening the Windows log
2026-11-03 18:10:38 +13:00
Dean Galvin 2cdb4d40d4 fix(relinker): start a deferred module's deferred dependencies before it on Windows
Since #12621 a Windows runtime module that another runtime module needs is deferred instead of started at boot, but loading a deferred module only started that module. A Unity plugin such as SPFXUnityPlugin that calls into a deferred module it needs (Il2CppUserAssemblies in Media/Modules) ran against code whose initializers had never run, and PPSA03743 crashed about 2.6 s in.

A deferred module's initialization table now lists the deferred modules it depends on (names, after the initializer array, behind a magic number so older output reads as having none). DynamicLoader starts those first, transitively and once each through the existing per-module state, with the start arguments of the load that began it, then starts the module itself. The module start result stays the module's own. Boot still starts no deferred module.

Linux is unchanged: its deferred modules still start only when loaded.
2026-11-03 16:03:33 +13:00
Dean 4c54ba9bfa Merge pull request #14442 from Serph91P/fix/14423-linux-trace-permissions
fix(relinker): preserve Linux import tracing execute permissions
2026-11-03 11:36:27 +13:00
Dean b2627ce36d Merge pull request #13291 from PolkadotDom/fix/eip-import-call-sites
fix(relinker): resolve EIP-relative import call sites
2026-11-03 08:45:32 +13:00
Dean b9d18dc1f9 Merge pull request #12951 from Kikoarl/fix/relinker-rip-displacement-overflow-guard
fix(relinker): guard 64-bit rip-relative displacement overflow and underflow
2026-11-03 06:25:52 +13:00
dom 21a7616cda chore(relinker): refresh EIP import analysis after prerequisite merge 2026-11-02 10:53:33 -05:00
Dean 8d530b6d3c Merge pull request #11883 from roboterspinne/fix/relinker-macos-gs-trap-entry-roots
fix(relinker): refuse GS traps that overwrite a code entry point in macOS output
2026-11-03 01:27:44 +13:00
Dean 8b9ae2fa8c Merge pull request #11626 from Mherberts/codex/fix-segment-prefixed-import-sites
fix(relinker): recognize ignored segment prefixes in import sites
2026-11-03 01:26:05 +13:00
Dean 718204e587 Merge pull request #11487 from roboterspinne/fix/relinker-linux-congruent-loads
fix(relinker): move a Linux PT_LOAD whose file offset is not page-congruent with its address
2026-11-02 23:28:40 +13:00
Dean da0f097c78 Merge pull request #11107 from AdnanKhan-ak47/feat/relinker-lower-bzhi-bextr
feat(relinker): lower BZHI and BEXTR under --to-rosetta
2026-11-02 23:26:58 +13:00
Dean 36564b6b4f Merge pull request #10970 from AdnanKhan-ak47/feat/relinker-lower-bls
feat(relinker): lower BLSI, BLSMSK and BLSR under --to-rosetta
2026-11-02 23:26:20 +13:00
Dean 2a9de0ea82 Merge pull request #10495 from wail-arch/fix/linux-guest-zero-address-exports
fix(relinker): bind guest function exports at address 0 on Linux
2026-11-02 23:22:55 +13:00
ken00H 9f49b1422d fix(relinker): wait for the LoadExec parent after opening the Windows log 2026-11-01 23:32:59 +03:00
Serph91P bb60acdde6 fix(relinker): preserve execute permissions when tracing Linux imports
Derive traced slot page protections from the final output LOAD layout, including normalized overlaps and host page rounding. Keep data pages non-executable and retain execute on shared code and flagless LOAD pages.

Add native permission and hook regressions for default, explicit and above-4-GiB fixed bases.

Fixes #14423
2026-11-01 13:36:51 +00:00
roboterspinne 94e4031147 fix(relinker): keep a moved Linux PT_LOAD's alignment on the header block
Moving a PT_LOAD to the end of the file sets its p_align to
min(p_align, 0x1000), since the copy honours only the page. When that
segment carried the largest p_align, the output's largest PT_LOAD
alignment, which Linux uses to align the ET_DYN load bias, fell with
it. SeparateSharedLoadPages now returns the largest power-of-two
p_align above the page that it lowered, and WriteLayout aligns the
header block PT_LOAD to at least that value, as it already does for
the largest kept p_align.
2026-11-01 09:37:04 +01:00
Kai Laue f2d7e367a7 fix(relinker): pin the __syscall6 syscall numbers instead of masking them
Review feedback: the three mount-family patterns now carry their exact numbers (21, 378, 22) like the mman patterns, so a stub with another number is not matched. The fixture check that changed only the masked bytes could not fail for the unmount fixture, whose number is also 22; it now rewrites the number field to 0, 1, 21, 22 and 378 and requires every other number to be rejected. Technical debt says the numbers are pinned.
2026-11-01 01:17:20 +01:00
Kai Laue 537c76fc9b fix(relinker): trap the inlined SDK __syscall6 stubs
Recognize the inlined __syscall6 wrappers of ps5-payload-dev SDK libc/mount.c (mount, nmount, unmount) under --trap-sdk-syscall-stubs, with the four-byte syscall number immediate masked so an SDK build that renumbers the call still matches. The three wrappers differ in argument preparation, so each sequence is matched separately.

Observed in ftpsrv v0.21.1 (0x709a, 0x70ec, 0x713c) and websrv v0.35 (0xae6a, 0xaebc, 0xaf0c). Related: issue #8624, open draft PR #8729 covers mount only.
2026-11-01 01:17:20 +01:00
JJenkxandClaude Opus 5.5 5461bdff9c fix(relinker): match imports by module and leave unavailable dependencies out only on request
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 18:52:32 -04:00
PROGABBOMALA 6a82825008 fix(relinker): restrict lea roots to unwind reachability (#7547) 2026-10-31 22:35:11 +01:00
PROGABBOMALA b8fc47fd47 fix(relinker): recognize indirect lea roots and restore gap data skip (#7547) 2026-10-31 21:29:39 +01:00
JJenkxandClaude Opus 5.5 e129780e16 fix(relinker): leave out a module dependency nothing provides or imports from on Linux
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 16:29:16 -04:00
PROGABBOMALA 0218b3529d fix(relinker): reject dynamic syscalls in indirect routines with unwind ranges (#7547) 2026-10-31 13:33:05 +01:00
shurhundo 79a91f942c fix(relinker): align the multi-RELRO rejection message and tests with its actual scope 2026-10-31 16:18:42 +08:00
shurhundo 4d860f8882 docs(relinker): record the RELRO gap on Windows, macOS and lazy-binding Linux 2026-10-31 15:47:57 +08:00
shurhundo 22b1ed2e9b fix(relinker): reject multiple disjoint RELRO ranges on Linux output
MarcZX10 found that this branch's RELRO fix doesn't hold when the
original image has more than one disjoint PT_SCE_RELRO range: ElfReader
retypes each one into its own PT_GNU_RELRO header, but glibc's loader
only tracks one PT_GNU_RELRO segment per image, so a later entry
silently overwrites the earlier one in the loader's state and only the
last range actually ends up protected. LLD's own linker has the same
one-segment assumption. Widening a single range to span the gap
between them isn't a safe fix either, since it would also protect
memory that was never part of any RELRO range.

Until a title is found that actually needs more than one disjoint
range, the program header layout builder now throws a clear error
instead of silently protecting only one of them.

Tested: two new program_layout_ranges cases (a single RELRO range
still reserves its header slot; two disjoint ranges are rejected).
Full relinker-only ctest suite: 245/246 pass, the one failure
(input_magic) is the same pre-existing, unrelated ASan allocation
issue seen on this branch before this change. Verified by hand with a
real two-range fixture converted through the actual relinker binary:
the Linux target now exits 2 with a clear message and writes no
output file, instead of silently succeeding with only one range
protected. check_conventions.py and git diff --check both pass.
2026-10-31 15:46:45 +08:00
PROGABBOMALA 695e2ec3d5 fix(relinker): resolve code and data boundaries in syscall scanner (#7547) 2026-10-31 02:14:04 +01:00
muhmuhkuh 77cb5f907c fix(relinker): export Windows executable symbols 2026-10-30 20:16:33 +01:00
roboterspinne ffa036cbec Merge remote-tracking branch 'upstream/main' into fix/relinker-linux-congruent-loads
# Conflicts:
#	core/relinker/elfpatcher/tests/LinuxLoadPageTests.cpp
2026-10-30 16:23:11 +01:00
Kikoarl 7b5c7ef478 fix(relinker): guard 64-bit rip-relative displacement overflow and underflow 2026-10-30 13:11:22 +01:00
dom 653f3ad9c0 fix(relinker): compose EIP and segment-prefixed import sites 2026-10-30 07:58:40 -04:00
Adnan Khan 6ad23bffdd fix(relinker): restore an RSP destination in one load in the BZHI and BEXTR stub and list MULX as lowered 2026-10-30 12:55:03 +05:30
Adnan Khan 4ff00abf28 fix(relinker): restore an RSP destination in one load in the BLS stub and list MULX as lowered 2026-10-30 12:55:03 +05:30
Adnan Khan cf78130042 feat(relinker): lower BZHI and BEXTR under --to-rosetta 2026-10-30 12:55:03 +05:30
Adnan Khan 7f0b73575b fix(relinker): restore an RSP destination in one load in the shift stub, list MULX as lowered and drop the title note 2026-10-30 12:55:03 +05:30
Adnan Khan bc6710735a docs(relinker): record the shift lowering 2026-10-30 12:55:03 +05:30
Adnan Khan 96ccdc3bed test(relinker): relink BLSR, BLSMSK and BLSI through the CLI and record the BLS lowering caveats 2026-10-30 12:55:02 +05:30
Adnan Khan 42a65719cb docs(relinker): record the BLS lowering 2026-10-30 12:55:02 +05:30
Adrià 389563fdf7 Merge pull request #12591 from tablefrogpillow/fix/ptload-congruent-overlap
fix(relinker): accept byte-congruent PT_LOAD overlaps by trimming the earlier segment
2026-10-30 07:41:25 +01:00
Adrià 064c6bb320 Merge pull request #12430 from akkadbakkad89/fix/windows-kernel-family-fallback
fix(relinker): resolve kernel-family exports for libkernel-declared imports
2026-10-30 06:54:36 +01:00
Adrià 47e0293303 Merge pull request #12857 from slopgobblercobbler/fix/relinker-dynamic-hash-bounds
fix(relinker): validate SysV and GNU dynamic symbol hash table bounds
2026-10-30 06:35:58 +01:00
Adrià 8324dbb30a fix(relinker): test earlier bss over non-zero later file bytes and state the protection gap first in the debt entry 2026-10-29 23:24:44 +01:00