Index: lld/MinGW/Driver.cpp =================================================================== --- lld/MinGW/Driver.cpp +++ lld/MinGW/Driver.cpp @@ -292,7 +292,8 @@ add("-noseh"); if (args.getLastArgValue(OPT_m) != "thumb2pe" && - args.getLastArgValue(OPT_m) != "arm64pe" && !args.hasArg(OPT_dynamicbase)) + args.getLastArgValue(OPT_m) != "arm64pe" && + args.hasArg(OPT_no_dynamicbase)) add("-dynamicbase:no"); if (args.hasFlag(OPT_no_insert_timestamp, OPT_insert_timestamp, false)) Index: lld/MinGW/Options.td =================================================================== --- lld/MinGW/Options.td +++ lld/MinGW/Options.td @@ -32,7 +32,7 @@ HelpText<"Don't automatically import data symbols from other DLLs without dllimport">; def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">, HelpText<"Don't do automatic imports that require runtime fixups">; -def dynamicbase: F<"dynamicbase">, HelpText<"Enable ASLR">; +defm dynamicbase: B<"dynamicbase", "Enable ASLR", "Disable ASLR">; def enable_auto_import: F<"enable-auto-import">, HelpText<"Automatically import data symbols from other DLLs where needed">; def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">, Index: lld/test/MinGW/driver.test =================================================================== --- lld/test/MinGW/driver.test +++ lld/test/MinGW/driver.test @@ -136,14 +136,18 @@ RUN: ld.lld -### -m i386pep foo.o --large-address-aware | FileCheck -check-prefix LARGE-ADDRESS-AWARE %s LARGE-ADDRESS-AWARE: -largeaddressaware -RUN: ld.lld -### -m i386pe foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s -RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s -DEFAULT-DISABLE-FLAGS: -dynamicbase:no -RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s -RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s -RUN: ld.lld -### -m thumb2pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s -RUN: ld.lld -### -m arm64pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s -NO-DEFAULT-DISABLE-FLAGS-NOT: -dynamicbase:no +RUN: ld.lld -### -m i386pe foo.o --no-dynamicbase | FileCheck -check-prefix DISABLE-DYNAMICBASE %s +DISABLE-DYNAMICBASE: -dynamicbase:no +RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m i386pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m thumb2pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m arm64pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +# On arm, dynamicbase can't be disabled, so --no-dynamicbase is ignored +RUN: ld.lld -### -m thumb2pe foo.o --no-dynamicbase | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +RUN: ld.lld -### -m arm64pe foo.o --no-dynamicbase | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s +NO-DISABLE-DYNAMICBASE-NOT: -dynamicbase:no RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s