Repository navigation
feat(relinker): support fixed Windows guest image bases - #4140
Conversation
|
Ruffle runs with this on Windows. Windows 11 (26300), AMD Radeon 860M, WinLibs GCC 15.2.0, Release, head Tests: Ruffle (PPSA68091, catalog 1.2.0), 60 s runs:
The same holds with #3635 and #3980 also merged: the default relink faults, and the fixed base runs 60 s at about 55 FPS. The other two #4013 titles don't get far enough to show anything, even with #3635 and #3980:
Both stops are the same with and without the fixed base, so they say nothing about this PR. AI-assisted: yes (Claude Code) |
|
Rebased onto current |
d8f73c2 to
319fa57
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
What
Addresses the Windows side of #4013. Executables that read
imports.txtoffsets throughoffset + 0x400000fault because the relinker normally places their ELF image elsewhere.Add
--windows-fixed-base <address>to map the lowest ELF load page at a requested, 64 KiB-aligned address. For example:The PE headers occupy the preceding 64 KiB. Relative ELF pointers, TLS directory/template addresses and lazy-import GOT stubs use the selected image base. Fixed executables omit PE base relocations, clear
DYNAMIC_BASE, retainNX_COMPAT, and setRELOCS_STRIPPED, so a conflicting mapping fails to load. Invalid, unaligned or overflowing addresses throw. Bundled guest DLLs keep their normal placement; output without this option is unchanged. The option requires--windowsand does not implement fixed Linux or macOS placement.Tested
Windows 11 x64 (build 26100), WinLibs GCC 15.2.0 / MinGW-w64 14.0.0, Release relinker-only build with Python tests enabled.
cmake -S . -B build-relinker -G Ninja -DCMAKE_BUILD_TYPE=Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, thencmake --build build-relinker --parallel 4: passed.ctest --test-dir build-relinker --output-on-failure --parallel 4: 120/120 passed, 76.23 s total; no individual test exceeded 30 s.ET_SCE_DYNEXEC, a zero-basedPT_LOAD, and the reportedcmp QWORD PTR [rax+0x400000], 0instruction. Built separately from unmodifiedmainbca7a29, it exits with 0xc0000005; converted with the new option, it exits with 42.0x7ffe0000) fails with 0xc0000018 / STATUS_CONFLICTING_ADDRESSES, rather than silently relocating. User-address-space overflow fails conversion without writing an executable.mainfor relative-pointer, eager-import and lazy-import fixtures.python tools/check_test_registration.py build-relinker: passed, 18 registered native test executables.python tools/check_conventions.py --base origin/main: passed.The same commit, d8f73c2, was also built and tested on Ubuntu 24.04.5 LTS x86-64 under WSL2 (kernel 6.18.33.2), using GCC 13.3.0, CMake 3.28.3 and Python 3.12.3:
ANYPS5_RELINKER_ONLY=ONandBUILD_TESTING=ON: passed.ctest --test-dir build-relinker --output-on-failure --parallel 4: 125/125 passed, 6.34 s total, including native Linux ELF execution tests.python3 tools/check_test_registration.py build-relinker: passed, 23 registered native test executables.windows_fixed_basevalidates PE generation and addresses; native Windows EXE execution and loader-collision checks were exercised in the Windows run above.Ruffle, VLC and XPSemu themselves were not run. Full system-library/GPU builds and macOS native runtime tests were not run. This PR provides the Windows loader behavior and a synthetic reproduction; it does not close the remaining Linux part of #4013.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)