Commit Graph
302 Commits
Author SHA1 Message Date
Dean 44661db263 Merge pull request #8973 from rooklz/fix/linux-console-base
fix(relinker): load Linux executables at 0x400000 by default
2026-10-22 15:24:38 +13:00
Rookie 123ba70839 fix(relinker): load Linux executables at 0x400000 by default 2026-10-21 19:25:33 +01:00
MarcZX10 7fdad075c3 fix(relinker): include libc for kernel variant imports 2026-10-21 05:47:33 +00:00
MarcZX10 0d0b29cf44 test(relinker): require libc for kernel variant fallback 2026-10-21 05:47:05 +00:00
MarcZX10 fef2755c76 test(relinker): cover scoped kernel variant imports 2026-10-21 03:42:04 +00:00
MarcZX10 7b07c20497 fix(relinker): resolve kernel variant imports via canonical kernel 2026-10-21 03:42:04 +00:00
Dean 46bfbe4e25 Merge pull request #8063 from AasishDairelSahayaGrinspan/fix/relinker-gs-memory-only-traps
fix(relinker): trap only GS memory accesses in Windows and macOS output
2026-10-21 16:35:25 +13:00
Dean Galvin 143ed02750 Merge branch 'main' into #7417
Resolve docs/dev/debt/libc.md: keep main's _Throw_Cpp_error entry and this branch's call tracing entry.
2026-10-21 06:33:59 +13:00
Dean 892a4f1328 Merge pull request #7993 from MarrasFederico/fix/relinker-windows-trampoline-builder-guards
fix(relinker): validate Windows trampoline section placement and sites
2026-10-21 06:30:55 +13:00
Dean 2fee39f1b3 Merge pull request #6684 from SandstromPL/fix/relinker-guest-zero-init
fix(relinker): run a guest DT_INIT of 0 as the module initializer
2026-10-21 06:07:25 +13:00
Dean 1b08a33b12 Merge pull request #8548 from tkcm01/fix/windows-icon-utf8-path
fix(relinker): format invalid Windows icon paths as UTF-8
2026-10-21 05:47:06 +13:00
Dean ab07854a58 Merge pull request #8166 from savvaniss/fix/sce-gap-syscall-data
fix(relinker): treat data between PS4 unwind functions as data in the syscall scan and the code roots
2026-10-21 05:17:04 +13:00
tkcm01 4d07bc0231 fix(relinker): format invalid Windows icon paths as UTF-8 2026-10-20 12:10:00 -04:00
Adrià 7d9372b77c Merge pull request #7740 from whamre/fix/windows-lazy-zero-fill-v2
fix(relinker): keep zero-filled PT_LOAD memory out of the Windows loa…
2026-10-20 15:41:27 +02:00
Savvanis SpyrosandClaude Opus 5.5 58a2a4962f fix(relinker): follow fs loads and report pointers taken as data between PS4 unwind functions
A relocation or lea target outside the unwind functions of a PS4 image
is now decoded up to its first jump, return or trap, or to the start of
the next unwind function, which also bounds the transfer check of the
tail rule. A target whose run holds an fs:[disp32] access, the form the
linear TLS sweep roots, is followed as code. The other targets taken as
data are counted in one message and kept as entry points that the
Windows TLS rewrite may not overwrite. The analysis merges nested
unwind ranges like the scans.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 15:48:42 +03:00
Adrià 3d54c5b2b2 Merge pull request #6448 from DavidSamir/fix/relinker-macos-empty-tls
fix(relinker): convert stack-guard and thread-pointer reads with an empty PT_TLS for macOS
2026-10-20 10:40:07 +02:00
aasishdairel 570c3297d3 fix(relinker): trap only GS memory accesses in Windows and macOS output 2026-10-20 10:13:34 +05:30
JJenkxandClaude Opus 5.5 92ea0b9ce3 test(relinker): wait for the exited diagnostic runner to release its fixtures
windows_dependency_diagnostics rewrites the fixture images right after the
diagnostic runner exits. The runner ends with an unhandled RaiseException of
STATUS_DLL_NOT_FOUND, and Windows fault handling keeps the exited process's
image files open for a short time after its handle is signaled: on Windows 11
22621 the Restart Manager names the exited runner as the holder and the file
opens 37 to 153 ms later. The rewrite then fails with ERROR_SHARING_VIOLATION,
and the final removal of the fixtures with access denied. Retry opening a
fixture while it fails with a sharing violation and the removal while it fails
with access denied, for at most 10 s each; every other failure still fails the
test at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:45:35 -04:00
Adrià 7e12b3da80 Merge pull request #7736 from jotitadev/fix/relinker-desktop-entry-test-unique-dir
test(relinker): give the desktop entry test its own temporary directory
2026-10-20 03:13:23 +02:00
Ishmam Ahmed 78634fb0a9 feat(relinker): support --trace-imports for Linux output
The Linux entry stub now passes each traced import through libc.prx's
TraceImport_nid_no_patch before it calls the guest entry, and stores the
returned thunk in the import's slot. The same imports are traced as on
Windows: functions bound through a PLT slot or a GOT slot, without an
addend, and not weak. TraceImport_nid_no_patch is bound eagerly through
an added GLOB_DAT relocation, so a libc.prx without it fails at load.
Each slot's page is made writable with mprotect first, so slots inside a
PT_GNU_RELRO range can be replaced.

