Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -156,6 +156,22 @@
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 (Args.hasArg(OPT_high_entropy_va))
+ Add("-highentropyva");
+ else
+ Add("-highentropyva:no");
if (auto *A = Args.getLastArg(OPT_m)) {
StringRef S = A->getValue();
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -6,10 +6,12 @@
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">,
HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
+def high_entropy_va: Flag<["--"], "high-entropy-va">, HelpText<"Enable 64-bit ASLR">;
def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"">,
HelpText<"Root name of library to use">;
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
@@ -17,6 +19,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 +31,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,21 @@
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 -highentropyva: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 -
+
+RUN: ld.lld -### -m i386pep foo.o --high-entropy-va | FileCheck -check-prefix HIGHENTROPYVA %s
+HIGHENTROPYVA: -highentropyva -