diff options
28 files changed, 52 insertions, 16 deletions
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 9e0c4774829..b6798daf826 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -604,7 +604,7 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND FUZZER_SUPPORTED_ARCH AND - OS_NAME MATCHES "Android|Darwin|Linux|NetBSD") + OS_NAME MATCHES "Android|Darwin|Linux|NetBSD|FreeBSD") 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 5942efc47a4..6c53e6347b4 100644 --- a/compiler-rt/lib/fuzzer/FuzzerDefs.h +++ b/compiler-rt/lib/fuzzer/FuzzerDefs.h @@ -27,30 +27,42 @@ #define LIBFUZZER_FUCHSIA 0 #define LIBFUZZER_LINUX 1 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #define LIBFUZZER_WINDOWS 0 #elif __APPLE__ #define LIBFUZZER_APPLE 1 #define LIBFUZZER_FUCHSIA 0 #define LIBFUZZER_LINUX 0 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #define LIBFUZZER_WINDOWS 0 #elif __NetBSD__ #define LIBFUZZER_APPLE 0 #define LIBFUZZER_FUCHSIA 0 #define LIBFUZZER_LINUX 0 #define LIBFUZZER_NETBSD 1 +#define LIBFUZZER_FREEBSD 0 +#define LIBFUZZER_WINDOWS 0 +#elif __FreeBSD__ +#define LIBFUZZER_APPLE 0 +#define LIBFUZZER_FUCHSIA 0 +#define LIBFUZZER_LINUX 0 +#define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 1 #define LIBFUZZER_WINDOWS 0 #elif _WIN32 #define LIBFUZZER_APPLE 0 #define LIBFUZZER_FUCHSIA 0 #define LIBFUZZER_LINUX 0 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #define LIBFUZZER_WINDOWS 1 #elif __Fuchsia__ #define LIBFUZZER_APPLE 0 #define LIBFUZZER_FUCHSIA 1 #define LIBFUZZER_LINUX 0 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #define LIBFUZZER_WINDOWS 0 #else #error "Support for your platform has not been implemented" @@ -60,7 +72,7 @@ # define __has_attribute(x) 0 #endif -#define LIBFUZZER_POSIX (LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD) +#define LIBFUZZER_POSIX (LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD) #ifdef __x86_64 # if __has_attribute(target) diff --git a/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp b/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp index 5a90723986a..7c47dfae312 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 || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA +#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA || LIBFUZZER_FREEBSD #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" @@ -51,4 +51,4 @@ ExternalFunctions::ExternalFunctions() { } // namespace fuzzer -#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD +#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUSCHIA || LIBFUZZER_FREEBSD diff --git a/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp b/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp index 0e7a7761bf8..d98598ab2f3 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 || LIBFUZZER_NETBSD +#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD __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 c7cf2c0a778..f8b5d11c534 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 || LIBFUZZER_NETBSD +#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD #include "FuzzerCommand.h" #include <stdlib.h> @@ -23,4 +23,4 @@ int ExecuteCommand(const Command &Cmd) { } // namespace fuzzer -#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD +#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp index 934b7aa98ff..cef6cec1ccb 100644 --- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp @@ -118,7 +118,7 @@ size_t GetPeakRSSMb() { struct rusage usage; if (getrusage(RUSAGE_SELF, &usage)) return 0; - if (LIBFUZZER_LINUX) { + if (LIBFUZZER_LINUX || LIBFUZZER_FREEBSD || LIBFUZZER_NETBSD) { // ru_maxrss is in KiB return usage.ru_maxrss >> 10; } else if (LIBFUZZER_APPLE) { diff --git a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp index bbe5be795ed..616ce4d471f 100644 --- a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp +++ b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp @@ -69,14 +69,22 @@ statistics from the file. If that fails then the process will quit. #define LIBFUZZER_LINUX 1 #define LIBFUZZER_APPLE 0 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #elif __APPLE__ #define LIBFUZZER_LINUX 0 #define LIBFUZZER_APPLE 1 #define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 0 #elif __NetBSD__ #define LIBFUZZER_LINUX 0 #define LIBFUZZER_APPLE 0 #define LIBFUZZER_NETBSD 1 +#define LIBFUZZER_FREEBSD 0 +#elif __FreeBSD__ +#define LIBFUZZER_LINUX 0 +#define LIBFUZZER_APPLE 0 +#define LIBFUZZER_NETBSD 0 +#define LIBFUZZER_FREEBSD 1 #else #error "Support for your platform has not been implemented" #endif @@ -125,7 +133,7 @@ size_t GetPeakRSSMb() { struct rusage usage; if (getrusage(RUSAGE_SELF, &usage)) return 0; - if (LIBFUZZER_LINUX || LIBFUZZER_NETBSD) { + if (LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD) { // ru_maxrss is in KiB return usage.ru_maxrss >> 10; } else if (LIBFUZZER_APPLE) { diff --git a/compiler-rt/lib/fuzzer/build.sh b/compiler-rt/lib/fuzzer/build.sh index 4556af5daf7..160d25199c5 100755 --- a/compiler-rt/lib/fuzzer/build.sh +++ b/compiler-rt/lib/fuzzer/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash LIBFUZZER_SRC_DIR=$(dirname $0) CXX="${CXX:-clang}" for f in $LIBFUZZER_SRC_DIR/*.cpp; do diff --git a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt index dac8773597e..9d888f0549e 100644 --- a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt +++ b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt @@ -12,8 +12,8 @@ set_target_properties(FuzzerUnitTests PROPERTIES FOLDER "Compiler-RT Tests") set(LIBFUZZER_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_LINK_FLAGS}) list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS --driver-mode=g++) -if(APPLE) - list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lc++) +if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lc++ -lpthread) else() list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lstdc++ -lpthread) endif() diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index dc480e75f98..7ba7adaae9b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -36,7 +36,7 @@ #endif // TLS is handled differently on different platforms -#if SANITIZER_LINUX || SANITIZER_NETBSD +#if SANITIZER_LINUX || SANITIZER_NETBSD || SANITIZER_FREEBSD # define SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE \ __attribute__((tls_model("initial-exec"))) thread_local #else diff --git a/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp b/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp index 5603af344cb..2b83d3597f3 100644 --- a/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp +++ b/compiler-rt/test/fuzzer/TraceMallocThreadedTest.cpp @@ -7,6 +7,7 @@ #include <cstddef> #include <cstdint> #include <cstring> +#include <cstdlib> #include <thread> extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { diff --git a/compiler-rt/test/fuzzer/afl-driver-stderr.test b/compiler-rt/test/fuzzer/afl-driver-stderr.test index be0efaa8f03..0ba5e36a739 100644 --- a/compiler-rt/test/fuzzer/afl-driver-stderr.test +++ b/compiler-rt/test/fuzzer/afl-driver-stderr.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %no_fuzzer_cpp_compiler -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters,trace-pc-guard %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.cpp -o %t-AFLDriverTest ; Test that not specifying a stderr file isn't broken. diff --git a/compiler-rt/test/fuzzer/caller-callee.test b/compiler-rt/test/fuzzer/caller-callee.test index e4eccdc307a..6690bb21c5a 100644 --- a/compiler-rt/test/fuzzer/caller-callee.test +++ b/compiler-rt/test/fuzzer/caller-callee.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/CallerCalleeTest.cpp -o %t-CallerCalleeTest CHECK: BINGO RUN: not %t-CallerCalleeTest -use_value_profile=1 -cross_over=0 -seed=1 -runs=10000000 2>&1 | FileCheck %s diff --git a/compiler-rt/test/fuzzer/cxxstring.test b/compiler-rt/test/fuzzer/cxxstring.test index 7bb341ba22b..a4e478ddb3f 100644 --- a/compiler-rt/test/fuzzer/cxxstring.test +++ b/compiler-rt/test/fuzzer/cxxstring.test @@ -1,4 +1,4 @@ -UNSUPPORTED: windows +UNSUPPORTED: windows,freebsd RUN: %cpp_compiler %S/CxxStringEqTest.cpp -o %t-CxxStringEqTest diff --git a/compiler-rt/test/fuzzer/dump_coverage.test b/compiler-rt/test/fuzzer/dump_coverage.test index b240089ce23..dd3e73e44c0 100644 --- a/compiler-rt/test/fuzzer/dump_coverage.test +++ b/compiler-rt/test/fuzzer/dump_coverage.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO1.cpp -fPIC -shared -o %t-DSO1.so RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO2.cpp -fPIC -shared -o %t-DSO2.so RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSOTestMain.cpp %S/DSOTestExtra.cpp -L. %t-DSO1.so %t-DSO2.so -o %t-DSOTest diff --git a/compiler-rt/test/fuzzer/equivalence-signals.test b/compiler-rt/test/fuzzer/equivalence-signals.test index 7951636e85f..b9054c5dab7 100644 --- a/compiler-rt/test/fuzzer/equivalence-signals.test +++ b/compiler-rt/test/fuzzer/equivalence-signals.test @@ -1,6 +1,7 @@ # Run EquivalenceATest against itself with a small timeout # to stress the signal handling and ensure that shmem doesn't mind # the signals. +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/EquivalenceATest.cpp -o %t-EquivalenceATest RUN: %t-EquivalenceATest -timeout=1 -run_equivalence_server=EQUIV_SIG_TEST & export APID=$! diff --git a/compiler-rt/test/fuzzer/equivalence.test b/compiler-rt/test/fuzzer/equivalence.test index 12964f478a4..24bb9d78979 100644 --- a/compiler-rt/test/fuzzer/equivalence.test +++ b/compiler-rt/test/fuzzer/equivalence.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/EquivalenceATest.cpp -o %t-EquivalenceATest RUN: %cpp_compiler %S/EquivalenceBTest.cpp -o %t-EquivalenceBTest diff --git a/compiler-rt/test/fuzzer/lit.cfg b/compiler-rt/test/fuzzer/lit.cfg index 0350a1ad779..6a2108cbf23 100644 --- a/compiler-rt/test/fuzzer/lit.cfg +++ b/compiler-rt/test/fuzzer/lit.cfg @@ -25,7 +25,7 @@ else: config.test_format = lit.formats.ShTest(execute_external) # LeakSanitizer is not supported on OSX right now. -if sys.platform.startswith('darwin'): +if sys.platform.startswith('darwin') or sys.platform.startswith('freebsd'): lit_config.note('lsan feature unavailable') else: lit_config.note('lsan feature available') @@ -51,7 +51,7 @@ config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root)) def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True): compiler_cmd = config.c_compiler - link_cmd = '-lc++' if 'darwin' in config.target_triple else '-lstdc++' + link_cmd = '-lc++' if 'darwin' or 'freebsd' in config.target_triple else '-lstdc++' std_cmd = '-std=c++11' if is_cpp else '' sanitizers = ['address'] if fuzzer_enabled: diff --git a/compiler-rt/test/fuzzer/memcmp.test b/compiler-rt/test/fuzzer/memcmp.test index 3431a524ced..2cc666ce616 100644 --- a/compiler-rt/test/fuzzer/memcmp.test +++ b/compiler-rt/test/fuzzer/memcmp.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest RUN: not %t-MemcmpTest -seed=1 -runs=10000000 2>&1 | FileCheck %s CHECK: BINGO diff --git a/compiler-rt/test/fuzzer/memcmp64.test b/compiler-rt/test/fuzzer/memcmp64.test index 223c3bd42a7..1b23ce856be 100644 --- a/compiler-rt/test/fuzzer/memcmp64.test +++ b/compiler-rt/test/fuzzer/memcmp64.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest RUN: not %t-Memcmp64BytesTest -seed=1 -runs=1000000 2>&1 | FileCheck %s CHECK: BINGO diff --git a/compiler-rt/test/fuzzer/minimize_two_crashes.test b/compiler-rt/test/fuzzer/minimize_two_crashes.test index e6ff9990ffd..60dce8883e8 100644 --- a/compiler-rt/test/fuzzer/minimize_two_crashes.test +++ b/compiler-rt/test/fuzzer/minimize_two_crashes.test @@ -1,4 +1,5 @@ # Test that the minimizer stops when it sees a differe bug. +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/TwoDifferentBugsTest.cpp -o %t-TwoDifferentBugsTest diff --git a/compiler-rt/test/fuzzer/recommended-dictionary.test b/compiler-rt/test/fuzzer/recommended-dictionary.test index 41b62c924ce..3c38837b6fe 100644 --- a/compiler-rt/test/fuzzer/recommended-dictionary.test +++ b/compiler-rt/test/fuzzer/recommended-dictionary.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/RepeatedMemcmp.cpp -o %t-RepeatedMemcmp RUN: %t-RepeatedMemcmp -seed=11 -runs=100000 -max_len=20 2>&1 | FileCheck %s --check-prefix=RECOMMENDED_DICT RECOMMENDED_DICT:###### Recommended dictionary. ###### diff --git a/compiler-rt/test/fuzzer/strcmp.test b/compiler-rt/test/fuzzer/strcmp.test index 47ad8f9ba0f..c8d7cf81538 100644 --- a/compiler-rt/test/fuzzer/strcmp.test +++ b/compiler-rt/test/fuzzer/strcmp.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest RUN: not %t-StrcmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s CHECK: BINGO diff --git a/compiler-rt/test/fuzzer/strncmp.test b/compiler-rt/test/fuzzer/strncmp.test index 49693c8de8f..9f4e4be6d2a 100644 --- a/compiler-rt/test/fuzzer/strncmp.test +++ b/compiler-rt/test/fuzzer/strncmp.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest RUN: not %t-StrncmpTest -seed=2 -runs=10000000 2>&1 | FileCheck %s CHECK: BINGO diff --git a/compiler-rt/test/fuzzer/strstr.test b/compiler-rt/test/fuzzer/strstr.test index c39d5801acd..3583ab05d0d 100644 --- a/compiler-rt/test/fuzzer/strstr.test +++ b/compiler-rt/test/fuzzer/strstr.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest RUN: not %t-StrstrTest -seed=1 -runs=2000000 2>&1 | FileCheck %s CHECK: BINGO diff --git a/compiler-rt/test/fuzzer/value-profile-mem.test b/compiler-rt/test/fuzzer/value-profile-mem.test index 0b0c21d689c..dfa23e86de3 100644 --- a/compiler-rt/test/fuzzer/value-profile-mem.test +++ b/compiler-rt/test/fuzzer/value-profile-mem.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd CHECK: BINGO RUN: %cpp_compiler %S/SingleMemcmpTest.cpp -o %t-SingleMemcmpTest RUN: not %t-SingleMemcmpTest -seed=1 -use_cmp=0 -use_value_profile=1 -runs=10000000 2>&1 | FileCheck %s diff --git a/compiler-rt/test/fuzzer/value-profile-strcmp.test b/compiler-rt/test/fuzzer/value-profile-strcmp.test index f5c766a658f..a686a7bb381 100644 --- a/compiler-rt/test/fuzzer/value-profile-strcmp.test +++ b/compiler-rt/test/fuzzer/value-profile-strcmp.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd CHECK: BINGO RUN: %cpp_compiler %S/SingleStrcmpTest.cpp -o %t-SingleStrcmpTest RUN: not %t-SingleStrcmpTest -seed=1 -use_cmp=0 -use_value_profile=1 -runs=10000000 2>&1 | FileCheck %s diff --git a/compiler-rt/test/fuzzer/value-profile-strncmp.test b/compiler-rt/test/fuzzer/value-profile-strncmp.test index 2dfe43c4abc..c97a37ac04c 100644 --- a/compiler-rt/test/fuzzer/value-profile-strncmp.test +++ b/compiler-rt/test/fuzzer/value-profile-strncmp.test @@ -1,3 +1,4 @@ +UNSUPPORTED: freebsd CHECK: BINGO RUN: %cpp_compiler %S/SingleStrncmpTest.cpp -o %t-SingleStrncmpTest RUN: not %t-SingleStrncmpTest -seed=1 -use_cmp=0 -use_value_profile=1 -runs=100000000 2>&1 | FileCheck %s |

