diff options
Diffstat (limited to 'lld/COFF/Driver.cpp')
| -rw-r--r-- | lld/COFF/Driver.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 47fc54fb91e..02bfdc9c4dc 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -244,6 +244,12 @@ WindowsSubsystem LinkerDriver::inferSubsystem() { return IMAGE_SUBSYSTEM_UNKNOWN; } +static uint64_t getDefaultImageBase() { + if (Config->is64()) + return Config->DLL ? 0x180000000 : 0x140000000; + return Config->DLL ? 0x10000000 : 0x400000; +} + bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { // Needed for LTO. llvm::InitializeAllTargetInfos(); @@ -311,7 +317,6 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { // Handle /dll if (Args.hasArg(OPT_dll)) { Config->DLL = true; - Config->ImageBase = 0x180000000U; Config->ManifestID = 2; } @@ -602,6 +607,10 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) { } } + // Set default image base if /base is not given. + if (Config->ImageBase == uint64_t(-1)) + Config->ImageBase = getDefaultImageBase(); + Symtab.addRelative(mangle("__ImageBase"), 0); if (Config->MachineType == IMAGE_FILE_MACHINE_I386) { Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0); |

