[PATCH] D45087: [lld-link] Add comment explaining that /FIXED behavior is correct despite contradicting MSDN.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 30 06:36:48 PDT 2018


thakis created this revision.
thakis added a reviewer: ruiu.

Also add a test for /FIXED.


https://reviews.llvm.org/D45087

Files:
  COFF/Driver.cpp
  test/COFF/fixed.test


Index: test/COFF/fixed.test
===================================================================
--- test/COFF/fixed.test
+++ test/COFF/fixed.test
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
+#
+# RUN: lld-link %t.obj /fixed %p/Inputs/std32.lib /subsystem:console \
+# RUN:   /entry:main at 0 /debug /out:%t.fixed.exe
+# RUN: llvm-readobj -file-headers %t.fixed.exe | \
+# RUN:   FileCheck -check-prefix=EXEFIXED %s
+#
+# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
+# RUN:   /entry:main at 0 /debug /out:%t.exe
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=EXEREL %s
+#
+# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
+#
+# RUN: lld-link %t.obj /dll /fixed /debug /out:%t.fixed.dll
+# RUN: llvm-readobj -file-headers %t.fixed.dll | FileCheck -check-prefix=DLLFIXED %s
+#
+# RUN: lld-link %t.obj /dll /debug /out:%t.dll
+# RUN: llvm-readobj -file-headers %t.dll | FileCheck -check-prefix=DLLREL %s
+
+EXEFIXED-NOT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
+DLLFIXED-NOT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
+EXEREL: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
+DLLREL: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -962,6 +962,9 @@
       DynamicBaseArg->getOption().getID() == OPT_dynamicbase_no)
     Config->DynamicBase = false;
 
+  // MSDN claims "/FIXED:NO is the default setting for a DLL, and /FIXED is the
+  // default setting for any other project type.", but link.exe defaults to
+  // /FIXED:NO for exe outputs as well. Match behavior, not docs.
   bool Fixed = Args.hasFlag(OPT_fixed, OPT_fixed_no, false);
   if (Fixed) {
     if (DynamicBaseArg &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45087.140418.patch
Type: text/x-patch
Size: 1763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180330/25264f89/attachment.bin>


More information about the llvm-commits mailing list