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 ASAN_NEEDS_SEGV = "0" 19 ASAN_HAS_EXCEPTIONS = "1" 20 ASAN_FLEXIBLE_MAPPING_AND_OFFSET = "0" 21 22 asan_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 45 asan_rtl_cxx_files = ["asan_new_delete.cc"] 46 47 asan_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 "-Wno-covered-switch-default", 55 "-Wno-non-virtual-dtor", 56 "-Wno-sign-compare", 57 "-Wno-unused-parameter", 58 "-std=c++11", 59 "-fno-rtti", 60 "-fno-builtin", 61 ] 62 63 cc_library_static { 64 name: "libasan", 65 host_supported: true, 66 defaults: ["asan_arch_defaults"], 67 include_dirs: [ 68 "external/compiler-rt/lib", 69 "external/compiler-rt/include", 70 ], 71 cflags: asan_rtl_cflags, 72 target: { 73 android: { 74 srcs: ["asan_preinit.cc"], 75 }, 76 host: { 77 srcs: asan_rtl_files, 78 whole_static_libs: [ 79 "libubsan", 80 "libinterception", 81 "liblsan", 82 "libsan" 83 ], 84 }, 85 }, 86 87 clang: true, 88 sdk_version: "19", 89 stl: "none", 90 91 sanitize: { 92 never: true, 93 }, 94 } 95 96 cc_library_host_static { 97 name: "libasan_cxx", 98 include_dirs: [ 99 "external/compiler-rt/lib", 100 "external/compiler-rt/include", 101 ], 102 cflags: asan_rtl_cflags, 103 srcs: asan_rtl_cxx_files, 104 105 clang: true, 106 compile_multilib: "both", 107 108 sanitize: { 109 never: true, 110 }, 111 target: { 112 darwin: { 113 enabled: false, 114 }, 115 }, 116 } 117 118 cc_defaults { 119 name: "libclang_rt_defaults", 120 121 // TODO: 122 // This library must go on /system partition, even in SANITIZE_TARGET mode (when all libraries are 123 // installed on /data). That's because /data may not be available until vold does some magic and 124 // vold itself depends on this library. 125 126 arch: { 127 arm: { 128 instruction_set: "arm", 129 }, 130 }, 131 include_dirs: [ 132 "external/compiler-rt/lib", 133 "external/compiler-rt/include", 134 ], 135 cflags: asan_rtl_cflags, 136 ldflags: ["-Wl,-z,global"], 137 srcs: asan_rtl_files + asan_rtl_cxx_files, 138 static_libs: [ 139 "libinterception", 140 "liblsan", 141 "libsan", 142 "libubsan", 143 ], 144 shared_libs: [ 145 "liblog", 146 "libdl", 147 ], 148 clang: true, 149 sanitize: { 150 never: true, 151 }, 152 sdk_version: "19", 153 stl: "none", 154 enabled: false, 155 } 156 157 // Disable libclang_rt prebuilts in aosp/master until soong has a build option 158 // to pick a prebuilt or compile/build a module. 159 // 160 // cc_library_shared { 161 // name: "libclang_rt.asan-arm-android", 162 // defaults: ["libclang_rt_defaults"], 163 // arch: { 164 // arm: { 165 // enabled: true, 166 // }, 167 // }, 168 // } 169 // 170 // cc_library_shared { 171 // name: "libclang_rt.asan-aarch64-android", 172 // defaults: ["libclang_rt_defaults"], 173 // arch: { 174 // arm64: { 175 // enabled: true, 176 // }, 177 // }, 178 // } 179 // 180 // cc_library_shared { 181 // name: "libclang_rt.asan-mips-android", 182 // defaults: ["libclang_rt_defaults"], 183 // arch: { 184 // mips: { 185 // enabled: true, 186 // }, 187 // }, 188 // } 189 // 190 // cc_library_shared { 191 // name: "libclang_rt.asan-mips64-android", 192 // defaults: ["libclang_rt_defaults"], 193 // arch: { 194 // mips64: { 195 // enabled: true, 196 // }, 197 // }, 198 // } 199 // 200 // cc_library_shared { 201 // name: "libclang_rt.asan-i686-android", 202 // defaults: ["libclang_rt_defaults"], 203 // arch: { 204 // x86: { 205 // enabled: true, 206 // }, 207 // }, 208 // } 209 210 cc_binary { 211 name: "asanwrapper", 212 defaults: ["asan_arch_defaults"], 213 214 srcs: ["asanwrapper.cc"], 215 216 cppflags: ["-std=c++11"], 217 sanitize: { 218 never: true, 219 }, 220 221 stl: "libc++", 222 } 223 224 // ANDROIDMK TRANSLATION ERROR: unsupported conditional 225 // ifneq (true,$(SKIP_LLVM_TESTS)) 226 cc_library_static { 227 name: "libasan_noinst_test", 228 host_supported: true, 229 defaults: ["asan_arch_defaults"], 230 231 tags: ["tests"], 232 include_dirs: [ 233 "external/compiler-rt/include", 234 "external/compiler-rt/lib", 235 "external/compiler-rt/lib/asan/tests", 236 "external/compiler-rt/lib/sanitizer_common/tests", 237 ], 238 cflags: [ 239 "-Wno-non-virtual-dtor", 240 "-Wno-unused-parameter", 241 "-Wno-sign-compare", 242 "-DASAN_UAR=0", 243 "-DASAN_HAS_BLACKLIST=1", 244 "-DASAN_HAS_EXCEPTIONS=" + ASAN_HAS_EXCEPTIONS, 245 "-DASAN_NEEDS_SEGV=" + ASAN_NEEDS_SEGV, 246 "-std=c++11", 247 ], 248 srcs: [ 249 "tests/asan_noinst_test.cc", 250 "tests/asan_test_main.cc", 251 ], 252 253 static_libs: ["libgtest"], 254 255 clang: true, 256 sanitize: { 257 never: true, 258 }, 259 260 stl: "libc++", 261 } 262 263 cc_test { 264 name: "asan_test", 265 host_supported: true, 266 defaults: ["asan_arch_defaults"], 267 268 tags: ["tests"], 269 include_dirs: [ 270 "external/compiler-rt/lib", 271 "external/compiler-rt/lib/asan/tests", 272 "external/compiler-rt/lib/sanitizer_common/tests", 273 ], 274 cflags: [ 275 "-DASAN_LOW_MEMORY=1", 276 "-DASAN_UAR=0", 277 "-DASAN_NEEDS_SEGV=" + ASAN_NEEDS_SEGV, 278 "-DASAN_HAS_EXCEPTIONS=" + ASAN_HAS_EXCEPTIONS, 279 "-DASAN_HAS_BLACKLIST=1", 280 "-Wno-covered-switch-default", 281 "-Wno-non-virtual-dtor", 282 "-Wno-sign-compare", 283 "-Wno-unused-parameter", 284 "-std=c++11", 285 ], 286 287 srcs: [ 288 "tests/asan_globals_test.cc", 289 "tests/asan_test.cc", 290 //"tests/asan_noinst_test.cc", 291 //"tests/asan_test_main.cc", 292 ], 293 294 static_libs: ["libasan_noinst_test"], 295 sanitize: { 296 address: true, 297 blacklist: "tests/asan_test.ignore", 298 }, 299 clang: true, 300 301 stl: "libc++", 302 target: { 303 host: { 304 host_ldlibs: ["-lrt"], 305 }, 306 }, 307 } 308 309 // ANDROIDMK TRANSLATION ERROR: endif from unsupported contitional 310 // endif 311 // SKIP_LLVM_TESTS 312