From 6319deed41c1f13eb9a7291d428042d337eedb7d Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Thu, 21 Dec 2017 16:04:03 -0600 Subject: [PATCH] Add support for honggfuzz to BUILD_FUZZ_TEST Change-Id: I38f70d1a57649635be95c59187da05ba22fcf687 --- core/clear_vars.mk | 1 + core/fuzz_test.mk | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) 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))