Index: MinGW/Driver.cpp =================================================================== --- MinGW/Driver.cpp +++ MinGW/Driver.cpp @@ -156,6 +156,18 @@ Add("-debug:dwarf"); if (Args.hasArg(OPT_large_address_aware)) Add("-largeaddressaware"); + if (Args.hasArg(OPT_dynamicbase)) + Add("-dynamicbase"); + else + Add("-dynamicbase:no"); + if (Args.hasArg(OPT_nxcompat)) + Add("-nxcompat"); + else + Add("-nxcompat:no"); + if (Args.hasArg(OPT_tsaware)) + Add("-tsaware"); + else + Add("-tsaware:no"); if (auto *A = Args.getLastArg(OPT_m)) { StringRef S = A->getValue(); Index: MinGW/Options.td =================================================================== --- MinGW/Options.td +++ MinGW/Options.td @@ -6,6 +6,7 @@ def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"">, HelpText<"Add a directory to the library search path">; +def dynamicbase: Flag<["--"], "dynamicbase">, HelpText<"Enable ASLR">; def entry: S<"entry">, MetaVarName<"">, HelpText<"Name of entry point symbol">; def export_all_symbols: F<"export-all-symbols">, @@ -17,6 +18,8 @@ HelpText<"No longer include all object files for following archives">; def large_address_aware: Flag<["--"], "large-address-aware">, HelpText<"Enable large addresses">; +def nxcompat: Flag<["--"], "nxcompat">, + HelpText<"Enable data execution prevention">; def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"">, HelpText<"Path to file to write output">; def out_implib: Separate<["--"], "out-implib">, HelpText<"Import library name">; @@ -27,6 +30,8 @@ def stack: S<"stack">; def strip_all: F<"strip-all">, HelpText<"Omit all symbol information from the output binary">; +def tsaware: Flag<["--"], "tsaware">, + HelpText<"Create Terminal Server aware executable">; def whole_archive: F<"whole-archive">, HelpText<"Include all object files for following archives">; def verbose: F<"verbose">, HelpText<"Verbose mode">; Index: test/MinGW/driver.test =================================================================== --- test/MinGW/driver.test +++ test/MinGW/driver.test @@ -92,3 +92,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 i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s +DEFAULT-DISABLE-FLAGS: -dynamicbase:no -nxcompat:no -tsaware:no + +# The extra '-' in the following check patterns is intentional, to make sure +# that a check for e.g. "-dynamicbase" doesn't match the default +# "-dynamicbase:no". +RUN: ld.lld -### -m i386pep foo.o --dynamicbase | FileCheck -check-prefix DYNAMICBASE %s +DYNAMICBASE: -dynamicbase - + +RUN: ld.lld -### -m i386pep foo.o --nxcompat | FileCheck -check-prefix NXCOMPAT %s +NXCOMPAT: -nxcompat - + +RUN: ld.lld -### -m i386pep foo.o --tsaware | FileCheck -check-prefix TSAWARE %s +TSAWARE: -tsaware -