diff options
Diffstat (limited to 'runtime/src/pe_loader.cpp')
| -rw-r--r-- | runtime/src/pe_loader.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp index 253a773b5..1c6b91b54 100644 --- a/runtime/src/pe_loader.cpp +++ b/runtime/src/pe_loader.cpp | |||
| @@ -1450,14 +1450,14 @@ Module& Loader::map_image(const std::filesystem::path& path, const std::string& | |||
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | int64_t delta = reinterpret_cast<int64_t>(m->base) - static_cast<int64_t>(oh.ImageBase); | 1452 | int64_t delta = reinterpret_cast<int64_t>(m->base) - static_cast<int64_t>(oh.ImageBase); |
| 1453 | // Windows' loader (LdrRelocateImage) refuses to move an image only when IMAGE_FILE_RELOCS_STRIPPED is set; with the | 1453 | // A moved image with a relocation table is fixed up, whatever IMAGE_FILE_RELOCS_STRIPPED says. Without a table, |
| 1454 | // flag clear and no relocation directory it moves it and fixes up nothing, so the image is trusted to hold no | 1454 | // the flag refuses the move; with the flag clear the image is moved and nothing is fixed up, so it is trusted to |
| 1455 | // absolute addresses. That move is logged so it shows in traces. base_reservation::needed still keeps the main | 1455 | // hold no absolute addresses. The Windows 11 loader does all three (measured in #8847); that move is logged so |
| 1456 | // image's range free when it has no relocation directory, so a main image is moved this way only where the | 1456 | // it shows in traces. base_reservation::needed still keeps the main image's range free when it has no |
| 1457 | // range could not be had. | 1457 | // relocation directory, so a main image is moved this way only where the range could not be had. |
| 1458 | const auto dir = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC); | 1458 | const auto dir = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC); |
| 1459 | if (delta) m->relocated = true; | 1459 | if (delta) m->relocated = true; |
| 1460 | if (delta && (nt->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED)) | 1460 | if (delta && !dir.Size && (nt->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED)) |
| 1461 | throw std::runtime_error(m->name + ": preferred base is taken and the image's relocations are stripped"); | 1461 | throw std::runtime_error(m->name + ": preferred base is taken and the image's relocations are stripped"); |
| 1462 | if (delta && !dir.Size) | 1462 | if (delta && !dir.Size) |
| 1463 | std::fprintf(stderr, "[rt] loader: %s: preferred base %#llx is taken, moved to %p with no relocations\n", | 1463 | std::fprintf(stderr, "[rt] loader: %s: preferred base %#llx is taken, moved to %p with no relocations\n", |