diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-23 14:36:22 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 04:58:41 -0500 |
| commit | 0ddf806359d30022a3152e61c93ed077212d25aa (patch) | |
| tree | cfad9153849f453afbde3123b8e61afd8e436c5a /runtime/src/bcpack.cpp | |
| parent | 21625bca8c675c62f9dbffc318ce6a59d57faf31 (diff) | |
pe_loader: move an image with no relocation directory, refuse only on 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>
Diffstat (limited to 'runtime/src/bcpack.cpp')
0 files changed, 0 insertions, 0 deletions