diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 59297eae8..5911f4cdc 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -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. diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk index 7e3995add..29e1dde48 100644 --- a/core/fuzz_test.mk +++ b/core/fuzz_test.mk @@ -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))