diff options
author | Phil Turnbull <philipturnbull@github.com> | 2017-06-26 15:05:30 -0400 |
---|---|---|
committer | Phil Turnbull <philipturnbull@github.com> | 2017-06-27 15:37:04 -0400 |
commit | c1dea4ee507ef62b121051e34e36a9b24459ea39 (patch) | |
tree | b08c2272ff191ea8ee29ebac00ecd9bd8b89aa84 /src | |
parent | 70a6a168146baa6ab0df33d4ddf424ba5d40b151 (diff) |
Add Makefile target and harness to fuzz with libFuzzer
This can be run locally with `make libFuzzer` but the harness will be
integrated into oss-fuzz for large-scale fuzzing.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f52ded6..3197196 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,3 +186,14 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "Ubsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") endif() + +if(CMARK_LIB_FUZZER) + set(FUZZ_HARNESS "cmark-fuzz") + add_executable(${FUZZ_HARNESS} ../test/cmark-fuzz.c ${LIBRARY_SOURCES}) + target_link_libraries(${FUZZ_HARNESS} "${CMAKE_LIB_FUZZER_PATH}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=trace-pc-guard") + + # cmark is written in C but the libFuzzer runtime is written in C++ which + # needs to link against the C++ runtime. Explicitly link it into cmark-fuzz + set_target_properties(${FUZZ_HARNESS} PROPERTIES LINK_FLAGS "-lstdc++") +endif() |