[PATCH] D70163: Warn on /align if used without /driver

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 12 22:18:12 PST 2019


ruiu created this revision.
ruiu added a reviewer: thakis.
Herald added a project: LLVM.

/align is not supposed to be used without /driver, so it makes
sense to warn if only /align is passed. MSVC link.exe warns on
this too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70163

Files:
  lld/COFF/Driver.cpp
  lld/test/COFF/align.s


Index: lld/test/COFF/align.s
===================================================================
--- lld/test/COFF/align.s
+++ lld/test/COFF/align.s
@@ -4,6 +4,16 @@
 
 # CHECK: SectionAlignment: 32
 
+# RUN: lld-link /out:%t.exe /entry:main /align:32 %t.obj 2>&1 \
+# RUN:   | FileCheck -check-prefix=WARN1 %s
+
+# WARN1: /align specified without /driver; image may not run
+
+# RUN: lld-link /out:%t.exe /entry:main /align:32 %t.obj /driver 2>&1 \
+# RUN:   | FileCheck -check-prefix=WARN2 --allow-empty %s
+
+# WARN2-NOT: /align specified without /driver; image may not run
+
 --- !COFF
 header:
   Machine:         IMAGE_FILE_MACHINE_AMD64
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1462,6 +1462,8 @@
     parseNumbers(arg->getValue(), &config->align);
     if (!isPowerOf2_64(config->align))
       error("/align: not a power of two: " + StringRef(arg->getValue()));
+    if (!args.hasArg(OPT_driver))
+      warn("/align specified without /driver; image may not run");
   }
 
   // Handle /aligncomm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70163.229006.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191113/2389e73f/attachment-0001.bin>


More information about the llvm-commits mailing list