--trace-imports now requires libc.prx among the libraries on Linux too,
and is refused with --macos.
2026-10-19 22:56:03 +01:00
Adrià ae7ad5ff98 Merge pull request #7361 from RockENZO/codex/macos-executable-exports
fix(relinker): preserve executable exports in macOS output
2026-10-19 20:41:17 +02:00
Adrià 48790e0233 Merge pull request #7039 from nabil88/fix/windows-libkernel-and-tests
feat(libkernel): implement getdtablesize and fix Windows host-tree removal
2026-10-19 19:36:18 +02:00
Federico Marras b336f0c4dc fix(relinker): validate Windows trampoline section placement and sites 2026-10-19 18:57:12 +02:00
Dean 7a015c0946 Merge pull request #7904 from mopga/fix/relinker-sort-guest-module-loads
fix(relinker): sort PT_LOAD entries of Linux guest modules by address
2026-10-20 05:54:46 +13:00
Adrià ee9bfe177e Merge pull request #6974 from HamidRezaLS/perf/relinker-tls-reachability-opt
perf(relinker): flat address-taken vector and region query caching in strict reachability
2026-10-19 17:53:17 +02:00
Dean 00d7e611ef Merge pull request #7363 from plokmklo/fix/relinker-gnu-stack-relro
fix(relinker): synthesise a non-executable PT_GNU_STACK for Linux executables
2026-10-20 03:52:18 +13:00
Dean 5eba12d6bd Merge pull request #7775 from whamre/fix/windows-tls-zero-fill
fix(relinker): keep the PT_TLS zero fill out of memory when converting to Windows
2026-10-20 02:23:39 +13:00
Dean 98024d4bce Merge pull request #7772 from fogydes/fix/relinker-section-header-table-overlap-and-bounds
fix(relinker): validate section header table bounds and reject overlapping sections
2026-10-20 02:23:11 +13:00
Dean 111f9eb6f2 Merge pull request #7771 from fogydes/fix/relinker-program-header-layout-extra-block-overlap
fix(relinker): reject program header table overlapping the extra block
2026-10-20 02:22:57 +13:00
Dean 1fad170b8b Merge pull request #7770 from fogydes/fix/relinker-windows-icon-resource-rva-and-overlap-guards
fix(relinker): validate resource section RVA and prevent section overlaps
2026-10-20 02:22:43 +13:00
Dean 7143c2acc8 Merge pull request #7763 from fogydes/fix/relinker-base-relocation-page-bounds-and-deduplication
fix(relinker): guard base relocations against page boundary overflow and deduplicate entries
2026-10-20 02:22:15 +13:00
UAQ Taxi 379dca5cac test: raise the slow-host timeouts 2026-10-19 14:49:36 +02:00
Hamidreza 186b2863ea perf(relinker): flat address-taken vector and region query caching in strict reachability 2026-10-19 14:40:17 +02:00
mopgobopotandClaude Opus 5.5 3f8184ae09 fix(relinker): sort PT_LOAD entries of Linux guest modules by address
The Linux executable sorts its PT_LOAD entries, but guest modules (*.guest.prx) kept them in the input table order. A module whose data segment comes before its text segment in the table was written with PT_LOAD entries out of address order, which the gABI forbids: glibc reserves the span from the first to the last entry, so with 0x2000, 0x1000, 0x4000 it reserved 0x2230 bytes instead of 0x3230 and mapped the text below the reservation. The PT_LOAD entries are now sorted in place, as for the executable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 15:40:05 +03:00
Adrià 0fa6ddb137 Merge pull request #6802 from DavidSamir/feat/relinker-macos-fixed-base
feat(relinker): place macOS executables at a fixed base with --macos-fixed-base
2026-10-19 12:54:31 +02:00
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
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à 4630318457 Merge pull request #6681 from milescoviello/fix/relinker-bss-page-overlap
fix(relinker): keep a segment's zero-filled tail zero when the next PT_LOAD starts on its page
2026-10-19 10:48:54 +02:00
Z User dd1e4b40de fix(relinker): include <cstddef> for std::size_t in ElfConstants.hpp
ProgramLayoutRangeTests.cpp includes this header first, and libc++ does
not provide size_t through <cstdint>, so the macOS relinker jobs failed
to compile the test.
2026-10-19 08:45:59 +00:00
David 35fe448155 feat(relinker): place macOS executables at a fixed base with --macos-fixed-base
Ruffle (PPSA68091), VLC (PPSA85300) and XPSemu (PPSA97358) read
app0/imports.txt, whose import slot addresses assume the executable's
lowest ELF load page at 0x400000, and dereference them at once. macOS
output always placed that page at 0x140010000, so all three fault on
their first slot read. Linux and Windows have --linux-fixed-base and
--windows-fixed-base for this; macOS had no equivalent.

