• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18ASAN_NEEDS_SEGV = "0"
19ASAN_HAS_EXCEPTIONS = "1"
20ASAN_FLEXIBLE_MAPPING_AND_OFFSET = "0"
21
22asan_rtl_files = [
23    "asan_activation.cc",
24    "asan_allocator.cc",
25    "asan_fake_stack.cc",
26    "asan_flags.cc",
27    "asan_globals.cc",
28    "asan_interceptors.cc",
29    "asan_linux.cc",
30    "asan_mac.cc",
31    "asan_malloc_linux.cc",
32    "asan_malloc_mac.cc",
33    "asan_malloc_win.cc",
34    "asan_poisoning.cc",
35    "asan_posix.cc",
36    "asan_report.cc",
37    "asan_rtl.cc",
38    "asan_stack.cc",
39    "asan_stats.cc",
40    "asan_suppressions.cc",
41    "asan_thread.cc",
42    "asan_win.cc",
43]
44
45asan_rtl_cxx_files = ["asan_new_delete.cc"]
46
47asan_rtl_cflags = [
48    "-fvisibility=hidden",
49    "-fno-exceptions",
50    "-DASAN_LOW_MEMORY=1",
51    "-DASAN_NEEDS_SEGV=" + ASAN_NEEDS_SEGV,
52    "-DASAN_HAS_EXCEPTIONS=" + ASAN_HAS_EXCEPTIONS,
53    "-DASAN_FLEXIBLE_MAPPING_AND_OFFSET=" + ASAN_FLEXIBLE_MAPPING_AND_OFFSET,
54    "-Wall",
55    "-Werror",
56    "-Wno-covered-switch-default",
57    "-Wno-non-virtual-dtor",
58    "-Wno-sign-compare",
59    "-Wno-unused-parameter",
60    "-std=c++11",
61    "-fno-rtti",
62    "-fno-builtin",
63]
64
65cc_library_static {
66    name: "libasan",
67    host_supported: true,
68    recovery_available: true,
69    defaults: ["asan_arch_defaults"],
70    include_dirs: [
71        "external/compiler-rt/lib",
72        "external/compiler-rt/include",
73    ],
74    cflags: asan_rtl_cflags,
75    target: {
76        android: {
77            srcs: ["asan_preinit.cc"],
78            system_shared_libs: [],
79        },
80        host: {
81            srcs: asan_rtl_files,
82            whole_static_libs: [
83                "libubsan",
84                "libinterception",
85                "liblsan",
86                "libsan"
87            ],
88        },
89    },
90
91    sdk_version: "19",
92    stl: "none",
93
94    sanitize: {
95        never: true,
96    },
97}
98
99cc_library_host_static {
100    name: "libasan_cxx",
101    include_dirs: [
102        "external/compiler-rt/lib",
103        "external/compiler-rt/include",
104    ],
105    cflags: asan_rtl_cflags,
106    srcs: asan_rtl_cxx_files,
107
108    compile_multilib: "both",
109
110    sanitize: {
111        never: true,
112    },
113    target: {
114        darwin: {
115            enabled: false,
116        },
117    },
118}
119
120cc_binary {
121    name: "asanwrapper",
122    defaults: ["asan_arch_defaults"],
123
124    srcs: ["asanwrapper.cc"],
125
126    cflags: ["-Wall", "-Werror"],
127    cppflags: ["-std=c++11"],
128    sanitize: {
129        never: true,
130    },
131
132    stl: "libc++",
133}
134
135// ANDROIDMK TRANSLATION ERROR: unsupported conditional
136// ifneq (true,$(SKIP_LLVM_TESTS))
137cc_library_static {
138    name: "libasan_noinst_test",
139    host_supported: true,
140    defaults: ["asan_arch_defaults"],
141
142    include_dirs: [
143        "external/compiler-rt/include",
144        "external/compiler-rt/lib",
145        "external/compiler-rt/lib/asan/tests",
146        "external/compiler-rt/lib/sanitizer_common/tests",
147    ],
148    cflags: [
149        "-Wall",
150        "-Werror",
151        "-Wno-non-virtual-dtor",
152        "-Wno-unused-parameter",
153        "-Wno-sign-compare",
154        "-DASAN_UAR=0",
155        "-DASAN_HAS_BLACKLIST=1",
156        "-DASAN_HAS_EXCEPTIONS=" + ASAN_HAS_EXCEPTIONS,
157        "-DASAN_NEEDS_SEGV=" + ASAN_NEEDS_SEGV,
158        "-std=c++11",
159    ],
160    srcs: [
161        "tests/asan_noinst_test.cc",
162        "tests/asan_test_main.cc",
163    ],
164
165    static_libs: ["libgtest"],
166
167    sanitize: {
168        never: true,
169    },
170
171    stl: "libc++",
172}
173
174cc_test {
175    name: "asan_test",
176    host_supported: true,
177    defaults: ["asan_arch_defaults"],
178
179    include_dirs: [
180        "external/compiler-rt/lib",
181        "external/compiler-rt/lib/asan/tests",
182        "external/compiler-rt/lib/sanitizer_common/tests",
183    ],
184    cflags: [
185        "-DASAN_LOW_MEMORY=1",
186        "-DASAN_UAR=0",
187        "-DASAN_NEEDS_SEGV=" + ASAN_NEEDS_SEGV,
188        "-DASAN_HAS_EXCEPTIONS=" + ASAN_HAS_EXCEPTIONS,
189        "-DASAN_HAS_BLACKLIST=1",
190        "-Wall",
191        "-Werror",
192        "-Wno-covered-switch-default",
193        "-Wno-non-virtual-dtor",
194        "-Wno-sign-compare",
195        "-Wno-unused-parameter",
196        "-std=c++11",
197    ],
198
199    srcs: [
200        "tests/asan_globals_test.cc",
201        "tests/asan_test.cc",
202        //"tests/asan_noinst_test.cc",
203        //"tests/asan_test_main.cc",
204    ],
205
206    static_libs: ["libasan_noinst_test"],
207    sanitize: {
208        address: true,
209        blacklist: "tests/asan_test.ignore",
210    },
211
212    stl: "libc++",
213}
214
215// ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional
216// endif
217// SKIP_LLVM_TESTS
218