[PATCH] D86654: [LLD] [MinGW] Enable dynamicbase by default
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 12:54:40 PDT 2020
mstorsjo created this revision.
mstorsjo added reviewers: amccarth, mati865, jacek, ruiu.
Herald added a subscriber: dang.
Herald added a project: LLVM.
mstorsjo requested review of this revision.
This matches lld-link's own default.
Add a new command line option --no-dynamicbase for disabling it. (Unfortunately, GNU ld doesn't yet have a matching --no-dynamicbase option, as that's the default there.)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86654
Files:
lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test
Index: lld/test/MinGW/driver.test
===================================================================
--- lld/test/MinGW/driver.test
+++ lld/test/MinGW/driver.test
@@ -136,14 +136,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 i386pe foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s
-RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s
-DEFAULT-DISABLE-FLAGS: -dynamicbase:no
-RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
-RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
-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
+RUN: ld.lld -### -m i386pe foo.o --no-dynamicbase | FileCheck -check-prefix DISABLE-DYNAMICBASE %s
+DISABLE-DYNAMICBASE: -dynamicbase:no
+RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m i386pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m thumb2pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m arm64pe foo.o | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+# On arm, dynamicbase can't be disabled, so --no-dynamicbase is ignored
+RUN: ld.lld -### -m thumb2pe foo.o --no-dynamicbase | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+RUN: ld.lld -### -m arm64pe foo.o --no-dynamicbase | FileCheck -check-prefix NO-DISABLE-DYNAMICBASE %s
+NO-DISABLE-DYNAMICBASE-NOT: -dynamicbase:no
RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
Index: lld/MinGW/Options.td
===================================================================
--- lld/MinGW/Options.td
+++ lld/MinGW/Options.td
@@ -32,7 +32,7 @@
HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;
def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,
HelpText<"Don't do automatic imports that require runtime fixups">;
-def dynamicbase: F<"dynamicbase">, HelpText<"Enable ASLR">;
+defm dynamicbase: B<"dynamicbase", "Enable ASLR", "Disable ASLR">;
def enable_auto_import: F<"enable-auto-import">,
HelpText<"Automatically import data symbols from other DLLs where needed">;
def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">,
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -292,7 +292,8 @@
add("-noseh");
if (args.getLastArgValue(OPT_m) != "thumb2pe" &&
- args.getLastArgValue(OPT_m) != "arm64pe" && !args.hasArg(OPT_dynamicbase))
+ args.getLastArgValue(OPT_m) != "arm64pe" &&
+ args.hasArg(OPT_no_dynamicbase))
add("-dynamicbase:no");
if (args.hasFlag(OPT_no_insert_timestamp, OPT_insert_timestamp, false))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86654.288085.patch
Type: text/x-patch
Size: 3432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/ff16a5b5/attachment.bin>
More information about the llvm-commits
mailing list