mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
ae0620c4e9
Introduce -mllvm -sanitizer-coverage-8bit-counters=1 which adds imprecise thread-unfriendly 8-bit coverage counters. The run-time library maps these 8-bit counters to 8-bit bitsets in the same way AFL (http://lcamtuf.coredump.cx/afl/technical_details.txt) does: counter values are divided into 8 ranges and based on the counter value one of the bits in the bitset is set. The AFL ranges are used here: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+. These counters provide a search heuristic for single-threaded coverage-guided fuzzers, we do not expect them to be useful for other purposes. Depending on the value of -fsanitize-coverage=[123] flag, these counters will be added to the function entry blocks (=1), every basic block (=2), or every edge (=3). Use these counters as an optional search heuristic in the Fuzzer library. Add a test where this heuristic is critical. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231166 91177308-0d34-0410-b5e6-96231b3b80d8
63 lines
1.5 KiB
CMake
63 lines
1.5 KiB
CMake
# Build all these tests with -O0, otherwise optimizations may merge some
|
|
# basic blocks and we'll fail to discover the targets.
|
|
# Also enable the coverage instrumentation back (it is disabled
|
|
# for the Fuzzer lib)
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O0 -fsanitize-coverage=4")
|
|
|
|
set(Tests
|
|
CounterTest
|
|
FourIndependentBranchesTest
|
|
FullCoverageSetTest
|
|
InfiniteTest
|
|
NullDerefTest
|
|
SimpleTest
|
|
TimeoutTest
|
|
)
|
|
|
|
set(TestBinaries)
|
|
|
|
foreach(Test ${Tests})
|
|
add_executable(LLVMFuzzer-${Test}
|
|
EXCLUDE_FROM_ALL
|
|
${Test}.cpp
|
|
)
|
|
target_link_libraries(LLVMFuzzer-${Test}
|
|
LLVMFuzzer
|
|
)
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
|
|
endforeach()
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
)
|
|
|
|
configure_lit_site_cfg(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg
|
|
)
|
|
|
|
include_directories(..)
|
|
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
|
|
|
|
add_executable(LLVMFuzzer-Unittest
|
|
FuzzerUnittest.cpp
|
|
$<TARGET_OBJECTS:LLVMFuzzerNoMain>
|
|
)
|
|
|
|
target_link_libraries(LLVMFuzzer-Unittest
|
|
gtest
|
|
gtest_main
|
|
)
|
|
|
|
set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest)
|
|
|
|
set_target_properties(${TestBinaries}
|
|
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
)
|
|
|
|
add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
DEPENDS ${TestBinaries} FileCheck not
|
|
)
|