Index: MinGW/Driver.cpp =================================================================== --- MinGW/Driver.cpp +++ MinGW/Driver.cpp @@ -159,7 +159,13 @@ if (Args.hasArg(OPT_large_address_aware)) Add("-largeaddressaware"); - Add(Args.hasArg(OPT_dynamicbase) ? "-dynamicbase" : "-dynamicbase:no"); + if (Args.getLastArgValue(OPT_m) == "thumb2pe" || + Args.getLastArgValue(OPT_m) == "arm64pe") { + if (Args.hasArg(OPT_dynamicbase)) + Add("-dynamicbase"); + } else { + Add(Args.hasArg(OPT_dynamicbase) ? "-dynamicbase" : "-dynamicbase:no"); + } if (Args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false)) Add("-opt:ref"); Index: test/MinGW/driver.test =================================================================== --- test/MinGW/driver.test +++ test/MinGW/driver.test @@ -95,11 +95,16 @@ RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s DEFAULT-DISABLE-FLAGS: -dynamicbase:no +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 # The extra '-' in the following check pattern is intentional, to make sure # that a check for "-dynamicbase" doesn't match the default "-dynamicbase:no". RUN: ld.lld -### -m i386pep foo.o --dynamicbase | FileCheck -check-prefix DYNAMICBASE %s RUN: ld.lld -### -m i386pep foo.o -dynamicbase | FileCheck -check-prefix DYNAMICBASE %s +RUN: ld.lld -### -m thumb2pe foo.o --dynamicbase | FileCheck -check-prefix DYNAMICBASE %s +RUN: ld.lld -### -m arm64pe foo.o --dynamicbase | FileCheck -check-prefix DYNAMICBASE %s DYNAMICBASE: -dynamicbase - RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s