[lld] r318281 - [MinGW] Add support for --dynamicbase, ignore --nxcompat, --tsaware and --high-entropy-va

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 00:18:11 PST 2017


Author: mstorsjo
Date: Wed Nov 15 00:18:11 2017
New Revision: 318281

URL: http://llvm.org/viewvc/llvm-project?rev=318281&view=rev
Log:
[MinGW] Add support for --dynamicbase, ignore --nxcompat, --tsaware and --high-entropy-va

All of these are disabled by default in GNU ld, but enabled by default
in lld.

Disable dynamicbase by default since it potentially could cause
compatibility issues, but just ignore the others since the lld
default should be fine for most concievable cases.

Differential Revision: https://reviews.llvm.org/D40017

Modified:
    lld/trunk/MinGW/Driver.cpp
    lld/trunk/MinGW/Options.td
    lld/trunk/test/MinGW/driver.test

Modified: lld/trunk/MinGW/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Driver.cpp?rev=318281&r1=318280&r2=318281&view=diff
==============================================================================
--- lld/trunk/MinGW/Driver.cpp (original)
+++ lld/trunk/MinGW/Driver.cpp Wed Nov 15 00:18:11 2017
@@ -157,6 +157,8 @@ bool mingw::link(ArrayRef<const char *>
   if (Args.hasArg(OPT_large_address_aware))
     Add("-largeaddressaware");
 
+  Add(Args.hasArg(OPT_dynamicbase) ? "-dynamicbase" : "-dynamicbase:no");
+
   if (auto *A = Args.getLastArg(OPT_m)) {
     StringRef S = A->getValue();
     if (S == "i386pe")

Modified: lld/trunk/MinGW/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Options.td?rev=318281&r1=318280&r2=318281&view=diff
==============================================================================
--- lld/trunk/MinGW/Options.td (original)
+++ lld/trunk/MinGW/Options.td Wed Nov 15 00:18:11 2017
@@ -6,6 +6,7 @@ class S<string name>: Separate<["--", "-
 
 def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
   HelpText<"Add a directory to the library search path">;
+def dynamicbase: F<"dynamicbase">, HelpText<"Enable ASLR">;
 def entry: S<"entry">, MetaVarName<"<entry>">,
   HelpText<"Name of entry point symbol">;
 def export_all_symbols: F<"export-all-symbols">,
@@ -45,9 +46,12 @@ def O: Joined<["-"], "O">, HelpText<"Opt
 def enable_auto_image_base: F<"enable-auto-image-base">;
 def enable_auto_import: F<"enable-auto-import">;
 def full_shutdown: Flag<["--"], "full-shutdown">;
+def high_entropy_va: F<"high-entropy-va">, HelpText<"Enable 64-bit ASLR">;
 def major_image_version: S<"major-image-version">;
 def minor_image_version: S<"minor-image-version">;
+def nxcompat: F<"nxcompat">, HelpText<"Enable data execution prevention">;
 def sysroot: J<"sysroot">, HelpText<"Sysroot">;
+def tsaware: F<"tsaware">, HelpText<"Create Terminal Server aware executable">;
 def v: Flag<["-"], "v">, HelpText<"Display the version number">;
 def version: F<"version">, HelpText<"Display the version number and exit">;
 

Modified: lld/trunk/test/MinGW/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/MinGW/driver.test?rev=318281&r1=318280&r2=318281&view=diff
==============================================================================
--- lld/trunk/test/MinGW/driver.test (original)
+++ lld/trunk/test/MinGW/driver.test Wed Nov 15 00:18:11 2017
@@ -92,3 +92,12 @@ STRIP-NOT: -debug:dwarf
 
 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
+
+# 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
+DYNAMICBASE: -dynamicbase -




More information about the llvm-commits mailing list