1// 2// Copyright (C) 2019 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 17package { 18 default_applicable_licenses: ["external_scudo_license"], 19} 20 21// Added automatically by a large-scale-change that took the approach of 22// 'apply every license found to every target'. While this makes sure we respect 23// every license restriction, it may not be entirely correct. 24// 25// e.g. GPL in an MIT project might only apply to the contrib/ directory. 26// 27// Please consider splitting the single license below into multiple licenses, 28// taking care not to lose any license_kind information, and overriding the 29// default license using the 'licenses: [...]' property on targets as needed. 30// 31// For unused files, consider creating a 'filegroup' with "//visibility:private" 32// to attach the license to, and including a comment whether the files may be 33// used in the current project. 34// http://go/android-license-faq 35license { 36 name: "external_scudo_license", 37 visibility: [":__subpackages__"], 38 license_kinds: [ 39 "SPDX-license-identifier-Apache-2.0", 40 "SPDX-license-identifier-BSD", 41 "SPDX-license-identifier-MIT", 42 "SPDX-license-identifier-NCSA", 43 ], 44 license_text: [ 45 "LICENSE.TXT", 46 ], 47} 48 49cc_library_headers { 50 name: "scudo_headers", 51 ramdisk_available: true, 52 recovery_available: true, 53 vendor_ramdisk_available: true, 54 55 export_include_dirs: [ 56 "standalone/include", 57 ], 58 59 apex_available: [ 60 "com.android.runtime", 61 "//apex_available:platform", 62 ], 63 64 visibility: [ 65 "//system/core/debuggerd", 66 ], 67} 68 69cc_defaults { 70 name: "scudo_config_defaults", 71 cflags: [ 72 // Use a custom Android configuration. 73 "-DSCUDO_USE_CUSTOM_CONFIG", 74 ], 75 76 include_dirs: [ 77 "external/scudo/config", 78 ], 79 80 product_variables: { 81 malloc_low_memory: { 82 cflags: ["-DSCUDO_LOW_MEMORY"], 83 }, 84 }, 85} 86 87cc_defaults { 88 name: "libscudo_defaults", 89 defaults: ["scudo_config_defaults"], 90 native_coverage: false, 91 ramdisk_available: true, 92 vendor_ramdisk_available: true, 93 recovery_available: true, 94 host_supported: true, 95 native_bridge_supported: true, 96 97 rtti: false, 98 stl: "none", 99 100 cflags: [ 101 "-O3", 102 "-fno-rtti", 103 // This option speeds up alloc/free code paths by about 5% to 7%. 104 "-fno-stack-protector", 105 106 "-Wall", 107 "-Wextra", 108 "-Wunused", 109 "-Wno-unused-result", 110 "-Wconversion", 111 112 "-Werror=pointer-to-int-cast", 113 "-Werror=int-to-pointer-cast", 114 "-Werror=thread-safety", 115 "-Werror=type-limits", 116 "-Werror", 117 ], 118 cppflags: [ 119 "-nostdinc++", 120 "-fno-exceptions", 121 ], 122 123 include_dirs: [ 124 "external/scudo/standalone/include", 125 ], 126 127 srcs: [ 128 "standalone/checksum.cpp", 129 "standalone/common.cpp", 130 "standalone/condition_variable_linux.cpp", 131 "standalone/flags.cpp", 132 "standalone/flags_parser.cpp", 133 "standalone/linux.cpp", 134 "standalone/mem_map.cpp", 135 "standalone/mem_map_linux.cpp", 136 "standalone/release.cpp", 137 "standalone/report.cpp", 138 "standalone/report_linux.cpp", 139 "standalone/string_utils.cpp", 140 "standalone/timing.cpp", 141 ], 142 arch: { 143 arm: { 144 cflags: ["-mcrc"], 145 srcs: ["standalone/crc32_hw.cpp"], 146 }, 147 arm64: { 148 cflags: ["-mcrc"], 149 srcs: ["standalone/crc32_hw.cpp"], 150 }, 151 riscv64: { 152 // This is a temporary fix, and should be reverted after 153 // yieldProcessor supports riscv. 154 cflags: ["-Wno-unused-parameter"], 155 }, 156 x86_64: { 157 cflags: ["-msse4.2"], 158 srcs: ["standalone/crc32_hw.cpp"], 159 }, 160 x86: { 161 cflags: ["-msse4.2"], 162 srcs: ["standalone/crc32_hw.cpp"], 163 }, 164 }, 165 166 target: { 167 bionic: { 168 system_shared_libs: [], 169 header_libs: [ 170 "libc_headers", 171 "bionic_libc_platform_headers", 172 ], 173 srcs: ["standalone/wrappers_c_bionic.cpp"], 174 cflags: [ 175 "-D_BIONIC=1", 176 177 // Indicate that bionic has reserved a TLS for Scudo. 178 "-DSCUDO_HAS_PLATFORM_TLS_SLOT", 179 180 // Always force alignment to 16 bytes even on 32 bit. 181 // Android assumes that allocations of multiples of 16 bytes 182 // will be aligned to at least 16 bytes. 183 "-DSCUDO_MIN_ALIGNMENT_LOG=4", 184 185 // Allow scudo to use android_unsafe_frame_pointer_chase(), 186 // which is normally a private function. 187 "-DHAVE_ANDROID_UNSAFE_FRAME_POINTER_CHASE", 188 ], 189 }, 190 native_bridge: { 191 cflags: ["-DSCUDO_DISABLE_TBI"], 192 }, 193 host: { 194 srcs: ["standalone/wrappers_c.cpp"], 195 }, 196 }, 197} 198 199cc_library { 200 name: "libscudo", 201 defaults: ["libscudo_defaults"], 202 visibility: [ 203 "//bionic:__subpackages__", 204 "//build/kati:__subpackages__", 205 "//frameworks/libs/native_bridge_support/android_api/libc:__subpackages__", 206 "//external/ninja:__subpackages__", 207 "//external/stg:__subpackages__", 208 "//system/core/debuggerd:__subpackages__", 209 ], 210 shared: { 211 enabled: false, 212 }, 213 target: { 214 host: { 215 shared: { 216 enabled: true, 217 }, 218 }, 219 }, 220 apex_available: [ 221 "com.android.runtime", 222 ], 223} 224 225cc_library_static { 226 name: "libscudo_for_testing", 227 defaults: ["libscudo_defaults"], 228 cflags: [ 229 "-DSCUDO_DEBUG", 230 ], 231} 232 233cc_defaults { 234 name: "scudo_unit_tests_default", 235 defaults: ["scudo_config_defaults"], 236 isolated: true, 237 static_libs: ["libscudo_for_testing"], 238 include_dirs: [ 239 "external/scudo/standalone", 240 "external/scudo/standalone/include", 241 ], 242 cflags: [ 243 "-Wconversion", 244 // In memtag_test.cpp, some tests are disabled by GTEST_SKIP() so that 245 // they won't be run. However, for those disabled tests, it may contain 246 // unreachable code paths which will mislead some compiler checks. Given 247 // this flag won't be impacted too much, disable it only in the test. 248 "-Wno-unreachable-code-loop-increment", 249 "-DSCUDO_DEBUG", 250 "-DSCUDO_NO_TEST_MAIN", 251 ], 252 target: { 253 bionic: { 254 header_libs: ["bionic_libc_platform_headers"], 255 }, 256 }, 257 test_suites: ["general-tests"], 258 bootstrap: true, 259 srcs: [ 260 "standalone/tests/scudo_unit_test_main.cpp", 261 ], 262} 263 264cc_test { 265 name: "scudo_unit_tests", 266 defaults: ["scudo_unit_tests_default"], 267 host_supported: true, 268 srcs: [ 269 "standalone/tests/allocator_config_test.cpp", 270 "standalone/tests/atomic_test.cpp", 271 "standalone/tests/bytemap_test.cpp", 272 "standalone/tests/checksum_test.cpp", 273 "standalone/tests/chunk_test.cpp", 274 "standalone/tests/combined_test.cpp", 275 "standalone/tests/condition_variable_test.cpp", 276 "standalone/tests/flags_test.cpp", 277 "standalone/tests/list_test.cpp", 278 "standalone/tests/map_test.cpp", 279 "standalone/tests/memtag_test.cpp", 280 "standalone/tests/mutex_test.cpp", 281 "standalone/tests/primary_test.cpp", 282 "standalone/tests/quarantine_test.cpp", 283 "standalone/tests/release_test.cpp", 284 "standalone/tests/report_test.cpp", 285 "standalone/tests/secondary_test.cpp", 286 "standalone/tests/size_class_map_test.cpp", 287 "standalone/tests/stats_test.cpp", 288 "standalone/tests/strings_test.cpp", 289 "standalone/tests/timing_test.cpp", 290 "standalone/tests/tsd_test.cpp", 291 "standalone/tests/vector_test.cpp", 292 ], 293} 294 295cc_test { 296 name: "scudo_wrappers_unit_tests", 297 defaults: ["scudo_unit_tests_default"], 298 // These are wrapper tests, disable the host tests since they would run 299 // against glibc. 300 host_supported: false, 301 cflags: [ 302 "-Wno-mismatched-new-delete", 303 ], 304 srcs: [ 305 "standalone/tests/wrappers_c_test.cpp", 306 "standalone/tests/wrappers_cpp_test.cpp", 307 ], 308} 309 310cc_fuzz { 311 name: "scudo_get_error_info_fuzzer", 312 host_supported: true, 313 compile_multilib: "64", 314 static_libs: ["libscudo"], 315 include_dirs: [ 316 "external/scudo/standalone", 317 "external/scudo/standalone/include", 318 ], 319 cflags: [ 320 "-Wno-unneeded-internal-declaration", 321 ], 322 srcs: ["standalone/fuzz/get_error_info_fuzzer.cpp"], 323 fuzz_config: { 324 componentid: 87896 325 }, 326} 327 328cc_test { 329 name: "size_map_verify_unit_tests", 330 host_supported: true, 331 static_libs: ["libscudo"], 332 333 include_dirs: [ 334 "external/scudo/android/tools", 335 "external/scudo/standalone", 336 "external/scudo/standalone/include", 337 "external/scudo/standalone/tools", 338 ], 339 srcs: [ 340 "android/tests/size_map_verify_unit_tests.cpp", 341 ], 342} 343 344cc_binary { 345 name: "size_map_gen", 346 defaults: ["scudo_config_defaults"], 347 host_supported: true, 348 static_libs: ["libscudo"], 349 include_dirs: [ 350 "external/scudo/android/tools", 351 "external/scudo/standalone", 352 "external/scudo/standalone/include", 353 ], 354 srcs: ["android/tools/size_map_gen.cpp"], 355} 356 357// The targets below verify that all configuration is set up properly for 358// the library or tests. 359cc_defaults { 360 name: "scudo_verify_defaults", 361 host_supported: true, 362 srcs: ["config/config_build_check.cpp"], 363 364 include_dirs: [ 365 "external/scudo/standalone", 366 ], 367 368 product_variables: { 369 malloc_low_memory: { 370 cflags: ["-DSCUDO_LOW_MEMORY_CHECK"], 371 }, 372 }, 373} 374 375cc_test { 376 name: "scudo_verify_config", 377 defaults: [ 378 "scudo_verify_defaults", 379 "scudo_unit_tests_default", 380 ], 381} 382