OLD-8847: restore old upstream PR 8847 - pe_loader: move an image with no relocation directory; refuse only on IMAGE_FILE_RELOCS_STRIPPED #634

Merged
aslan2142 merged 3 commits from upstream-pr/634 into main 2026-11-25 22:53:26 +00:00
aslan2142 commented 2026-11-24 10:33:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T10:33:28Z.


Claimed in the coordination issue as: OLD-8847 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128926292

Restoration of my original pull request, old upstream PR 8847 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Its two commits are cherry-picked onto main at 21625bca8 without conflicts. One extra commit replaces the links to the old PR number, which no longer resolve, with plain text.

What and why

Loader::map_image refuses any image whose preferred base is taken when the image has no relocation directory (runtime/src/pe_loader.cpp:1428-1431 and :1456-1459 on main). Windows only refuses that move when IMAGE_FILE_RELOCS_STRIPPED is set. With the flag clear, it moves the image without fix-ups.

This PR follows Windows:

Image Base taken, main Base taken, this PR
flag clear, no relocation directory refused moved, not fixed up, one log line
flag set, no relocation directory refused refused, and the message names the flag
has a relocation table moved and fixed up moved and fixed up, whatever RELOCS_STRIPPED says (the Windows 11 measurement from the original PR's review)
  • An image whose base is free maps at its base, as on main.
  • The retail executable and the package's DLLs are unaffected: all of them have a relocation table and the flag clear, as measured on the original PR.

Tested

  • On Linux under Wine 11.22, built with clang for the mingw target. MSVC is left to CI.
  • main (21625bca8) with only this PR's tests: 99 checks, 2 failed. The two are "an image without relocations, flag clear, moves when its base is taken" and "an image with IMAGE_FILE_RELOCS_STRIPPED is refused when its base is taken".
  • This branch: 99 checks, 0 failed.
  • Other checks: git diff --check and python -I scripts/check_no_game_data.py on the changed files are clean.
  • No game data: synthetic PE images only; no game files were used and no retail code was run.

GPUs tested: n/a (CPU-only loader tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470478711 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/634). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T10:33:28Z. --- Claimed in the coordination issue as: OLD-8847 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128926292 Restoration of my original pull request, old upstream PR 8847 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Its two commits are cherry-picked onto `main` at `21625bca8` without conflicts. One extra commit replaces the links to the old PR number, which no longer resolve, with plain text. ### What and why `Loader::map_image` refuses any image whose preferred base is taken when the image has no relocation directory (`runtime/src/pe_loader.cpp:1428-1431` and `:1456-1459` on `main`). Windows only refuses that move when `IMAGE_FILE_RELOCS_STRIPPED` is set. With the flag clear, it moves the image without fix-ups. This PR follows Windows: | Image | Base taken, `main` | Base taken, this PR | |---|---|---| | flag clear, no relocation directory | refused | moved, not fixed up, one log line | | flag set, no relocation directory | refused | refused, and the message names the flag | | has a relocation table | moved and fixed up | moved and fixed up, whatever `RELOCS_STRIPPED` says (the Windows 11 measurement from the original PR's review) | - An image whose base is free maps at its base, as on `main`. - **The retail executable and the package's DLLs are unaffected:** all of them have a relocation table and the flag clear, as measured on the original PR. ### Tested - **On Linux under Wine 11.22,** built with clang for the mingw target. MSVC is left to CI. - **`main` (`21625bca8`) with only this PR's tests:** 99 checks, 2 failed. The two are "an image without relocations, flag clear, moves when its base is taken" and "an image with IMAGE_FILE_RELOCS_STRIPPED is refused when its base is taken". - **This branch:** 99 checks, 0 failed. - **Other checks:** `git diff --check` and `python -I scripts/check_no_game_data.py` on the changed files are clean. - **No game data:** synthetic PE images only; no game files were used and no retail code was run. GPUs tested: n/a (CPU-only loader tests) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
PierreEbele commented 2026-11-25 01:39:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T01:39:25Z.


Reviewed bb256ebb: read the relocation-move policy end to end (a relocation table applies regardless of IMAGE_FILE_RELOCS_STRIPPED; with no table, flag set refuses and flag clear moves without fixups and logs) and all three commits. The only 8847 reference in docs/code is runtime/README.md's unreadable-origin note, matching the old-number rule, and the Win11 error-487 free-base question stays documented. Merges cleanly into current origin/main (auto-merging disjoint edits in runtime/src/pe_loader.cpp and runtime/README.md). On arm64 Linux (no network), the portable runtime builds and its CTest passes on bb256ebb (72/72, 2 skipped: shader_library_corpus, vk_sync_validation); loader_test is WIN32-only (windows.h) and was not run; compileall, the 12 doc tests (47 tests, 2 git-dependent skipped), test_boot_trace.py, test_ctest_registration.py, and check_no_game_data.py all pass on pr634, origin/main, and the merged tree. Statically against origin/main, all helpers in test_moved_without_relocations exist, Block 1 (flag clear) expects a load main refuses, and Block 2 (flag set) asserts the new "stripped" refusal message, so the test exercises the change. No blocking findings. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7149803076 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/634#issuecomment-7149803076). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T01:39:25Z. --- Reviewed bb256ebb: read the relocation-move policy end to end (a relocation table applies regardless of `IMAGE_FILE_RELOCS_STRIPPED`; with no table, flag set refuses and flag clear moves without fixups and logs) and all three commits. The only `8847` reference in docs/code is `runtime/README.md`'s unreadable-origin note, matching the old-number rule, and the Win11 error-487 free-base question stays documented. Merges cleanly into current `origin/main` (auto-merging disjoint edits in `runtime/src/pe_loader.cpp` and `runtime/README.md`). On arm64 Linux (no network), the portable runtime builds and its CTest passes on bb256ebb (72/72, 2 skipped: `shader_library_corpus`, `vk_sync_validation`); `loader_test` is WIN32-only (`windows.h`) and was not run; `compileall`, the 12 doc tests (47 tests, 2 git-dependent skipped), `test_boot_trace.py`, `test_ctest_registration.py`, and `check_no_game_data.py` all pass on `pr634`, `origin/main`, and the merged tree. Statically against `origin/main`, all helpers in `test_moved_without_relocations` exist, Block 1 (flag clear) expects a load main refuses, and Block 2 (flag set) asserts the new `"stripped"` refusal message, so the test exercises the change. No blocking findings. AI-assisted review. **Recommendation:** Merge
aslan2142 commented 2026-11-25 22:53:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:53:29Z.


Merged: pe_loader moves an image that has no relocation directory, and refuses only on IMAGE_FILE_RELOCS_STRIPPED.

  • Changed since review: nothing. It merges cleanly with main and with #643, and no review point is open.
  • Tested: the full Windows suite under Wine on main 5fab93967 with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. loader passes on both.
  • Checked on main 5fab93967 + bb256ebbf: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 4 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176906006 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/634#issuecomment-7176906006). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:53:29Z. --- Merged: `pe_loader` moves an image that has no relocation directory, and refuses only on `IMAGE_FILE_RELOCS_STRIPPED`. - **Changed since review:** nothing. It merges cleanly with `main` and with #643, and no review point is open. - **Tested:** the full Windows suite under Wine on `main` `5fab93967` with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. `loader` passes on both. - **Checked on `main` `5fab93967` + `bb256ebbf`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 4 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
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
ProjectLeonida/mandy!634
No description provided.