[lld] r305679 - [ELF] Emit only one error if -z max-page-size without value
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 04:05:15 PDT 2017
Author: jhenderson
Date: Mon Jun 19 06:05:15 2017
New Revision: 305679
URL: http://llvm.org/viewvc/llvm-project?rev=305679&view=rev
Log:
[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
Added:
lld/trunk/test/ELF/invalid-z.s
Modified:
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=305679&r1=305678&r2=305679&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Jun 19 06:05:15 2017
@@ -301,7 +301,7 @@ static uint64_t getZOptionValue(opt::Inp
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;
Added: lld/trunk/test/ELF/invalid-z.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid-z.s?rev=305679&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid-z.s (added)
+++ lld/trunk/test/ELF/invalid-z.s Mon Jun 19 06:05:15 2017
@@ -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
More information about the llvm-commits
mailing list