Repository navigation
OLD-8847: restore old upstream PR 8847 - pe_loader: move an image with no relocation directory; refuse only on IMAGE_FILE_RELOCS_STRIPPED - #634
Conversation
… IMAGE_FILE_RELOCS_STRIPPED The loader refused any image whose preferred base was taken when it had no relocation directory. Windows' loader decides on the file header flag instead (LdrRelocateImage, the same in Wine's perform_relocations and ReactOS's LdrRelocateImageWithBias): IMAGE_FILE_RELOCS_STRIPPED set means the image cannot move and is refused (STATUS_CONFLICTING_ADDRESSES); with the flag clear and an empty directory the image is moved with nothing to fix up, as a second copy of such a DLL is. map_image now does the same, for an EXE and a DLL alike: it refuses to move a flag-set image (also one that has a relocation table, as Windows does), moves a flag-clear image without a directory and logs one "[rt] loader: ... moved ... with no relocations" line, so a move without fix-ups shows in traces. base_reservation::needed keeps reserving the main image's range for both kinds of image without relocations, and now also for a flag-set image with a table, so the main image keeps its base wherever it did before. The retail executable and every package DLL have a relocation table and the flag clear, so neither path applies to them. loader_test covers a flag-clear image moved when its base is held (it loads elsewhere, nothing is fixed up, its DllMain runs), the same image with the flag set (refused), the flag at a free base (maps), and the flag with a relocation table (refused). test_failed_dependency_not_registered's dependency shared its parent's base and was refused for that; it now fails on its corrupt import table, which is what the test describes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (Windows 11 measurement) Zombins2 measured the Windows 11 (26200) loader with synthetic x64 DLLs in #8847. An image with IMAGE_FILE_RELOCS_STRIPPED set and a relocation table was moved and fixed up when its base was taken. The previous commit refused that case, while main relocated it. That is now back to main's behaviour: a moved image with a table is fixed up whatever the flag says, and the flag refuses a move only when there is no table. base_reservation::needed is back to main's test (the directory size) and no longer reserves for a flag-set image with a table. The core change stays: with the flag clear and no relocation directory, the image is moved with nothing fixed up and the move is logged. That matches the measurement. Windows also refused flag-set DLLs without a relocation directory at a free base (error 487), and it is not known why. The loader keeps main's behaviour there and maps them at their base. runtime/README.md records this as an open question, and loader_test's check for it no longer claims Windows parity. The flag-with-table check now expects a move with the DIR64 fix-up applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… number The Windows 11 measurement behind this behaviour was posted in a review of pull request 8847 of the original repository, which went private on 2026-11-23, so its link and the "#8847" references in pe_loader.cpp and loader_test.cpp lead nowhere now. runtime/README.md keeps the measurement and the open question in its own words and names where it came from; the code comments point at the README. No behaviour changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed bb256eb: read the relocation-move policy end to end (a relocation table applies regardless of Recommendation: Merge |
ProjectLeonida#634 rewrote the same runtime/README.md paragraph on the loader. Its text stays, and its relocation sentence takes this PR's wording: DIR64 and HIGHLOW relocations, the other types rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: OLD-8847 #14 (comment)
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 ontomainat21625bca8without conflicts. One extra commit replaces the links to the old PR number, which no longer resolve, with plain text.What and why
Loader::map_imagerefuses any image whose preferred base is taken when the image has no relocation directory (runtime/src/pe_loader.cpp:1428-1431and:1456-1459onmain). Windows only refuses that move whenIMAGE_FILE_RELOCS_STRIPPEDis set. With the flag clear, it moves the image without fix-ups.This PR follows Windows:
mainRELOCS_STRIPPEDsays (the Windows 11 measurement from the original PR's review)main.Tested
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".git diff --checkandpython -I scripts/check_no_game_data.pyon the changed files are clean.GPUs tested: n/a (CPU-only loader tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code, Claude Opus 5.5).