Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 1 | ########################################### |
| 2 | ## A thin wrapper around BUILD_EXECUTABLE |
| 3 | ## Common flags for fuzz tests are added. |
| 4 | ########################################### |
Dan Willemsen | 3bf15e7 | 2016-07-25 16:03:53 -0700 | [diff] [blame] | 5 | $(call record-module-type,FUZZ_TEST) |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 6 | |
| 7 | ifdef LOCAL_SDK_VERSION |
| 8 | $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.) |
| 9 | endif |
| 10 | |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 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 | |
Zach Riggle | be0811f | 2017-08-21 17:07:42 -0400 | [diff] [blame] | 19 | LOCAL_CFLAGS += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 20 | |
| 21 | ifeq ($(my_fuzzer),libFuzzer) |
Dan Austin | 5567e50 | 2017-04-19 10:56:45 -0700 | [diff] [blame] | 22 | LOCAL_STATIC_LIBRARIES += libFuzzer |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 23 | else ifeq ($(my_fuzzer),honggfuzz) |
| 24 | LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz |
Zach Riggle | bcfa37e | 2018-01-03 13:32:14 -0600 | [diff] [blame] | 25 | LOCAL_REQUIRED_MODULES += honggfuzz |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 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 |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 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 | |
Vishwath Mohan | b6baba0 | 2016-09-02 13:25:59 -0700 | [diff] [blame] | 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) |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 70 | |
| 71 | ifndef LOCAL_MULTILIB |
| 72 | ifndef LOCAL_32_BIT_ONLY |
| 73 | LOCAL_MULTILIB := both |
| 74 | endif |
| 75 | endif |
| 76 | |
Zach Riggle | bcfa37e | 2018-01-03 13:32:14 -0600 | [diff] [blame] | 77 | ifndef LOCAL_STRIP_MODULE |
| 78 | LOCAL_STRIP_MODULE := keep_symbols |
| 79 | endif |
| 80 | |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 81 | include $(BUILD_EXECUTABLE) |