libfuzzer実戦--cmakelists.txt一般的な変更ポリシー
1535 ワード
libfuzzer実戦--cmakelists.txt一般的な変更ポリシー
libfuzzerの真髄は、プログラムアーキテクチャを理解し、fuzzを加えることです.aosp,chromium,skiaのような大型工事杭fuzzの操作は,まず全体工事杭を挿入し,その後工事に独自のテストファイルを追加する.これもすべての大型プロジェクトLibfuzzerに対する使用方法である.
CCとCXXの設定
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(cov-flag -fsanitize-coverage=edge,indirect-calls,trace-cmp,trace-gep,trace-pc-guard)
set(CMAKE_CXX_FLAGS "-g -fsanitize=address")
set(CMAKE_C_FLAGS "-g -fsanitize=address ${cov-flag}")
CMakeLists.txtに独自のテストファイルを追加
add_executable(fuzz-ReadAnimatedImage
myfuzzer/fuzz-ReadAnimatedImage/fuzz_ReadAnimatedImage.cpp
)
target_compile_options(fuzz-ReadAnimatedImage PUBLIC -fsanitize=fuzzer,address -O3)
target_include_directories(fuzz-ReadAnimatedImage PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
target_include_directories(fuzz-ReadAnimatedImage PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(fuzz-ReadAnimatedImage PUBLIC .)
target_link_libraries(fuzz-ReadAnimatedImage exampleutil imagedec imageenc -fsanitize=address,fuzzer)
popplerくい
cmake .. -DBUILD_SHARED_LIBS=OFF -DENABLE_DCTDECODER=none -DENABLE_LIBOPENJPEG=none -DENABLE_CMS=none -DENABLE_LIBPNG=OFF -DENABLE_ZLIB=OFF -DENABLE_LIBTIFF=OFF -DENABLE_LIBJPEG=OFF -DENABLE_GLIB=OFF -DENABLE_LIBCURL=OFF -DENABLE_QT5=OFF -DENABLE_UTILS=OFF -DWITH_Cairo=OFF -DWITH_NSS3=OFF
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(cov-flag -fsanitize-coverage=edge,indirect-calls,trace-cmp,trace-gep,trace-pc-guard)
set(CMAKE_CXX_FLAGS "-g -fsanitize=address")
set(CMAKE_C_FLAGS "-g -fsanitize=address ${cov-flag}")
add_executable(fuzz-ReadAnimatedImage
myfuzzer/fuzz-ReadAnimatedImage/fuzz_ReadAnimatedImage.cpp
)
target_compile_options(fuzz-ReadAnimatedImage PUBLIC -fsanitize=fuzzer,address -O3)
target_include_directories(fuzz-ReadAnimatedImage PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
target_include_directories(fuzz-ReadAnimatedImage PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(fuzz-ReadAnimatedImage PUBLIC .)
target_link_libraries(fuzz-ReadAnimatedImage exampleutil imagedec imageenc -fsanitize=address,fuzzer)
cmake .. -DBUILD_SHARED_LIBS=OFF -DENABLE_DCTDECODER=none -DENABLE_LIBOPENJPEG=none -DENABLE_CMS=none -DENABLE_LIBPNG=OFF -DENABLE_ZLIB=OFF -DENABLE_LIBTIFF=OFF -DENABLE_LIBJPEG=OFF -DENABLE_GLIB=OFF -DENABLE_LIBCURL=OFF -DENABLE_QT5=OFF -DENABLE_UTILS=OFF -DWITH_Cairo=OFF -DWITH_NSS3=OFF