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 18 LOCAL_PATH:= $(call my-dir) 19 20 ifeq ($(TARGET_ARCH),arm) 21 22 ASAN_NEEDS_SEGV=0 23 ASAN_HAS_EXCEPTIONS=1 24 ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 25 26 asan_rtl_files := \ 27 asan_allocator2.cc \ 28 asan_fake_stack.cc \ 29 asan_globals.cc \ 30 asan_interceptors.cc \ 31 asan_linux.cc \ 32 asan_mac.cc \ 33 asan_malloc_linux.cc \ 34 asan_malloc_mac.cc \ 35 asan_malloc_win.cc \ 36 asan_new_delete.cc \ 37 asan_poisoning.cc \ 38 asan_posix.cc \ 39 asan_report.cc \ 40 asan_rtl.cc \ 41 asan_stack.cc \ 42 asan_stats.cc \ 43 asan_thread.cc \ 44 asan_win.cc \ 45 ../interception/interception_linux.cc \ 46 ../sanitizer_common/sanitizer_allocator.cc \ 47 ../sanitizer_common/sanitizer_common.cc \ 48 ../sanitizer_common/sanitizer_common_libcdep.cc \ 49 ../sanitizer_common/sanitizer_flags.cc \ 50 ../sanitizer_common/sanitizer_libc.cc \ 51 ../sanitizer_common/sanitizer_linux.cc \ 52 ../sanitizer_common/sanitizer_linux_libcdep.cc \ 53 ../sanitizer_common/sanitizer_mac.cc \ 54 ../sanitizer_common/sanitizer_posix.cc \ 55 ../sanitizer_common/sanitizer_posix_libcdep.cc \ 56 ../sanitizer_common/sanitizer_platform_limits_posix.cc \ 57 ../sanitizer_common/sanitizer_printf.cc \ 58 ../sanitizer_common/sanitizer_stackdepot.cc \ 59 ../sanitizer_common/sanitizer_stacktrace.cc \ 60 ../sanitizer_common/sanitizer_symbolizer_itanium.cc \ 61 ../sanitizer_common/sanitizer_symbolizer_libcdep.cc \ 62 ../sanitizer_common/sanitizer_symbolizer_linux.cc \ 63 ../sanitizer_common/sanitizer_symbolizer_linux_libcdep.cc \ 64 ../sanitizer_common/sanitizer_symbolizer_mac.cc \ 65 ../sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc \ 66 ../sanitizer_common/sanitizer_symbolizer_win.cc \ 67 ../sanitizer_common/sanitizer_thread_registry.cc \ 68 ../sanitizer_common/sanitizer_win.cc \ 69 70 asan_rtl_cflags := \ 71 -fvisibility=hidden \ 72 -fno-exceptions \ 73 -DASAN_LOW_MEMORY=1 \ 74 -DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \ 75 -DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \ 76 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=$(ASAN_FLEXIBLE_MAPPING_AND_OFFSET) \ 77 -Wno-covered-switch-default \ 78 -Wno-non-virtual-dtor \ 79 -Wno-sign-compare \ 80 -Wno-unused-parameter \ 81 -D__WORDSIZE=32 82 83 asan_test_files := \ 84 tests/asan_globals_test.cc \ 85 tests/asan_test.cc 86 87 #tests/asan_noinst_test.cc \ 88 #tests/asan_test_main.cc \ 89 90 asan_test_cflags := \ 91 -mllvm -asan-blacklist=external/compiler-rt/lib/asan/tests/asan_test.ignore \ 92 -DASAN_LOW_MEMORY=1 \ 93 -DASAN_UAR=0 \ 94 -DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \ 95 -DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \ 96 -DASAN_HAS_BLACKLIST=1 \ 97 -Wno-covered-switch-default \ 98 -Wno-non-virtual-dtor \ 99 -Wno-sign-compare \ 100 -Wno-unused-parameter \ 101 -D__WORDSIZE=32 102 103 104 include $(CLEAR_VARS) 105 106 LOCAL_MODULE := libasan 107 LOCAL_MODULE_TAGS := optional 108 LOCAL_C_INCLUDES := bionic external/compiler-rt/lib external/compiler-rt/include 109 LOCAL_CFLAGS += $(asan_rtl_cflags) 110 LOCAL_SRC_FILES := asan_preinit.cc 111 #LOCAL_SRC_FILES := asan_android_stub.cc asan_preinit.cc 112 LOCAL_CPP_EXTENSION := .cc 113 LOCAL_CLANG := true 114 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 115 include $(BUILD_STATIC_LIBRARY) 116 117 118 include $(CLEAR_VARS) 119 120 LOCAL_MODULE := libasan_preload 121 LOCAL_MODULE_TAGS := eng 122 LOCAL_C_INCLUDES := \ 123 bionic \ 124 external/compiler-rt/lib \ 125 external/compiler-rt/include 126 LOCAL_CFLAGS += $(asan_rtl_cflags) 127 LOCAL_SRC_FILES := $(asan_rtl_files) 128 LOCAL_CPP_EXTENSION := .cc 129 LOCAL_SHARED_LIBRARIES := libc libdl 130 LOCAL_CLANG := true 131 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 132 include $(BUILD_SHARED_LIBRARY) 133 134 135 include $(CLEAR_VARS) 136 137 LOCAL_MODULE := asanwrapper 138 LOCAL_MODULE_TAGS := eng 139 LOCAL_C_INCLUDES := \ 140 bionic \ 141 external/stlport/stlport 142 LOCAL_SRC_FILES := asanwrapper.cc 143 LOCAL_CPP_EXTENSION := .cc 144 LOCAL_SHARED_LIBRARIES := libstlport libc 145 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 146 147 include $(BUILD_EXECUTABLE) 148 149 150 include $(CLEAR_VARS) 151 152 LOCAL_MODULE := libasan_noinst_test 153 LOCAL_MODULE_TAGS := tests 154 LOCAL_C_INCLUDES := \ 155 bionic \ 156 external/stlport/stlport \ 157 external/gtest/include \ 158 external/compiler-rt/include \ 159 external/compiler-rt/lib \ 160 external/compiler-rt/lib/asan/tests \ 161 external/compiler-rt/lib/sanitizer_common/tests 162 LOCAL_CFLAGS += \ 163 -Wno-unused-parameter \ 164 -Wno-sign-compare \ 165 -DASAN_UAR=0 \ 166 -DASAN_HAS_BLACKLIST=1 \ 167 -DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \ 168 -DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \ 169 -D__WORDSIZE=32 170 LOCAL_SRC_FILES := tests/asan_noinst_test.cc tests/asan_test_main.cc 171 LOCAL_CPP_EXTENSION := .cc 172 LOCAL_CLANG := true 173 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 174 include $(BUILD_STATIC_LIBRARY) 175 176 177 include $(CLEAR_VARS) 178 179 LOCAL_MODULE := asan_test 180 LOCAL_MODULE_TAGS := tests 181 LOCAL_C_INCLUDES := \ 182 bionic \ 183 external/stlport/stlport \ 184 external/gtest/include \ 185 external/compiler-rt/lib \ 186 external/compiler-rt/lib/asan/tests \ 187 external/compiler-rt/lib/sanitizer_common/tests 188 LOCAL_CFLAGS += $(asan_test_cflags) 189 LOCAL_SRC_FILES := $(asan_test_files) 190 LOCAL_CPP_EXTENSION := .cc 191 LOCAL_STATIC_LIBRARIES := libgtest libasan_noinst_test 192 LOCAL_SHARED_LIBRARIES := libc libstlport 193 LOCAL_ADDRESS_SANITIZER := true 194 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 195 196 include $(BUILD_EXECUTABLE) 197 198 endif # ifeq($(TARGET_ARCH),arm) 199