[PATCH] D40017: [LLD] [MinGW] Add support for --dynamicbase, --nxcompat, --tsaware and --high-entropy-va
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 06:46:32 PST 2017
mstorsjo updated this revision to Diff 122835.
mstorsjo retitled this revision from "[LLD] [MinGW] Add support for --dynamicbase, --nxcompat and --tsaware" to "[LLD] [MinGW] Add support for --dynamicbase, --nxcompat, --tsaware and --high-entropy-va".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.
Added `--high-entropy-va` as well.
https://reviews.llvm.org/D40017
Files:
MinGW/Driver.cpp
MinGW/Options.td
test/MinGW/driver.test
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 -
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -6,17 +6,21 @@
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
HelpText<"Add a directory to the library search path">;
+def dynamicbase: Flag<["--"], "dynamicbase">, HelpText<"Enable ASLR">;
def entry: S<"entry">, MetaVarName<"<entry>">,
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<"<libName>">,
HelpText<"Root name of library to use">;
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
def no_whole_archive: F<"no-whole-archive">,
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<"<path>">,
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: 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40017.122835.patch
Type: text/x-patch
Size: 3595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171114/d7ad9943/attachment.bin>
More information about the llvm-commits
mailing list