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

Closed
opened 2026-11-26 20:18:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/634
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: loader-rebase-without-reloc-dir


📝 Commits (3)

  • 0ddf806 pe_loader: move an image with no relocation directory, refuse only on IMAGE_FILE_RELOCS_STRIPPED
  • ca56a0d pe_loader: a relocation table is applied whatever RELOCS_STRIPPED says (Windows 11 measurement)
  • bb256eb pe_loader: the relocation-move notes stop citing the old pull request number

📊 Changes

4 files changed (+113 additions, -10 deletions)

View changed files

📝 runtime/README.md (+7 -1)
📝 runtime/src/base_reservation.h (+4 -1)
📝 runtime/src/pe_loader.cpp (+14 -8)
📝 runtime/test/loader_test.cpp (+88 -0)

📄 Description

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/634 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `loader-rebase-without-reloc-dir` --- ### 📝 Commits (3) - [`0ddf806`](https://github.com/ubiquitarianism/leonida/commit/0ddf806359d30022a3152e61c93ed077212d25aa) pe_loader: move an image with no relocation directory, refuse only on IMAGE_FILE_RELOCS_STRIPPED - [`ca56a0d`](https://github.com/ubiquitarianism/leonida/commit/ca56a0d5eff2f6217a593babcfaff87d46daa15d) pe_loader: a relocation table is applied whatever RELOCS_STRIPPED says (Windows 11 measurement) - [`bb256eb`](https://github.com/ubiquitarianism/leonida/commit/bb256ebbf32d7493e3d867923ec737e60d3f9f9d) pe_loader: the relocation-move notes stop citing the old pull request number ### 📊 Changes **4 files changed** (+113 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `runtime/README.md` (+7 -1) 📝 `runtime/src/base_reservation.h` (+4 -1) 📝 `runtime/src/pe_loader.cpp` (+14 -8) 📝 `runtime/test/loader_test.cpp` (+88 -0) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:40 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#675
No description provided.