fix(relinker): load Windows executables at a fixed low base #4237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4237"
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 MarcZX10 on 2026-10-12T01:55:40Z.
What
Writes converted Windows executables without
DYNAMIC_BASE, so Windows can load the main image at its fixed low base inside the console's 40-bit address window. Guest modules keepDYNAMIC_BASE. The integration test checks both characteristics and confirms the executable fixture has relocations. This addresses the mspace buffer rejection described in #3043 for PRAGMATA.Tested
Checklist
main; no matching open fix PRLimitations
The runtime evidence is from Windows 10 and has not been verified on console hardware or other Windows versions.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T01:55:44Z.
Carried the current-main fix linked in #3043 with the source author preserved. Local conventions and diff checks pass; the branch reports 124 Linux relinker tests and Windows 10 runtime evidence. The PR explicitly records that Windows 11 build 26200 reserves the image range and remains unverified, so this is not claimed as a Windows 11 fix.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:25:35Z.
Please cut the TechnicalDebt entry to one sentence and drop the Windows 11 build 26200 claim, there and in Limitations. #1955 was
RELOCS_STRIPPED, fixed by #1958, and two 26200 machines in that issue load at0x140000000.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:17:52Z.
Thanks for the correction. The #1955 failure was caused by RELOCS_STRIPPED and was fixed by #1958; I do not have evidence that Windows 11 build 26200 fails to load at the standard base. I will remove that claim from Limitations and shorten the TechnicalDebt entry, then rebase the PR onto current main.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:35:24Z.
Rebased onto current
mainand updated the debt entry to one sentence. I removed the Windows 11 build 26200 assertion from both the entry and the limitations section; #1955 wasRELOCS_STRIPPED, and its later runs do not support that claim. The PR description now distinguishes the Windows 10 evidence reported in #3043 from testing this rebased head, which has not been rerun locally.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:35:13Z.
Review: DISMISSED
Rebased this onto current
mainlocally; it builds, but two tests fail:windows_fixed_base:test_windows_fixed_base.py:73asserts the default output keepsDYNAMIC_BASE(bool(characteristics & 0x40) == (base is None)). #319fa5779added--windows-fixed-baseas the opt-in way to get a non-ASLR main image, anddocs/user/USAGE.mdsays that without it placement is unchanged. This PR changes that default.windows_address_space(this PR's own test): the guest module artifact comes out withDllCharacteristics 0x100, not0x140. The module goes through the sameWindowsPeWriter::Write, so on main's writer the flag can't be dropped for the executable alone; the PR needs to pass the distinction in (executable vs module).Please rework this on top of main: either document why
--windows-fixed-base 0x140000000is not enough for #3043 (the default image base is already0x140000000, below 1 TiB), or make the executable/module distinction explicit inWindowsPeWriter::Write, updatewindows_fixed_baseand USAGE.md for the new default, and keep the module case in your test. The debt line should then also reflect the option that exists on main.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T17:13:17Z.
Follow-up to the default-image-base review: the Windows test recorded in issue #3043 using the existing fixed-base option removes the reported allocation crash and reaches the later
sceVideoOutGetOutputStatusWithVrrstop. That is evidence the current option handles the reported title case; I do not have evidence that all converted executables should loseDYNAMIC_BASEby default. I agree the current PR needs a distinct use case or a narrower scope before its default change is justified. I have not changed the branch.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:23:43Z.
Thanks for flagging the mismatch. I reworked the rebased writer so
dynamicBaseis explicit: main executables passfalse, while guest modules use the defaulttrueand retain relocations. The rebasedwindows_fixed_basetest now asserts the default executable has noDYNAMIC_BASE, whilewindows_address_spaceasserts executable0x100and module0x140. Local Linux relinker/windows CTest passed 13/13; the updated Ubuntu CI check also passes. macOS and Windows checks are still running. The current PR body includes the distinction and limitation of the runtime evidence. Could you please re-review once the remaining CI jobs finish?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:26:46Z.
I found your later follow-up (comment 6151045069) about the existing
--windows-fixed-baseoption. The current PR still lacks evidence that changing the default is necessary for PRAGMATA: #3043 reports the existing option reaches the next stop. The passing tests establish the executable/module characteristics and address-space behavior, but not a user-visible benefit over opting in. Could you clarify a separate use case where default ASLR prevents loading or causes the low-base requirement to fail? Until then I agree this point remains open; I will not treat green CI as resolving it.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T00:55:38Z.
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.
main)docs/dev/debt/relinker.mdL6Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T03:20:18Z.
Title evidence and Windows test for this PR (Windows 10 19045, MinGW-w64 GCC 15.2.0, Release; head
808b2a83dmerged ontomaina5f493f90, clean merge; relinker,libkernelandlibcbuilt from that merge).PPSA02530 (SDK word
0x1100004012590001in its process parameters):main, converted withrelinker --windows --registry --trace-imports: the executable loads at a0x7ff6...address (DYNAMIC_BASE) and stops about 6 s after the start:FATAL: unhandled exception 0xc0000005 ... rip app.exe+0x26917, write of 0x0000000000000020. The write ismov DWORD PTR [r15+0x20], ebxafter the title's firstmalloc(112)returned NULL. Cause, traced with gdb: the title's libc init callback callssceLibcMspaceCreate("User Malloc For TLS", <static 256 KiB buffer in the executable image>, 0x40000, 0); the guest libc rejects a base address above 2^40 whilesceKernelIsAddressSanitizerEnabledreturns 0, the callback returns 1, the libc reportssceKernelDebugRaiseException c1=-1610481644(0xA0020014) and skips the creation of its default heap, so every latermallocreturns NULL.RunThread entry=0x140a03c90 ...), it opens/app0/natives/PS5/runtime.args, and it then stops atwhat(): sceVideoOutGetOutputStatusWithVrr not implemented(a separate gap; #3972 implements that function). The same result is reached onmainwithrelinker --windows-fixed-base 0x400000000.run_041304.err(main, crash),run_051605.err(this PR, next stop).Not run: Linux, a console. The relinker tests of this PR were not run by me.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T03:28:45Z.
Addendum to my Windows test above, for the executable header:
objdump -p app.exeof the converted PPSA02530 showsImageBase 0x0000000140000000andDllCharacteristics 0x00000100with this PR, andDllCharacteristics 0x00000140(the extra0x40isDYNAMIC_BASE) when converted frommainwithout it.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T04:06:37Z.
Correction to my Windows test above: I wrote that the relinker,
libkernelandlibcwere built from the merge of this PR intomain. That holds for the relinker only. The.prxlibraries used in those title runs were an earlier build ofmain(the libs directory was not rebuilt from the merge). The crash onmainand the result with this PR therefore compare two relinker outputs run with the same earlier libraries, which is the part this PR changes (the header and load address of the converted executable); theobjdump -pvalues in my addendum are from the converted executables and are not affected.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:40:16Z.
I pushed a docs commit for the two open points:
docs/user/USAGE.mdnow describes the new default (noDYNAMIC_BASE, preferred base0x140000000, relocations kept;--windows-fixed-basestays for exact addresses), and the debt line says why it is the default (the title's ownsceLibcMspaceCreatechecks a 40-bit window, #3043) and names the option. xXPBSXx's Windows 10 run on808b2a83dcovers the code; no other change.