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