Add support for honggfuzz to BUILD_FUZZ_TEST

Change-Id: I38f70d1a57649635be95c59187da05ba22fcf687
This commit is contained in:
Zach Riggle 2017-12-21 16:04:03 -06:00
parent f3aa0668c2
commit 6319deed41
2 changed files with 43 additions and 0 deletions

View File

@ -93,6 +93,7 @@ LOCAL_FULL_LIBS_MANIFEST_FILES:=
LOCAL_FULL_MANIFEST_FILE:=
LOCAL_FULL_CLASSES_JACOCO_JAR:=
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR:=
LOCAL_FUZZ_ENGINE:=
LOCAL_GCNO_FILES:=
LOCAL_GENERATED_SOURCES:=
# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.

View File

@ -8,8 +8,50 @@ ifdef LOCAL_SDK_VERSION
$(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.)
endif
my_fuzzer:=libFuzzer
ifdef LOCAL_FUZZ_ENGINE
my_fuzzer:=$(LOCAL_FUZZ_ENGINE)
else ifdef TARGET_FUZZ_ENGINE
my_fuzzer:=$(TARGET_FUZZ_ENGINE)
endif
LOCAL_CFLAGS += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
ifeq ($(my_fuzzer),libFuzzer)
LOCAL_STATIC_LIBRARIES += libFuzzer
else ifeq ($(my_fuzzer),honggfuzz)
LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz
LOCAL_LDFLAGS += \
"-Wl,--wrap=strcmp" \
"-Wl,--wrap=strcasecmp" \
"-Wl,--wrap=strncmp" \
"-Wl,--wrap=strncasecmp" \
"-Wl,--wrap=strstr" \
"-Wl,--wrap=strcasestr" \
"-Wl,--wrap=memcmp" \
"-Wl,--wrap=bcmp" \
"-Wl,--wrap=memmem" \
"-Wl,--wrap=ap_cstr_casecmp" \
"-Wl,--wrap=ap_cstr_casecmpn" \
"-Wl,--wrap=ap_strcasestr" \
"-Wl,--wrap=apr_cstr_casecmp" \
"-Wl,--wrap=apr_cstr_casecmpn" \
"-Wl,--wrap=CRYPTO_memcmp" \
"-Wl,--wrap=OPENSSL_memcmp" \
"-Wl,--wrap=OPENSSL_strcasecmp" \
"-Wl,--wrap=OPENSSL_strncasecmp" \
"-Wl,--wrap=xmlStrncmp" \
"-Wl,--wrap=xmlStrcmp" \
"-Wl,--wrap=xmlStrEqual" \
"-Wl,--wrap=xmlStrcasecmp" \
"-Wl,--wrap=xmlStrncasecmp" \
"-Wl,--wrap=xmlStrstr" \
"-Wl,--wrap=xmlStrcasestr"
else
$(call pretty-error, Unknown fuzz engine $(my_fuzzer))
endif
ifdef LOCAL_MODULE_PATH
$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))