summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Henderson <jh7370@my.bristol.ac.uk>2017-06-19 11:05:15 +0000
committerJames Henderson <jh7370@my.bristol.ac.uk>2017-06-19 11:05:15 +0000
commit38e67e82121f9e9fb8250117383f1d7917986040 (patch)
treeeb13cc2ef78311b341a1816bcc1499ee0616c077
parentdad1e1a3b50b035eecfc5e225b736796a232b09c (diff)
downloadbcm5719-llvm-38e67e82121f9e9fb8250117383f1d7917986040.tar.gz
bcm5719-llvm-38e67e82121f9e9fb8250117383f1d7917986040.zip
[ELF] Emit only one error if -z max-page-size without value
In r305364, Rui changed the mechanism that parses -z option values slightly. This caused a bug, as demonstrated by this test, which now fails: --- # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: ld.lld %t.o -o %t -z max-page-size .global _start _start: nop --- Before, the link succeeded and set the max-page-size to the target default. After we get the following two error messages: "invalid max-page-size: " "max-page-size: value isn't a power of 2" The latter error is because an uninitialised variable ends up being passed back to getMaxPageSize). This change ensures we only get the first error. Reviewers: ruiu Differential Revision: https://reviews.llvm.org/D34234 llvm-svn: 305679
-rw-r--r--lld/ELF/Driver.cpp2
-rw-r--r--lld/test/ELF/invalid-z.s9
2 files changed, 10 insertions, 1 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index c87ffa26af8..1d966b45444 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -301,7 +301,7 @@ static uint64_t getZOptionValue(opt::InputArgList &Args, StringRef Key,
for (auto *Arg : Args.filtered(OPT_z)) {
std::pair<StringRef, StringRef> KV = StringRef(Arg->getValue()).split('=');
if (KV.first == Key) {
- uint64_t Result;
+ uint64_t Result = Default;
if (!to_integer(KV.second, Result))
error("invalid " + Key + ": " + KV.second);
return Result;
diff --git a/lld/test/ELF/invalid-z.s b/lld/test/ELF/invalid-z.s
new file mode 100644
index 00000000000..10415526e0c
--- /dev/null
+++ b/lld/test/ELF/invalid-z.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: not ld.lld %t.o -o %t -z max-page-size 2>&1 | FileCheck %s
+# CHECK: invalid max-page-size
+# CHECK-NOT: error
+
+.global _start
+_start:
+ nop
OpenPOWER on IntegriCloud