fix(relinker): load Windows executables at a fixed low base #4237

Merged
MarcZX10 merged 3 commits from upstream-pr/4237 into main 2026-10-14 04:49:45 +00:00
MarcZX10 commented 2026-10-12 01:55:40 +00:00 (Migrated from github.com)

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 keep DYNAMIC_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

  • The #3043 report records 124 Linux relinker tests and Windows 10 runtime evidence for PRAGMATA, plus eight Windows address-space launches in its integration test. Those results are from the issue's tested branch, not a fresh run of this current-main rebase.
  • The current-main rebase has not been built or tested locally; CI should rerun against this head.

Checklist

  • Rebased onto current main; no matching open fix PR
  • Main executables disable dynamic-base relocation; guest modules retain it
  • One topic: fixed-base loading for converted main executables
  • Depends on: none
  • AI-assisted: yes

Limitations

The runtime evidence is from Windows 10 and has not been verified on console hardware or other Windows versions.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4824020514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237). Originally posted by [MarcZX10](https://github.com/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 keep `DYNAMIC_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 - The #3043 report records 124 Linux relinker tests and Windows 10 runtime evidence for PRAGMATA, plus eight Windows address-space launches in its integration test. Those results are from the issue's tested branch, not a fresh run of this current-main rebase. - The current-main rebase has not been built or tested locally; CI should rerun against this head. ### Checklist - [x] Rebased onto current `main`; no matching open fix PR - [x] Main executables disable dynamic-base relocation; guest modules retain it - [x] One topic: fixed-base loading for converted main executables - [x] Depends on: none - [x] AI-assisted: yes ### Limitations The runtime evidence is from Windows 10 and has not been verified on console hardware or other Windows versions.
MarcZX10 commented 2026-10-12 01:55:44 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116371028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6116371028). Originally posted by [MarcZX10](https://github.com/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.
oneandonlydean commented 2026-10-12 08:25:35 +00:00 (Migrated from github.com)

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 at 0x140000000.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120541240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6120541240). Originally posted by [oneandonlydean](https://github.com/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 at `0x140000000`.
MarcZX10 commented 2026-10-13 07:17:52 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140404017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6140404017). Originally posted by [MarcZX10](https://github.com/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.
MarcZX10 commented 2026-10-13 07:35:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:35:24Z.


Rebased onto current main and updated the debt entry to one sentence. I removed the Windows 11 build 26200 assertion from both the entry and the limitations section; #1955 was RELOCS_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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140670159 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6140670159). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:35:24Z. --- Rebased onto current `main` and updated the debt entry to one sentence. I removed the Windows 11 build 26200 assertion from both the entry and the limitations section; #1955 was `RELOCS_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.
adriadam10 commented 2026-10-13 13:35:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:35:13Z.

Review: DISMISSED


Rebased this onto current main locally; it builds, but two tests fail:

  • windows_fixed_base: test_windows_fixed_base.py:73 asserts the default output keeps DYNAMIC_BASE (bool(characteristics & 0x40) == (base is None)). #319fa5779 added --windows-fixed-base as the opt-in way to get a non-ASLR main image, and docs/user/USAGE.md says 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 with DllCharacteristics 0x100, not 0x140. The module goes through the same WindowsPeWriter::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 0x140000000 is not enough for #3043 (the default image base is already 0x140000000, below 1 TiB), or make the executable/module distinction explicit in WindowsPeWriter::Write, update windows_fixed_base and 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5504350893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#pullrequestreview-5504350893). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T13:35:13Z. **Review:** DISMISSED --- Rebased this onto current `main` locally; it builds, but two tests fail: - `windows_fixed_base`: `test_windows_fixed_base.py:73` asserts the default output keeps `DYNAMIC_BASE` (`bool(characteristics & 0x40) == (base is None)`). #319fa5779 added `--windows-fixed-base` as the opt-in way to get a non-ASLR main image, and `docs/user/USAGE.md` says 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 with `DllCharacteristics 0x100`, not `0x140`. The module goes through the same `WindowsPeWriter::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 0x140000000` is not enough for #3043 (the default image base is already `0x140000000`, below 1 TiB), or make the executable/module distinction explicit in `WindowsPeWriter::Write`, update `windows_fixed_base` and 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.
MarcZX10 commented 2026-10-13 17:13:17 +00:00 (Migrated from github.com)

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 sceVideoOutGetOutputStatusWithVrr stop. That is evidence the current option handles the reported title case; I do not have evidence that all converted executables should lose DYNAMIC_BASE by 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6151045069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6151045069). Originally posted by [MarcZX10](https://github.com/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 `sceVideoOutGetOutputStatusWithVrr` stop. That is evidence the current option handles the reported title case; I do not have evidence that all converted executables should lose `DYNAMIC_BASE` by 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.
MarcZX10 commented 2026-10-13 19:23:43 +00:00 (Migrated from github.com)

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 dynamicBase is explicit: main executables pass false, while guest modules use the default true and retain relocations. The rebased windows_fixed_base test now asserts the default executable has no DYNAMIC_BASE, while windows_address_space asserts executable 0x100 and module 0x140. 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?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153387789 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6153387789). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T19:23:43Z. --- Thanks for flagging the mismatch. I reworked the rebased writer so `dynamicBase` is explicit: main executables pass `false`, while guest modules use the default `true` and retain relocations. The rebased `windows_fixed_base` test now asserts the default executable has no `DYNAMIC_BASE`, while `windows_address_space` asserts executable `0x100` and module `0x140`. 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?
MarcZX10 commented 2026-10-13 19:26:46 +00:00 (Migrated from github.com)

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-base option. 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153442358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6153442358). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T19:26:46Z. --- I found your later follow-up (comment 6151045069) about the existing `--windows-fixed-base` option. 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.
github-actions[bot] commented 2026-10-14 00:55:38 +00:00 (Migrated from github.com)

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#5598 docs/dev/debt/relinker.md L6
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158444162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6158444162). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T00:55:38Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5598 | `docs/dev/debt/relinker.md` [L6](https://github.com/boykopovar/AnyPS5/blob/90d0cb4812770a54251c3b91308a2f4b6b5da3b1/docs/dev/debt/relinker.md#L6) | | |
xXPBSXx commented 2026-10-14 03:20:18 +00:00 (Migrated from github.com)

Imported 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 808b2a83d merged onto main a5f493f90, clean merge; relinker, libkernel and libc built from that merge).

