2016-05-26 22:55:05 +02:00
|
|
|
set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}")
|
2015-03-31 00:09:51 +02:00
|
|
|
# Disable the coverage and sanitizer instrumentation for the fuzzer itself.
|
2016-08-24 03:38:42 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror")
|
2015-04-06 18:09:13 +02:00
|
|
|
if( LLVM_USE_SANITIZE_COVERAGE )
|
2016-05-26 22:55:09 +02:00
|
|
|
if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address")
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"LibFuzzer and its tests require LLVM_USE_SANITIZER=Address and "
|
|
|
|
"LLVM_USE_SANITIZE_COVERAGE=YES to be set."
|
|
|
|
)
|
|
|
|
endif()
|
2015-05-23 00:35:31 +02:00
|
|
|
add_library(LLVMFuzzerNoMainObjects OBJECT
|
2015-01-29 17:58:29 +01:00
|
|
|
FuzzerCrossOver.cpp
|
2015-05-11 23:16:27 +02:00
|
|
|
FuzzerTraceState.cpp
|
2015-02-19 19:45:37 +01:00
|
|
|
FuzzerDriver.cpp
|
2016-06-02 07:48:02 +02:00
|
|
|
FuzzerExtFunctionsDlsym.cpp
|
|
|
|
FuzzerExtFunctionsWeak.cpp
|
2015-01-29 17:58:29 +01:00
|
|
|
FuzzerIO.cpp
|
|
|
|
FuzzerLoop.cpp
|
|
|
|
FuzzerMutate.cpp
|
2015-05-15 00:41:49 +02:00
|
|
|
FuzzerSHA1.cpp
|
2016-02-26 22:33:56 +01:00
|
|
|
FuzzerTracePC.cpp
|
2015-01-29 17:58:29 +01:00
|
|
|
FuzzerUtil.cpp
|
2016-08-12 20:29:36 +02:00
|
|
|
FuzzerUtilDarwin.cpp
|
|
|
|
FuzzerUtilLinux.cpp
|
2015-01-29 17:58:29 +01:00
|
|
|
)
|
2015-05-23 00:35:31 +02:00
|
|
|
add_library(LLVMFuzzerNoMain STATIC
|
|
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
|
|
|
|
)
|
2016-03-01 16:54:40 +01:00
|
|
|
target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB})
|
2015-01-31 00:26:57 +01:00
|
|
|
add_library(LLVMFuzzer STATIC
|
|
|
|
FuzzerMain.cpp
|
2015-05-23 00:35:31 +02:00
|
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
|
2015-01-31 00:26:57 +01:00
|
|
|
)
|
2016-03-01 16:54:40 +01:00
|
|
|
target_link_libraries(LLVMFuzzer ${PTHREAD_LIB})
|
2015-01-29 17:58:29 +01:00
|
|
|
|
|
|
|
if( LLVM_INCLUDE_TESTS )
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
endif()
|