[PATCH] D48621: Report an error for an unknown -z option.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 26 23:28:55 PDT 2018
ruiu created this revision.
ruiu added a reviewer: grimar.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
This is a less clever version of https://reviews.llvm.org/D48433.
This is a dumb version but I think I prefer this for its simplicity.
https://reviews.llvm.org/D48621
Files:
lld/ELF/Driver.cpp
lld/test/ELF/driver.test
Index: lld/test/ELF/driver.test
===================================================================
--- lld/test/ELF/driver.test
+++ lld/test/ELF/driver.test
@@ -55,6 +55,9 @@
# RUN: not ld.lld %t -output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR8 %s
# ERR8: cannot open output file utput=/no/such/file
+# RUN: not ld.lld %t -z foo 2>&1 | FileCheck -check-prefix=ERR9 %s
+# ERR9: unknown -z value: foo
+
.globl _start
_start:
nop
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -325,6 +325,25 @@
return Default;
}
+static bool isKnown(StringRef S) {
+ return S == "combreloc" || S == "copyreloc" || S == "defs" ||
+ S == "execstack" || S == "hazardplt" || S == "initfirst" ||
+ S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
+ S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" ||
+ S == "nodlopen" || S == "noexecstack" ||
+ S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" ||
+ S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" ||
+ S == "rodynamic" || S == "text" || S == "wxneeded" ||
+ S.startswith("max-page-size") || S.startswith("stack-size");
+}
+
+// Report an error for an unknown -z option.
+static void checkZOptions(opt::InputArgList &Args) {
+ for (auto *Arg : Args.filtered(OPT_z))
+ if (!isKnown(Arg->getValue()))
+ error("unknown -z value: " + StringRef(Arg->getValue()));
+}
+
void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
ELFOptTable Parser;
opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -380,6 +399,7 @@
}
readConfigs(Args);
+ checkZOptions(Args);
initLLVM();
createFiles(Args);
if (errorCount())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48621.153004.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180627/1b55c372/attachment.bin>
More information about the llvm-commits
mailing list