fix(relinker): keep Windows images without relocations loadable #1958
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1958"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-10-09T02:28:13Z.
What
Stop setting
IMAGE_FILE_RELOCS_STRIPPEDon Windows PE outputs whose base-relocation directory is empty.This is the ordinary path for Windows guest modules with no absolute addresses to relocate, including output from both
WindowsGuestModuleWriterandWindowsPePatcher. Marking those images as relocation-stripped unnecessarily makes them non-relocatable and causesCreateProcessto reject them with error 623 on the reporter's Windows configuration. The fixed image base and existingDYNAMIC_BASEbehavior remain unchanged.Add a Windows PE builder regression assertion for the emitted COFF characteristics.
Closes #1955 in part. The remaining
windows_address_spacefailure is a separate stack-placement assumption and does not prevent generated images from starting.Tested
main(0c0dc1e9)windows_dependency_diagnostics: passedamd64_only_windows: passed, including the new COFF characteristics assertionguest_needed_modules: passedguest_module_directories: passedwindows_import_modules: passedwindows_address_spacehigh-stack assertion remains; three unrelated current-main tool tests fail locally because Python 3.10 lackssubprocess._text_encodingand the sandbox blocks their temporary Git/file-replacement operationspython tools/check_conventions.py --base origin/main: passedgit diff --check origin/main HEAD: passedChecklist
main; no other open PR implements the same changeImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T02:31:29Z.
Review: APPROVED
Reviewed the complete two-file diff and the Windows reproduction in #1955. Clearing IMAGE_FILE_RELOCS_STRIPPED while keeping the fixed base and DYNAMIC_BASE behavior unchanged matches the controlled Windows result; the test asserts the emitted COFF characteristics. This head is based directly on current main. On Linux/GCC 12.2, the relinker-only build and all 38 CTests passed, including Windows PE generation/integration checks that run portably; Conventions and diff whitespace checks passed. The author reports the Windows-only builder test and four affected Windows integration tests passing on 26200; windows_address_space remains a separate stack-placement failure on that build. GitHub reports no upstream checks for this head, so this approval records local Linux validation plus the author-provided Windows evidence.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T03:06:32Z.
Review: COMMENTED
What I could and could not check on Linux — including a correction worth writing down for the next verifier.
peOffset + 22is the COFFCharacteristics;0x22isIMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LARGE_ADDRESS_AWARE, and the old0x23addedIMAGE_FILE_RELOCS_STRIPPED. So this drops exactly the flag the body saysCreateProcessrejects with error 623 and nothing else.Amd64OnlyWindowsTests.cpp, whose targetamd64_only_windows_testsis defined inside the platform guard that closes atcore/relinker/CMakeLists.txt:124, so on Linux there is neither a target nor a ctest entry for it.ctest -R amd64_only_converteris a different target whose binary does not contain this file at all. I ran that first and the new assertion looked like it did not bite. It does — the test'sdirectoriesarray is all-zero (Amd64OnlyWindowsTests.cpp:616-617), which is exactly thedirectories[5].Size == 0case the old code wrote0x23for.windows_dependency_diagnostics, the other Linux-runnable test that includesWindowsPeWriter, passes with this change — no regression on the Linux/Mesa side of the writer.WindowsGuestModuleWriter.cpp:82andWindowsPePatcher.cpp:54both hand the writer an all-zerodirectoriesarray, so this is the ordinary path for a Windows guest module that has no relocations.Not verified: the Windows witness itself (error 623 on NT 10.0.26200.0) — there is no Windows here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:39:29Z.
One actionable check remains: the current Conventions run failed because the description uses
Summary/Verification/Why, while the repository check requires non-emptyWhat,Tested, andChecklistsections. Please keep the existing technical explanation but move it into those template headings and fill the checklist, includingDepends on: noneand AI assistance. Also consider the reviewer’s note that a zero relocation directory is the ordinary Windows guest-module path; the current wording “fixed-base PE outputs” may understate the scope. The code review and Linux/Windows evidence remain favorable.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:40:30Z.
One more contribution-rule follow-up: this head is still based on
f1451396, while current upstreammainis6cc0503d. Please rebase and rerun the current-head checks along with the template correction; the already-passing Build evidence remains useful for the current source diff.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:06:18Z.
Checked the one-line change: the COFF
Characteristicsword atpeOffset + 22goes from0x23to0x22, dropping onlyIMAGE_FILE_RELOCS_STRIPPED. Both writers pass an all-zero directory array only when there are no relocations, so there are no absolute addresses to fix up and the image can be rebased safely. The new assertion atAmd64OnlyWindowsTests.cpp:619reads the right offset (0x80 + 22). Relinker build and ctest (47/47) pass on Linux; the Windows-onlyamd64_only_windows_teststarget can't run here, so that part and the error 623 itself rest on your controlled runs and the Windows results in the thread. Merging.