PPSA02530 (SDK word 0x1100004012590001 in its process parameters):

  • On main, converted with relinker --windows --registry --trace-imports: the executable loads at a 0x7ff6... address (DYNAMIC_BASE) and stops about 6 s after the start: FATAL: unhandled exception 0xc0000005 ... rip app.exe+0x26917, write of 0x0000000000000020. The write is mov DWORD PTR [r15+0x20], ebx after the title's first malloc(112) returned NULL. Cause, traced with gdb: the title's libc init callback calls sceLibcMspaceCreate("User Malloc For TLS", <static 256 KiB buffer in the executable image>, 0x40000, 0); the guest libc rejects a base address above 2^40 while sceKernelIsAddressSanitizerEnabled returns 0, the callback returns 1, the libc reports sceKernelDebugRaiseException c1=-1610481644 (0xA0020014) and skips the creation of its default heap, so every later malloc returns NULL.
  • With this PR (converted without any fixed-base flag) the title gets past that point and runs on: threads start (RunThread entry=0x140a03c90 ...), it opens /app0/natives/PS5/runtime.args, and it then stops at what(): sceVideoOutGetOutputStatusWithVrr not implemented (a separate gap; #3972 implements that function). The same result is reached on main with relinker --windows-fixed-base 0x400000000.
  • Logs: 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160126060 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6160126060). Originally posted by [xXPBSXx](https://github.com/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 `808b2a83d` merged onto `main` `a5f493f90`, clean merge; relinker, `libkernel` and `libc` built from that merge). PPSA02530 (SDK word `0x1100004012590001` in its process parameters): - On `main`, converted with `relinker --windows --registry --trace-imports`: the executable loads at a `0x7ff6...` address (DYNAMIC_BASE) and stops about 6 s after the start: `FATAL: unhandled exception 0xc0000005 ... rip app.exe+0x26917, write of 0x0000000000000020`. The write is `mov DWORD PTR [r15+0x20], ebx` after the title's first `malloc(112)` returned NULL. Cause, traced with gdb: the title's libc init callback calls `sceLibcMspaceCreate("User Malloc For TLS", <static 256 KiB buffer in the executable image>, 0x40000, 0)`; the guest libc rejects a base address above 2^40 while `sceKernelIsAddressSanitizerEnabled` returns 0, the callback returns 1, the libc reports `sceKernelDebugRaiseException c1=-1610481644` (`0xA0020014`) and skips the creation of its default heap, so every later `malloc` returns NULL. - With this PR (converted without any fixed-base flag) the title gets past that point and runs on: threads start (`RunThread entry=0x140a03c90 ...`), it opens `/app0/natives/PS5/runtime.args`, and it then stops at `what(): sceVideoOutGetOutputStatusWithVrr not implemented` (a separate gap; #3972 implements that function). The same result is reached on `main` with `relinker --windows-fixed-base 0x400000000`. - Logs: `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).
xXPBSXx commented 2026-10-14 03:28:45 +00:00 (Migrated from github.com)

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.exe of the converted PPSA02530 shows ImageBase 0x0000000140000000 and DllCharacteristics 0x00000100 with this PR, and DllCharacteristics 0x00000140 (the extra 0x40 is DYNAMIC_BASE) when converted from main without it.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160223325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6160223325). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-14T03:28:45Z. --- Addendum to my Windows test above, for the executable header: `objdump -p app.exe` of the converted PPSA02530 shows `ImageBase 0x0000000140000000` and `DllCharacteristics 0x00000100` with this PR, and `DllCharacteristics 0x00000140` (the extra `0x40` is `DYNAMIC_BASE`) when converted from `main` without it. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-14 04:06:37 +00:00 (Migrated from github.com)

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, libkernel and libc were built from the merge of this PR into main. That holds for the relinker only. The .prx libraries used in those title runs were an earlier build of main (the libs directory was not rebuilt from the merge). The crash on main and 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); the objdump -p values in my addendum are from the converted executables and are not affected.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160651695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6160651695). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-14T04:06:37Z. --- Correction to my Windows test above: I wrote that the relinker, `libkernel` and `libc` were built from the merge of this PR into `main`. That holds for the relinker only. The `.prx` libraries used in those title runs were an earlier build of `main` (the libs directory was not rebuilt from the merge). The crash on `main` and 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); the `objdump -p` values in my addendum are from the converted executables and are not affected. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-14 04:40:16 +00:00 (Migrated from github.com)

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.md now describes the new default (no DYNAMIC_BASE, preferred base 0x140000000, relocations kept; --windows-fixed-base stays for exact addresses), and the debt line says why it is the default (the title's own sceLibcMspaceCreate checks a 40-bit window, #3043) and names the option. xXPBSXx's Windows 10 run on 808b2a83d covers the code; no other change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161036825 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4237#issuecomment-6161036825). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T04:40:16Z. --- I pushed a docs commit for the two open points: `docs/user/USAGE.md` now describes the new default (no `DYNAMIC_BASE`, preferred base `0x140000000`, relocations kept; `--windows-fixed-base` stays for exact addresses), and the debt line says why it is the default (the title's own `sceLibcMspaceCreate` checks a 40-bit window, #3043) and names the option. xXPBSXx's Windows 10 run on 808b2a83d covers the code; no other change.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4237
No description provided.