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 recovery_available: true, 52 vendor_ramdisk_available: true, 53 54 export_include_dirs: [ 55 "standalone/include", 56 ], 57 58 apex_available: [ 59 "com.android.runtime", 60 ], 61 62 visibility: [ 63 "//system/core/debuggerd", 64 ], 65} 66 67cc_defaults { 68 name: "libscudo_defaults", 69 native_coverage: false, 70 ramdisk_available: true, 71 vendor_ramdisk_available: true, 72 recovery_available: true, 73 host_supported: true, 74 native_bridge_supported: true, 75 76 rtti: false, 77 stl: "none", 78 79 cflags: [ 80 "-O3", 81 "-fno-rtti", 82 // This option speeds up alloc/free code paths by about 5% to 7%. 83 "-fno-stack-protector", 84 "-fno-emulated-tls", 85 86 "-Wall", 87 "-Wextra", 88 "-Wunused", 89 "-Wno-unused-result", 90 91 "-Werror=pointer-to-int-cast", 92 "-Werror=int-to-pointer-cast", 93 "-Werror=thread-safety", 94 "-Werror=type-limits", 95 "-Werror", 96 97 // Always force alignment to 16 bytes even on 32 bit. 98 // Android assumes that allocations of multiples of 16 bytes 99 // will be aligned to at least 16 bytes. 100 "-DSCUDO_MIN_ALIGNMENT_LOG=4", 101 102 // Allow scudo to use android_unsafe_frame_pointer_chase(), which is 103 // normally a private function. 104 "-DHAVE_ANDROID_UNSAFE_FRAME_POINTER_CHASE", 105 ], 106 cppflags: [ 107 "-nostdinc++", 108 "-fno-exceptions", 109 ], 110 111 include_dirs: [ 112 "external/scudo/standalone/include", 113 ], 114 115 srcs: [ 116 "standalone/checksum.cpp", 117 "standalone/common.cpp", 118 "standalone/flags.cpp", 119 "standalone/flags_parser.cpp", 120 "standalone/linux.cpp", 121 "standalone/mem_map.cpp", 122 "standalone/release.cpp", 123 "standalone/report.cpp", 124 "standalone/rss_limit_checker.cpp", 125 "standalone/string_utils.cpp", 126 "standalone/timing.cpp", 127 "standalone/wrappers_c_bionic.cpp" 128 ], 129 arch: { 130 arm: { 131 cflags: ["-mcrc"], 132 srcs: ["standalone/crc32_hw.cpp"], 133 }, 134 arm64: { 135 cflags: ["-mcrc"], 136 srcs: ["standalone/crc32_hw.cpp"], 137 }, 138 riscv64: { 139 // This is a temporary fix, and should be reverted after 140 // yieldProcessor supports riscv. 141 cflags: ["-Wno-unused-parameter"], 142 }, 143 x86_64: { 144 cflags: ["-msse4.2"], 145 srcs: ["standalone/crc32_hw.cpp"], 146 }, 147 x86: { 148 cflags: ["-msse4.2"], 149 srcs: ["standalone/crc32_hw.cpp"], 150 }, 151 }, 152 153 target: { 154 bionic: { 155 system_shared_libs: [], 156 header_libs: [ 157 "libc_headers", 158 "bionic_libc_platform_headers", 159 ], 160 }, 161 native_bridge: { 162 cflags: ["-DSCUDO_DISABLE_TBI"], 163 }, 164 }, 165} 166 167cc_library_static { 168 name: "libscudo", 169 defaults: ["libscudo_defaults"], 170 cflags: [ 171 "-D_BIONIC=1", 172 "-DSCUDO_HAS_PLATFORM_TLS_SLOT", 173 ], 174 visibility: [ 175 "//bionic:__subpackages__", 176 "//frameworks/libs/native_bridge_support/libc:__subpackages__", 177 "//system/core/debuggerd:__subpackages__", 178 ], 179} 180 181cc_library_static { 182 name: "libscudo_for_testing", 183 defaults: ["libscudo_defaults"], 184 cflags: [ 185 "-DSCUDO_DEBUG", 186 ], 187} 188 189cc_defaults { 190 name: "scudo_unit_tests_default", 191 static_libs: ["libscudo_for_testing"], 192 include_dirs: [ 193 "external/scudo/standalone", 194 "external/scudo/standalone/include", 195 ], 196 cflags: [ 197 "-fno-emulated-tls", 198 // In memtag_test.cpp, some tests are disabled by GTEST_SKIP() so that 199 // they won't be run. However, for those disabled tests, it may contain 200 // unreachable code paths which will mislead some compiler checks. Given 201 // this flag won't be impacted too much, disable it only in the test. 202 "-Wno-unreachable-code-loop-increment", 203 "-Wno-unused-parameter", 204 "-DSCUDO_DEBUG", 205 ], 206 target: { 207 bionic: { 208 header_libs: ["bionic_libc_platform_headers"], 209 }, 210 }, 211 test_suites: ["general-tests"], 212 bootstrap: true, 213} 214 215cc_test { 216 name: "scudo_unit_tests", 217 defaults: ["scudo_unit_tests_default"], 218 // Temporarily disabled on host due to a 15-20s per-test timeout, 219 // which is currently exceeded by ScudoCombinedTest.BasicCombined. 220 host_supported: false, 221 srcs: [ 222 "standalone/tests/atomic_test.cpp", 223 "standalone/tests/bytemap_test.cpp", 224 "standalone/tests/checksum_test.cpp", 225 "standalone/tests/chunk_test.cpp", 226 "standalone/tests/combined_test.cpp", 227 "standalone/tests/flags_test.cpp", 228 "standalone/tests/list_test.cpp", 229 "standalone/tests/map_test.cpp", 230 "standalone/tests/memtag_test.cpp", 231 "standalone/tests/mutex_test.cpp", 232 "standalone/tests/primary_test.cpp", 233 "standalone/tests/quarantine_test.cpp", 234 "standalone/tests/release_test.cpp", 235 "standalone/tests/report_test.cpp", 236 "standalone/tests/scudo_unit_test_main.cpp", 237 "standalone/tests/secondary_test.cpp", 238 "standalone/tests/size_class_map_test.cpp", 239 "standalone/tests/stats_test.cpp", 240 "standalone/tests/strings_test.cpp", 241 "standalone/tests/timing_test.cpp", 242 "standalone/tests/tsd_test.cpp", 243 "standalone/tests/vector_test.cpp", 244 ], 245} 246 247cc_test { 248 name: "scudo_hooks_unit_tests", 249 defaults: ["scudo_unit_tests_default"], 250 host_supported: true, 251 srcs: [ 252 "standalone/tests/scudo_hooks_test.cpp", 253 "standalone/tests/scudo_unit_test_main.cpp", 254 ], 255} 256 257cc_fuzz { 258 name: "scudo_get_error_info_fuzzer", 259 host_supported: true, 260 compile_multilib: "64", 261 static_libs: ["libscudo"], 262 include_dirs: [ 263 "external/scudo/standalone", 264 "external/scudo/standalone/include", 265 ], 266 cflags: [ 267 "-Wno-unneeded-internal-declaration", 268 ], 269 srcs: ["standalone/fuzz/get_error_info_fuzzer.cpp"], 270 fuzz_config: { 271 componentid: 87896 272 }, 273} 274