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 | |
Mitch Phillips | ee8f4a0 | 2019-05-01 14:37:33 -0700 | [diff] [blame] | 18 | LOCAL_SANITIZE += fuzzer |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 19 | |
| 20 | ifeq ($(my_fuzzer),libFuzzer) |
Dan Austin | 5567e50 | 2017-04-19 10:56:45 -0700 | [diff] [blame] | 21 | LOCAL_STATIC_LIBRARIES += libFuzzer |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 22 | else ifeq ($(my_fuzzer),honggfuzz) |
| 23 | LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz |
Zach Riggle | bcfa37e | 2018-01-03 13:32:14 -0600 | [diff] [blame] | 24 | LOCAL_REQUIRED_MODULES += honggfuzz |
Zach Riggle | 6319dee | 2017-12-21 16:04:03 -0600 | [diff] [blame] | 25 | LOCAL_LDFLAGS += \ |
| 26 | "-Wl,--wrap=strcmp" \ |
| 27 | "-Wl,--wrap=strcasecmp" \ |
| 28 | "-Wl,--wrap=strncmp" \ |
| 29 | "-Wl,--wrap=strncasecmp" \ |
| 30 | "-Wl,--wrap=strstr" \ |
| 31 | "-Wl,--wrap=strcasestr" \ |
| 32 | "-Wl,--wrap=memcmp" \ |
| 33 | "-Wl,--wrap=bcmp" \ |
| 34 | "-Wl,--wrap=memmem" \ |
| 35 | "-Wl,--wrap=ap_cstr_casecmp" \ |
| 36 | "-Wl,--wrap=ap_cstr_casecmpn" \ |
| 37 | "-Wl,--wrap=ap_strcasestr" \ |
| 38 | "-Wl,--wrap=apr_cstr_casecmp" \ |
| 39 | "-Wl,--wrap=apr_cstr_casecmpn" \ |
| 40 | "-Wl,--wrap=CRYPTO_memcmp" \ |
| 41 | "-Wl,--wrap=OPENSSL_memcmp" \ |
| 42 | "-Wl,--wrap=OPENSSL_strcasecmp" \ |
| 43 | "-Wl,--wrap=OPENSSL_strncasecmp" \ |
| 44 | "-Wl,--wrap=xmlStrncmp" \ |
| 45 | "-Wl,--wrap=xmlStrcmp" \ |
| 46 | "-Wl,--wrap=xmlStrEqual" \ |
| 47 | "-Wl,--wrap=xmlStrcasecmp" \ |
| 48 | "-Wl,--wrap=xmlStrncasecmp" \ |
| 49 | "-Wl,--wrap=xmlStrstr" \ |
| 50 | "-Wl,--wrap=xmlStrcasestr" |
| 51 | else |
| 52 | $(call pretty-error, Unknown fuzz engine $(my_fuzzer)) |
| 53 | endif |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 54 | |
| 55 | ifdef LOCAL_MODULE_PATH |
| 56 | $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE)) |
| 57 | endif |
| 58 | |
| 59 | ifdef LOCAL_MODULE_PATH_32 |
| 60 | $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE)) |
| 61 | endif |
| 62 | |
| 63 | ifdef LOCAL_MODULE_PATH_64 |
| 64 | $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE)) |
| 65 | endif |
| 66 | |
Zach Riggle | 70299e9 | 2018-03-26 14:47:31 -0500 | [diff] [blame] | 67 | LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE) |
| 68 | LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE) |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 69 | |
Zach Riggle | bcfa37e | 2018-01-03 13:32:14 -0600 | [diff] [blame] | 70 | ifndef LOCAL_STRIP_MODULE |
| 71 | LOCAL_STRIP_MODULE := keep_symbols |
| 72 | endif |
| 73 | |
Dan Albert | 36b6f04 | 2015-07-30 16:56:30 -0700 | [diff] [blame] | 74 | include $(BUILD_EXECUTABLE) |