1 ########################################### 2 ## A thin wrapper around BUILD_EXECUTABLE 3 ## Common flags for fuzz tests are added. 4 ########################################### 5 $(call record-module-type,FUZZ_TEST) 6 7 ifdef LOCAL_SDK_VERSION 8 $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.) 9 endif 10 11 my_fuzzer:=libFuzzer 12 ifdef LOCAL_FUZZ_ENGINE 13 my_fuzzer:=$(LOCAL_FUZZ_ENGINE) 14 else ifdef TARGET_FUZZ_ENGINE 15 my_fuzzer:=$(TARGET_FUZZ_ENGINE) 16 endif 17 18 19 LOCAL_CFLAGS += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp 20 21 ifeq ($(my_fuzzer),libFuzzer) 22 LOCAL_STATIC_LIBRARIES += libFuzzer 23 else ifeq ($(my_fuzzer),honggfuzz) 24 LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz 25 LOCAL_REQUIRED_MODULES += honggfuzz 26 LOCAL_LDFLAGS += \ 27 "-Wl,--wrap=strcmp" \ 28 "-Wl,--wrap=strcasecmp" \ 29 "-Wl,--wrap=strncmp" \ 30 "-Wl,--wrap=strncasecmp" \ 31 "-Wl,--wrap=strstr" \ 32 "-Wl,--wrap=strcasestr" \ 33 "-Wl,--wrap=memcmp" \ 34 "-Wl,--wrap=bcmp" \ 35 "-Wl,--wrap=memmem" \ 36 "-Wl,--wrap=ap_cstr_casecmp" \ 37 "-Wl,--wrap=ap_cstr_casecmpn" \ 38 "-Wl,--wrap=ap_strcasestr" \ 39 "-Wl,--wrap=apr_cstr_casecmp" \ 40 "-Wl,--wrap=apr_cstr_casecmpn" \ 41 "-Wl,--wrap=CRYPTO_memcmp" \ 42 "-Wl,--wrap=OPENSSL_memcmp" \ 43 "-Wl,--wrap=OPENSSL_strcasecmp" \ 44 "-Wl,--wrap=OPENSSL_strncasecmp" \ 45 "-Wl,--wrap=xmlStrncmp" \ 46 "-Wl,--wrap=xmlStrcmp" \ 47 "-Wl,--wrap=xmlStrEqual" \ 48 "-Wl,--wrap=xmlStrcasecmp" \ 49 "-Wl,--wrap=xmlStrncasecmp" \ 50 "-Wl,--wrap=xmlStrstr" \ 51 "-Wl,--wrap=xmlStrcasestr" 52 else 53 $(call pretty-error, Unknown fuzz engine $(my_fuzzer)) 54 endif 55 56 ifdef LOCAL_MODULE_PATH 57 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE)) 58 endif 59 60 ifdef LOCAL_MODULE_PATH_32 61 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE)) 62 endif 63 64 ifdef LOCAL_MODULE_PATH_64 65 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE)) 66 endif 67 68 LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE) 69 LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE) 70 71 ifndef LOCAL_MULTILIB 72 ifndef LOCAL_32_BIT_ONLY 73 LOCAL_MULTILIB := both 74 endif 75 endif 76 77 ifndef LOCAL_STRIP_MODULE 78 LOCAL_STRIP_MODULE := keep_symbols 79 endif 80 81 include $(BUILD_EXECUTABLE) 82