summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-01-15 00:17:37 +0000
committerKostya Serebryany <kcc@google.com>2016-01-15 00:17:37 +0000
commit4282d30516cd836ac72e053cff7555d0595f5ece (patch)
tree488d3d5b96f54825b79a6f57dd7eb41650978731 /llvm/lib
parent35bafeea4a36a45a41629c65c6b101429f1ae0da (diff)
downloadbcm5719-llvm-4282d30516cd836ac72e053cff7555d0595f5ece.tar.gz
bcm5719-llvm-4282d30516cd836ac72e053cff7555d0595f5ece.zip
[libFuzzer] use custom stol; also introduce __libfuzzer_is_present so that users can check for its presence.
llvm-svn: 257848
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Fuzzer/FuzzerDriver.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerDriver.cpp b/llvm/lib/Fuzzer/FuzzerDriver.cpp
index 66e46dbf3aa..eaa308cac72 100644
--- a/llvm/lib/Fuzzer/FuzzerDriver.cpp
+++ b/llvm/lib/Fuzzer/FuzzerDriver.cpp
@@ -23,6 +23,10 @@
#include <algorithm>
#include <iterator>
+// This function should be present in the libFuzzer so that the client
+// binary can test for its existence.
+extern "C" __attribute__((used)) void __libfuzzer_is_present() {}
+
namespace fuzzer {
// Program arguments.
@@ -93,6 +97,18 @@ static const char *FlagValue(const char *Param, const char *Name) {
return nullptr;
}
+// Avoid calling stol as it triggers a bug in clang/glibc build.
+static long MyStol(const char *Str) {
+ long Res = 0;
+ for (size_t i = 0; Str[i]; i++) {
+ char Ch = Str[i];
+ if (Ch < '0' || Ch > '9')
+ return Res;
+ Res = Res * 10 + (Ch - '0');
+ }
+ return Res;
+}
+
static bool ParseOneFlag(const char *Param) {
if (Param[0] != '-') return false;
if (Param[1] == '-') {
@@ -108,7 +124,7 @@ static bool ParseOneFlag(const char *Param) {
const char *Str = FlagValue(Param, Name);
if (Str) {
if (FlagDescriptions[F].IntFlag) {
- int Val = std::stol(Str);
+ int Val = MyStol(Str);
*FlagDescriptions[F].IntFlag = Val;
if (Flags.verbosity >= 2)
Printf("Flag: %s %d\n", Name, Val);;
OpenPOWER on IntegriCloud