Android.mk revision 51584046b5a19fcc3ef47a0ade2e88b58ded7e81
1# 2# Copyright (C) 2012 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# 17 18LOCAL_PATH:= $(call my-dir) 19 20ifeq ($(TARGET_ARCH),arm) 21 22ASAN_NEEDS_SEGV=0 23ASAN_HAS_EXCEPTIONS=1 24ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 25 26asan_rtl_files := \ 27 asan_rtl.cc \ 28 asan_allocator.cc \ 29 asan_globals.cc \ 30 asan_interceptors.cc \ 31 asan_linux.cc \ 32 asan_malloc_linux.cc \ 33 asan_malloc_mac.cc \ 34 asan_new_delete.cc \ 35 asan_poisoning.cc \ 36 asan_posix.cc \ 37 asan_printf.cc \ 38 asan_stack.cc \ 39 asan_stats.cc \ 40 asan_thread.cc \ 41 asan_thread_registry.cc \ 42 ../interception/interception_linux.cc \ 43 ../sanitizer_common/sanitizer_allocator.cc \ 44 ../sanitizer_common/sanitizer_common.cc \ 45 ../sanitizer_common/sanitizer_libc.cc \ 46 ../sanitizer_common/sanitizer_linux.cc \ 47 ../sanitizer_common/sanitizer_posix.cc \ 48 ../sanitizer_common/sanitizer_printf.cc \ 49 ../sanitizer_common/sanitizer_symbolizer.cc 50 51asan_rtl_cflags := \ 52 -fvisibility=hidden \ 53 -fno-exceptions \ 54 -DASAN_LOW_MEMORY=1 \ 55 -DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \ 56 -DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \ 57 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=$(ASAN_FLEXIBLE_MAPPING_AND_OFFSET) \ 58 -Wno-covered-switch-default \ 59 -Wno-sign-compare \ 60 -Wno-unused-parameter \ 61 -D__WORDSIZE=32 62 63asan_test_files := \ 64 tests/asan_test.cc \ 65 tests/asan_globals_test.cc \ 66 tests/asan_break_optimization.cc \ 67 tests/asan_interface_test.cc 68 69asan_test_cflags := \ 70 -mllvm -asan-blacklist=external/compiler-rt/lib/asan/tests/asan_test.ignore \ 71 -DASAN_LOW_MEMORY=1 \ 72 -DASAN_UAR=0 \ 73 -DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \ 74 -DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \ 75 -DASAN_HAS_BLACKLIST=1 \ 76 -Wno-covered-switch-default \ 77 -Wno-sign-compare \ 78 -Wno-unused-parameter \ 79 -D__WORDSIZE=32 80 81 82include $(CLEAR_VARS) 83 84LOCAL_MODULE := libasan 85LOCAL_MODULE_TAGS := optional 86LOCAL_C_INCLUDES := bionic external/compiler-rt/lib 87LOCAL_CFLAGS += $(asan_rtl_cflags) 88LOCAL_SRC_FILES := asan_android_stub.cc 89LOCAL_CPP_EXTENSION := .cc 90LOCAL_CLANG := true 91include $(BUILD_STATIC_LIBRARY) 92 93 94include $(CLEAR_VARS) 95 96LOCAL_MODULE := libasan_preload 97LOCAL_MODULE_TAGS := eng 98LOCAL_C_INCLUDES := \ 99 bionic \ 100 external/stlport/stlport \ 101 external/compiler-rt/lib 102LOCAL_CFLAGS += $(asan_rtl_cflags) 103LOCAL_SRC_FILES := $(asan_rtl_files) 104LOCAL_CPP_EXTENSION := .cc 105LOCAL_SHARED_LIBRARIES := libc libstlport libdl 106LOCAL_CLANG := true 107include $(BUILD_SHARED_LIBRARY) 108 109 110include $(CLEAR_VARS) 111 112LOCAL_MODULE := asanwrapper 113LOCAL_MODULE_TAGS := eng 114LOCAL_C_INCLUDES := \ 115 bionic \ 116 external/stlport/stlport 117LOCAL_SRC_FILES := asanwrapper.cc 118LOCAL_CPP_EXTENSION := .cc 119LOCAL_SHARED_LIBRARIES := libstlport libc 120 121include $(BUILD_EXECUTABLE) 122 123 124include $(CLEAR_VARS) 125 126LOCAL_MODULE := libasan_noinst_test 127LOCAL_MODULE_TAGS := tests 128LOCAL_C_INCLUDES := \ 129 bionic \ 130 external/stlport/stlport \ 131 external/gtest/include \ 132 external/compiler-rt/lib 133LOCAL_CFLAGS += \ 134 -Wno-unused-parameter \ 135 -Wno-sign-compare \ 136 -D__WORDSIZE=32 137LOCAL_SRC_FILES := tests/asan_noinst_test.cc 138LOCAL_CPP_EXTENSION := .cc 139LOCAL_CLANG := true 140include $(BUILD_STATIC_LIBRARY) 141 142 143include $(CLEAR_VARS) 144 145LOCAL_MODULE := asan_test 146LOCAL_MODULE_TAGS := tests 147LOCAL_C_INCLUDES := \ 148 bionic \ 149 external/stlport/stlport \ 150 external/gtest/include \ 151 external/compiler-rt/lib 152LOCAL_CFLAGS += $(asan_test_cflags) 153LOCAL_SRC_FILES := $(asan_test_files) 154LOCAL_CPP_EXTENSION := .cc 155LOCAL_STATIC_LIBRARIES := libgtest libasan_noinst_test 156LOCAL_SHARED_LIBRARIES := libc libstlport 157LOCAL_ADDRESS_SANITIZER := true 158 159include $(BUILD_EXECUTABLE) 160 161# Build output tests for AddressSanitizer. 162 163define asan-output-test 164 include $(CLEAR_VARS) 165 LOCAL_MODULE := $(1) 166 LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan 167 LOCAL_MODULE_TAGS := tests 168 LOCAL_SRC_FILES := output_tests/$(1).cc 169 LOCAL_CPP_EXTENSION := .cc 170 LOCAL_ADDRESS_SANITIZER := true 171 LOCAL_C_INCLUDES := bionic external/stlport/stlport 172 LOCAL_CFLAGS := -Wno-unused-parameter 173 LOCAL_SHARED_LIBRARIES := libstlport 174 include $(BUILD_EXECUTABLE) 175endef 176 177define asan-output-test-so 178 include $(CLEAR_VARS) 179 LOCAL_MODULE := $(1) 180 LOCAL_MODULE_TAGS := tests 181 LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan 182 LOCAL_SRC_FILES := output_tests/$(1).cc 183 LOCAL_CPP_EXTENSION := .cc 184 LOCAL_ADDRESS_SANITIZER := true 185 LOCAL_C_INCLUDES := bionic external/stlport/stlport 186 LOCAL_CFLAGS := -Wno-unused-parameter 187 LOCAL_SHARED_LIBRARIES := libstlport 188 include $(BUILD_SHARED_LIBRARY) 189endef 190 191OUTPUT_TESTS := \ 192 clone_test \ 193 deep_tail_call \ 194 dlclose-test \ 195 dlclose-test-so \ 196 global-overflow \ 197 heap-overflow \ 198 large_func_test \ 199 null_deref \ 200 shared-lib-test \ 201 shared-lib-test-so \ 202 stack-overflow \ 203 strncpy-overflow \ 204 use-after-free 205 206$(foreach test,$(filter %-so,$(OUTPUT_TESTS)),$(eval $(call asan-output-test-so,$(test)))) 207$(foreach test,$(filter-out %-so,$(OUTPUT_TESTS)),$(eval $(call asan-output-test,$(test)))) 208 209endif # ifeq($(TARGET_ARCH),arm) 210