--macos-fixed-base <address> builds the load image so that the lowest
ELF load page is at the address, as --windows-fixed-base does. The
Mach-O header takes the 64 KiB below it and __PAGEZERO ends there. The
executable is MH_EXECUTE without MH_PIE, so dyld does not slide it. The
address must be 64 KiB aligned, from 0x20000 through 0x7fffffff0000,
and an image ending past the macOS user address space is refused.
2026-10-19 10:32:30 +02:00
David 96e373f8ad refactor(relinker): take the macOS image base from the load image
WriteMacOsImage wrote the Windows ImageBase constant into the Mach-O
segment and section addresses, __PAGEZERO, the metadata load bias, the
TLS descriptors and the init pointer, while the relocations it rebases
were computed from the WindowsLoadImage base. Read the base from the
load image everywhere instead. Every caller still builds its image at
ImageBase, so the output is unchanged.
2026-10-19 10:32:17 +02:00
plokmklo c1866af79b fix(relinker): synthesize PT_GNU_STACK for Linux outputs without one
Outputs whose input carries no PT_GNU_STACK get one appended with
PF_R|PF_W and alignment 16 so the kernel does not fall back to an
executable stack marking.

RequiredProgramHeaderCount and WriteLayout now derive from one shared
header list, so the reserved slot and the written header cannot
disagree at any PhNum boundary, when a free input slot should be
reused, or when the RELRO coverage guard reduces the kept count.
Space exhaustion beyond the 16-bit header limit fails loudly instead
of silently skipping the header.
2026-10-19 07:30:56 +00:00
fogydes 5536aa8c0d fix(relinker): validate section header table bounds and reject overlapping sections 2026-10-19 12:22:43 +05:30
fogydes 93d3f89b51 fix(relinker): reject program header table overlapping the extra block 2026-10-19 12:21:35 +05:30
fogydes a7374e243e fix(relinker): validate resource section RVA and prevent section overlaps 2026-10-19 12:19:59 +05:30
fogydes f36bdeba2b fix(relinker): guard base relocations against page boundary overflow and deduplicate entries 2026-10-19 12:15:00 +05:30
Werner ea58c903b0 fix(relinker): keep the PT_TLS zero fill out of memory when converting to Windows
WindowsTlsBuilder allocated the whole TLS block and thread control block
for .gtls, so a large p_memsz cost that much memory even though only the
p_filesz template is written. Store the template and reserve the rest as
the section's virtual size; the TLS directory still covers the whole
block, which the loader copies from the zeroed image.
2026-10-19 06:39:49 +00:00
Werner 9babdd83fb fix(relinker): merge zero-filled Mach-O segments past the dyld segment limit
Backing only the pages a pointer touches splits a zero-filled run into
one section per backed block. Each becomes a Mach-O segment, and dyld's
bind and rebase opcodes address at most 16 segments, so a module with
pointer slots on many separate zero-filled pages converted on main but
failed with --macos. When the segments would pass that limit, adjacent
sections with the same protection are merged again, smallest gap first.

Reported by jotitadev in the review.
2026-10-19 05:55:26 +00:00
Werner d15c38b4de fix(relinker): compare page indices of one type when building Windows sections
dataEnd was a std::uint64_t and last a std::size_t, which are different
types on macOS, so std::min did not compile with Apple clang.
2026-10-19 05:22:58 +00:00
Jota 21325fba43 test(relinker): give the desktop entry test its own temporary directory 2026-10-19 04:51:37 +00:00