Android.mk revision 1f922a5259510f70a12576e7a61eaa0033a02b16
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_report.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_flags.cc \
46	../sanitizer_common/sanitizer_libc.cc \
47	../sanitizer_common/sanitizer_linux.cc \
48	../sanitizer_common/sanitizer_posix.cc \
49	../sanitizer_common/sanitizer_printf.cc \
50	../sanitizer_common/sanitizer_stacktrace.cc \
51	../sanitizer_common/sanitizer_symbolizer.cc \
52	../sanitizer_common/sanitizer_symbolizer_linux.cc \
53
54asan_rtl_cflags := \
55	-fvisibility=hidden \
56	-fno-exceptions \
57	-DASAN_LOW_MEMORY=1 \
58	-DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \
59	-DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \
60	-DASAN_FLEXIBLE_MAPPING_AND_OFFSET=$(ASAN_FLEXIBLE_MAPPING_AND_OFFSET) \
61	-Wno-covered-switch-default \
62	-Wno-sign-compare \
63	-Wno-unused-parameter \
64	-D__WORDSIZE=32
65
66asan_test_files := \
67	tests/asan_test.cc \
68	tests/asan_globals_test.cc \
69	tests/asan_break_optimization.cc
70
71asan_test_cflags := \
72	-mllvm -asan-blacklist=external/compiler-rt/lib/asan/tests/asan_test.ignore \
73	-DASAN_LOW_MEMORY=1 \
74	-DASAN_UAR=0 \
75	-DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \
76	-DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \
77	-DASAN_HAS_BLACKLIST=1 \
78	-Wno-covered-switch-default \
79	-Wno-sign-compare \
80	-Wno-unused-parameter \
81	-D__WORDSIZE=32
82
83
84include $(CLEAR_VARS)
85
86LOCAL_MODULE := libasan
87LOCAL_MODULE_TAGS := optional
88LOCAL_C_INCLUDES := bionic external/compiler-rt/lib external/compiler-rt/include
89LOCAL_CFLAGS += $(asan_rtl_cflags)
90LOCAL_SRC_FILES := asan_android_stub.cc
91LOCAL_CPP_EXTENSION := .cc
92LOCAL_CLANG := true
93include $(BUILD_STATIC_LIBRARY)
94
95
96include $(CLEAR_VARS)
97
98LOCAL_MODULE := libasan_preload
99LOCAL_MODULE_TAGS := eng
100LOCAL_C_INCLUDES := \
101  bionic \
102  external/stlport/stlport \
103  external/compiler-rt/lib \
104  external/compiler-rt/include
105LOCAL_CFLAGS += $(asan_rtl_cflags)
106LOCAL_SRC_FILES := $(asan_rtl_files)
107LOCAL_CPP_EXTENSION := .cc
108LOCAL_SHARED_LIBRARIES := libc libstlport libdl
109LOCAL_CLANG := true
110include $(BUILD_SHARED_LIBRARY)
111
112
113include $(CLEAR_VARS)
114
115LOCAL_MODULE := asanwrapper
116LOCAL_MODULE_TAGS := eng
117LOCAL_C_INCLUDES := \
118        bionic \
119        external/stlport/stlport
120LOCAL_SRC_FILES := asanwrapper.cc
121LOCAL_CPP_EXTENSION := .cc
122LOCAL_SHARED_LIBRARIES := libstlport libc
123
124include $(BUILD_EXECUTABLE)
125
126
127include $(CLEAR_VARS)
128
129LOCAL_MODULE := libasan_noinst_test
130LOCAL_MODULE_TAGS := tests
131LOCAL_C_INCLUDES := \
132        bionic \
133        external/stlport/stlport \
134        external/gtest/include \
135        external/compiler-rt/include \
136        external/compiler-rt/lib
137LOCAL_CFLAGS += \
138        -Wno-unused-parameter \
139        -Wno-sign-compare \
140        -DASAN_UAR=0 \
141        -DASAN_HAS_BLACKLIST=1 \
142        -D__WORDSIZE=32
143LOCAL_SRC_FILES := tests/asan_noinst_test.cc
144LOCAL_CPP_EXTENSION := .cc
145LOCAL_CLANG := true
146include $(BUILD_STATIC_LIBRARY)
147
148
149include $(CLEAR_VARS)
150
151LOCAL_MODULE := asan_test
152LOCAL_MODULE_TAGS := tests
153LOCAL_C_INCLUDES := \
154        bionic \
155        external/stlport/stlport \
156        external/gtest/include \
157        external/compiler-rt/lib
158LOCAL_CFLAGS += $(asan_test_cflags)
159LOCAL_SRC_FILES := $(asan_test_files)
160LOCAL_CPP_EXTENSION := .cc
161LOCAL_STATIC_LIBRARIES := libgtest libasan_noinst_test
162LOCAL_SHARED_LIBRARIES := libc libstlport
163LOCAL_ADDRESS_SANITIZER := true
164
165include $(BUILD_EXECUTABLE)
166
167endif # ifeq($(TARGET_ARCH),arm)
168