/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.
Differential Revision: https://reviews.llvm.org/D70163
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
# 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
+
+# RUN: lld-link /out:%t.exe /entry:main %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