summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2017-08-30 22:44:11 +0000
committerKamil Rytarowski <n54@gmx.com>2017-08-30 22:44:11 +0000
commit8da2722a9f5146067ce650583ea6b32eaa663c8a (patch)
treefa49041a525a579cc69d96fcf9ceca7df3e803a8 /compiler-rt
parent76794daf05456edd3042906fd2670ea7a32e977c (diff)
downloadbcm5719-llvm-8da2722a9f5146067ce650583ea6b32eaa663c8a.tar.gz
bcm5719-llvm-8da2722a9f5146067ce650583ea6b32eaa663c8a.zip
Add preliminary NetBSD support in libfuzzer
Summary: This code already works and passes some number of tests. There is need to finish remaining sanitizers to get better coverage. Many tests fail due to overly long file names of executables (>31). This is a current shortcoming of the NetBSD 8(beta) kernel, as certain functions can fail (like retrieving file name of executable). Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, george.karpenkov Reviewed By: kcc Subscribers: mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37304 llvm-svn: 312183
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/cmake/config-ix.cmake2
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerDefs.h10
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp4
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp2
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp4
-rw-r--r--compiler-rt/lib/fuzzer/afl/afl_driver.cpp8
6 files changed, 22 insertions, 8 deletions
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index d5ef46e255b..d688abccb27 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -588,7 +588,7 @@ else()
endif()
if (COMPILER_RT_HAS_SANITIZER_COMMON AND FUZZER_SUPPORTED_ARCH AND
- OS_NAME MATCHES "Darwin|Linux")
+ OS_NAME MATCHES "Darwin|Linux|NetBSD")
set(COMPILER_RT_HAS_FUZZER TRUE)
else()
set(COMPILER_RT_HAS_FUZZER FALSE)
diff --git a/compiler-rt/lib/fuzzer/FuzzerDefs.h b/compiler-rt/lib/fuzzer/FuzzerDefs.h
index 7ea54a92062..e8c92ae3f11 100644
--- a/compiler-rt/lib/fuzzer/FuzzerDefs.h
+++ b/compiler-rt/lib/fuzzer/FuzzerDefs.h
@@ -25,14 +25,22 @@
#ifdef __linux__
#define LIBFUZZER_APPLE 0
#define LIBFUZZER_LINUX 1
+#define LIBFUZZER_NETBSD 0
#define LIBFUZZER_WINDOWS 0
#elif __APPLE__
#define LIBFUZZER_APPLE 1
#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_WINDOWS 0
+#elif __NetBSD__
+#define LIBFUZZER_APPLE 0
+#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_NETBSD 1
#define LIBFUZZER_WINDOWS 0
#elif _WIN32
#define LIBFUZZER_APPLE 0
#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_NETBSD 0
#define LIBFUZZER_WINDOWS 1
#else
#error "Support for your platform has not been implemented"
@@ -42,7 +50,7 @@
# define __has_attribute(x) 0
#endif
-#define LIBFUZZER_POSIX LIBFUZZER_APPLE || LIBFUZZER_LINUX
+#define LIBFUZZER_POSIX (LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD)
#ifdef __x86_64
# if __has_attribute(target)
diff --git a/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp b/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
index 503f0395cf8..5056eb8a962 100644
--- a/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
@@ -13,7 +13,7 @@
// to clients right now.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
@@ -51,4 +51,4 @@ ExternalFunctions::ExternalFunctions() {
} // namespace fuzzer
-#endif // LIBFUZZER_LINUX
+#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD
diff --git a/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp b/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
index 07dbe0fdee7..0e7a7761bf8 100644
--- a/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
@@ -11,7 +11,7 @@
#include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD
__attribute__((weak)) extern uint8_t __start___libfuzzer_extra_counters;
__attribute__((weak)) extern uint8_t __stop___libfuzzer_extra_counters;
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
index dfe7e6f4e18..69d46b578c0 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
@@ -9,7 +9,7 @@
// Misc utils for Linux.
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
-#if LIBFUZZER_LINUX
+#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD
#include <stdlib.h>
@@ -21,4 +21,4 @@ int ExecuteCommand(const std::string &Command) {
} // namespace fuzzer
-#endif // LIBFUZZER_LINUX
+#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD
diff --git a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
index 15bceb896e1..f1024794785 100644
--- a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
+++ b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
@@ -68,9 +68,15 @@ statistics from the file. If that fails then the process will quit.
#ifdef __linux__
#define LIBFUZZER_LINUX 1
#define LIBFUZZER_APPLE 0
+#define LIBFUZZER_NETBSD 0
#elif __APPLE__
#define LIBFUZZER_LINUX 0
#define LIBFUZZER_APPLE 1
+#define LIBFUZZER_NETBSD 0
+#elif __NetBSD__
+#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_APPLE 0
+#define LIBFUZZER_NETBSD 1
#else
#error "Support for your platform has not been implemented"
#endif
@@ -119,7 +125,7 @@ size_t GetPeakRSSMb() {
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage))
return 0;
- if (LIBFUZZER_LINUX) {
+ if (LIBFUZZER_LINUX || LIBFUZZER_NETBSD) {
// ru_maxrss is in KiB
return usage.ru_maxrss >> 10;
} else if (LIBFUZZER_APPLE) {
OpenPOWER on IntegriCloud