blob: 4c8a6114a9efa2f5ef55c5480d10762cfc45176f [file] [log] [blame]
Colin Cross16b23492016-01-06 14:41:07 -08001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
18 "fmt"
Colin Cross8ff9ef42017-05-08 13:44:11 -070019 "io"
Jeff Gaston72765392017-11-28 16:37:53 -080020 "sort"
Colin Cross16b23492016-01-06 14:41:07 -080021 "strings"
Vishwath Mohane7128792017-11-17 11:08:10 -080022 "sync"
Colin Cross16b23492016-01-06 14:41:07 -080023
Colin Cross6b753602018-06-21 13:03:07 -070024 "github.com/google/blueprint"
25
Colin Cross635c3b02016-05-18 15:37:25 -070026 "android/soong/android"
Evgenii Stepanovaf36db12016-08-15 14:18:24 -070027 "android/soong/cc/config"
Colin Cross16b23492016-01-06 14:41:07 -080028)
29
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070030var (
31 // Any C flags added by sanitizer which libTooling tools may not
32 // understand also need to be added to ClangLibToolingUnknownCflags in
33 // cc/config/clang.go
Vishwath Mohanf3918d32017-02-14 07:59:33 -080034
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070035 asanCflags = []string{"-fno-omit-frame-pointer"}
36 asanLdflags = []string{"-Wl,-u,__asan_preinit"}
37 asanLibs = []string{"libasan"}
38
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000039 cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070040 "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070041 cfiLdflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fsanitize=cfi",
Pirama Arumuga Nainarbdb17f02017-08-28 21:50:17 -070042 "-Wl,-plugin-opt,O1"}
Vishwath Mohane7128792017-11-17 11:08:10 -080043 cfiExportsMapPath = "build/soong/cc/config/cfi_exports.map"
Vishwath Mohane7128792017-11-17 11:08:10 -080044 cfiStaticLibsMutex sync.Mutex
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070045
Ivan Lozano30c5db22018-02-21 15:49:20 -080046 intOverflowCflags = []string{"-fsanitize-blacklist=build/soong/cc/config/integer_overflow_blacklist.txt"}
47 minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer", "-fno-sanitize-recover=integer"}
Dan Willemsencbceaab2016-10-13 16:44:07 -070048)
49
Colin Cross16b23492016-01-06 14:41:07 -080050type sanitizerType int
51
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -070052func boolPtr(v bool) *bool {
53 if v {
54 return &v
55 } else {
56 return nil
57 }
58}
59
Colin Cross16b23492016-01-06 14:41:07 -080060const (
61 asan sanitizerType = iota + 1
62 tsan
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070063 intOverflow
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000064 cfi
Colin Cross16b23492016-01-06 14:41:07 -080065)
66
67func (t sanitizerType) String() string {
68 switch t {
69 case asan:
70 return "asan"
71 case tsan:
72 return "tsan"
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070073 case intOverflow:
74 return "intOverflow"
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000075 case cfi:
76 return "cfi"
Colin Cross16b23492016-01-06 14:41:07 -080077 default:
78 panic(fmt.Errorf("unknown sanitizerType %d", t))
79 }
80}
81
82type SanitizeProperties struct {
83 // enable AddressSanitizer, ThreadSanitizer, or UndefinedBehaviorSanitizer
84 Sanitize struct {
Nan Zhang0007d812017-11-07 10:57:05 -080085 Never *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -080086
87 // main sanitizers
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -070088 Address *bool `android:"arch_variant"`
89 Thread *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -080090
91 // local sanitizers
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070092 Undefined *bool `android:"arch_variant"`
93 All_undefined *bool `android:"arch_variant"`
94 Misc_undefined []string `android:"arch_variant"`
95 Coverage *bool `android:"arch_variant"`
96 Safestack *bool `android:"arch_variant"`
97 Cfi *bool `android:"arch_variant"`
98 Integer_overflow *bool `android:"arch_variant"`
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -070099 Scudo *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -0800100
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700101 // Sanitizers to run in the diagnostic mode (as opposed to the release mode).
102 // Replaces abort() on error with a human-readable error message.
103 // Address and Thread sanitizers always run in diagnostic mode.
104 Diag struct {
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700105 Undefined *bool `android:"arch_variant"`
106 Cfi *bool `android:"arch_variant"`
107 Integer_overflow *bool `android:"arch_variant"`
108 Misc_undefined []string `android:"arch_variant"`
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700109 }
110
111 // value to pass to -fsanitize-recover=
Colin Cross16b23492016-01-06 14:41:07 -0800112 Recover []string
113
114 // value to pass to -fsanitize-blacklist
115 Blacklist *string
116 } `android:"arch_variant"`
117
Ivan Lozano30c5db22018-02-21 15:49:20 -0800118 SanitizerEnabled bool `blueprint:"mutated"`
119 SanitizeDep bool `blueprint:"mutated"`
120 MinimalRuntimeDep bool `blueprint:"mutated"`
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700121 UbsanRuntimeDep bool `blueprint:"mutated"`
Ivan Lozano30c5db22018-02-21 15:49:20 -0800122 InSanitizerDir bool `blueprint:"mutated"`
Colin Cross16b23492016-01-06 14:41:07 -0800123}
124
125type sanitize struct {
126 Properties SanitizeProperties
Colin Cross8ff9ef42017-05-08 13:44:11 -0700127
Jiyong Park27b188b2017-07-18 13:23:39 +0900128 runtimeLibrary string
129 androidMkRuntimeLibrary string
Colin Cross16b23492016-01-06 14:41:07 -0800130}
131
Vishwath Mohane7128792017-11-17 11:08:10 -0800132func init() {
133 android.RegisterMakeVarsProvider(pctx, cfiMakeVarsProvider)
134}
135
Colin Cross16b23492016-01-06 14:41:07 -0800136func (sanitize *sanitize) props() []interface{} {
137 return []interface{}{&sanitize.Properties}
138}
139
140func (sanitize *sanitize) begin(ctx BaseModuleContext) {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700141 s := &sanitize.Properties.Sanitize
142
Colin Cross16b23492016-01-06 14:41:07 -0800143 // Don't apply sanitizers to NDK code.
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700144 if ctx.useSdk() {
Nan Zhang0007d812017-11-07 10:57:05 -0800145 s.Never = BoolPtr(true)
Colin Cross16b23492016-01-06 14:41:07 -0800146 }
147
148 // Never always wins.
Nan Zhang0007d812017-11-07 10:57:05 -0800149 if Bool(s.Never) {
Colin Cross16b23492016-01-06 14:41:07 -0800150 return
151 }
152
Colin Cross16b23492016-01-06 14:41:07 -0800153 var globalSanitizers []string
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700154 var globalSanitizersDiag []string
155
Colin Cross16b23492016-01-06 14:41:07 -0800156 if ctx.clang() {
157 if ctx.Host() {
Pirama Arumuga Nainar83d716c2018-06-26 14:01:40 -0700158 if !ctx.Windows() {
159 globalSanitizers = ctx.Config().SanitizeHost()
160 }
Colin Cross16b23492016-01-06 14:41:07 -0800161 } else {
Colin Cross6510f912017-11-29 00:27:14 -0800162 arches := ctx.Config().SanitizeDeviceArch()
Colin Cross23ae82a2016-11-02 14:34:39 -0700163 if len(arches) == 0 || inList(ctx.Arch().ArchType.Name, arches) {
Colin Cross6510f912017-11-29 00:27:14 -0800164 globalSanitizers = ctx.Config().SanitizeDevice()
165 globalSanitizersDiag = ctx.Config().SanitizeDeviceDiag()
Colin Cross23ae82a2016-11-02 14:34:39 -0700166 }
Colin Cross16b23492016-01-06 14:41:07 -0800167 }
168 }
169
Colin Cross16b23492016-01-06 14:41:07 -0800170 if len(globalSanitizers) > 0 {
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000171 var found bool
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700172 if found, globalSanitizers = removeFromList("undefined", globalSanitizers); found && s.All_undefined == nil {
173 s.All_undefined = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000174 }
Colin Cross16b23492016-01-06 14:41:07 -0800175
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700176 if found, globalSanitizers = removeFromList("default-ub", globalSanitizers); found && s.Undefined == nil {
177 s.Undefined = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000178 }
179
Evgenii Stepanov774cb812016-12-28 15:52:54 -0800180 if found, globalSanitizers = removeFromList("address", globalSanitizers); found {
181 if s.Address == nil {
182 s.Address = boolPtr(true)
183 } else if *s.Address == false {
184 // Coverage w/o address is an error. If globalSanitizers includes both, and the module
185 // disables address, then disable coverage as well.
186 _, globalSanitizers = removeFromList("coverage", globalSanitizers)
187 }
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000188 }
189
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700190 if found, globalSanitizers = removeFromList("thread", globalSanitizers); found && s.Thread == nil {
191 s.Thread = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000192 }
193
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700194 if found, globalSanitizers = removeFromList("coverage", globalSanitizers); found && s.Coverage == nil {
195 s.Coverage = boolPtr(true)
196 }
197
198 if found, globalSanitizers = removeFromList("safe-stack", globalSanitizers); found && s.Safestack == nil {
199 s.Safestack = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000200 }
201
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700202 if found, globalSanitizers = removeFromList("cfi", globalSanitizers); found && s.Cfi == nil {
Colin Cross6510f912017-11-29 00:27:14 -0800203 if !ctx.Config().CFIDisabledForPath(ctx.ModuleDir()) {
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700204 s.Cfi = boolPtr(true)
205 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700206 }
207
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700208 // Global integer_overflow builds do not support static libraries.
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700209 if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700210 if !ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) && !ctx.static() {
Ivan Lozano5f595532017-07-13 14:46:05 -0700211 s.Integer_overflow = boolPtr(true)
212 }
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700213 }
214
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700215 if found, globalSanitizers = removeFromList("scudo", globalSanitizers); found && s.Scudo == nil {
216 s.Scudo = boolPtr(true)
217 }
218
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000219 if len(globalSanitizers) > 0 {
220 ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0])
221 }
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700222
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700223 // Global integer_overflow builds do not support static library diagnostics.
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700224 if found, globalSanitizersDiag = removeFromList("integer_overflow", globalSanitizersDiag); found &&
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700225 s.Diag.Integer_overflow == nil && Bool(s.Integer_overflow) && !ctx.static() {
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700226 s.Diag.Integer_overflow = boolPtr(true)
227 }
228
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700229 if found, globalSanitizersDiag = removeFromList("cfi", globalSanitizersDiag); found &&
230 s.Diag.Cfi == nil && Bool(s.Cfi) {
231 s.Diag.Cfi = boolPtr(true)
232 }
233
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700234 if len(globalSanitizersDiag) > 0 {
235 ctx.ModuleErrorf("unknown global sanitizer diagnostics option %s", globalSanitizersDiag[0])
236 }
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700237 }
Colin Cross3c344ef2016-07-18 15:44:56 -0700238
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700239 // Enable CFI for all components in the include paths
Colin Cross6510f912017-11-29 00:27:14 -0800240 if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) {
Vishwath Mohan3af8ee02018-03-30 02:55:23 +0000241 s.Cfi = boolPtr(true)
242 if inList("cfi", ctx.Config().SanitizeDeviceDiag()) {
243 s.Diag.Cfi = boolPtr(true)
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700244 }
245 }
246
Evgenii Stepanova83fdac2017-01-31 18:37:30 -0800247 // CFI needs gold linker, and mips toolchain does not have one.
Colin Cross6510f912017-11-29 00:27:14 -0800248 if !ctx.Config().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 {
Vishwath Mohan1b017a72017-01-19 13:54:55 -0800249 s.Cfi = nil
250 s.Diag.Cfi = nil
251 }
252
Vishwath Mohan6d67e6e2017-02-07 20:31:41 -0800253 // Also disable CFI for arm32 until b/35157333 is fixed.
254 if ctx.Arch().ArchType == android.Arm {
255 s.Cfi = nil
256 s.Diag.Cfi = nil
257 }
258
Vishwath Mohan8f4fdd82017-04-20 07:42:52 -0700259 // Also disable CFI if ASAN is enabled.
260 if Bool(s.Address) {
261 s.Cfi = nil
262 s.Diag.Cfi = nil
263 }
264
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700265 // Disable sanitizers that depend on the UBSan runtime for host builds.
Vishwath Mohane7128792017-11-17 11:08:10 -0800266 if ctx.Host() {
267 s.Cfi = nil
268 s.Diag.Cfi = nil
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700269 s.Misc_undefined = nil
270 s.Undefined = nil
271 s.All_undefined = nil
272 s.Integer_overflow = nil
Vishwath Mohane7128792017-11-17 11:08:10 -0800273 }
274
Colin Cross3c344ef2016-07-18 15:44:56 -0700275 if ctx.staticBinary() {
276 s.Address = nil
Colin Cross91169fe2016-08-11 15:54:20 -0700277 s.Coverage = nil
Colin Cross3c344ef2016-07-18 15:44:56 -0700278 s.Thread = nil
Colin Cross16b23492016-01-06 14:41:07 -0800279 }
280
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700281 if Bool(s.All_undefined) {
282 s.Undefined = nil
283 }
284
Evgenii Stepanov0a8a0d02016-05-12 13:54:53 -0700285 if !ctx.toolchain().Is64Bit() {
286 // TSAN and SafeStack are not supported on 32-bit architectures
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700287 s.Thread = nil
288 s.Safestack = nil
Colin Cross16b23492016-01-06 14:41:07 -0800289 // TODO(ccross): error for compile_multilib = "32"?
290 }
291
Evgenii Stepanov76cee232017-01-27 15:44:44 -0800292 if ctx.Os() != android.Windows && (Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || Bool(s.Thread) ||
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700293 Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) || Bool(s.Integer_overflow) || len(s.Misc_undefined) > 0 ||
294 Bool(s.Scudo)) {
Colin Cross3c344ef2016-07-18 15:44:56 -0700295 sanitize.Properties.SanitizerEnabled = true
296 }
297
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700298 // Disable Scudo if ASan or TSan is enabled.
299 if Bool(s.Address) || Bool(s.Thread) {
300 s.Scudo = nil
301 }
302
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700303 if Bool(s.Coverage) {
304 if !Bool(s.Address) {
Colin Cross16b23492016-01-06 14:41:07 -0800305 ctx.ModuleErrorf(`Use of "coverage" also requires "address"`)
306 }
307 }
308}
309
310func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
311 if !sanitize.Properties.SanitizerEnabled { // || c.static() {
312 return deps
313 }
314
315 if ctx.Device() {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700316 if Bool(sanitize.Properties.Sanitize.Address) {
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700317 deps.StaticLibs = append(deps.StaticLibs, asanLibs...)
Colin Cross16b23492016-01-06 14:41:07 -0800318 }
319 }
320
321 return deps
322}
323
324func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
Ivan Lozano59fdea22018-05-10 14:17:22 -0700325 minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
326 minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib
Ivan Lozano30c5db22018-02-21 15:49:20 -0800327
328 if ctx.Device() && sanitize.Properties.MinimalRuntimeDep {
329 flags.LdFlags = append(flags.LdFlags, minimalRuntimePath)
Ivan Lozano59fdea22018-05-10 14:17:22 -0700330 flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
Ivan Lozano30c5db22018-02-21 15:49:20 -0800331 }
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700332 if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep {
Colin Cross16b23492016-01-06 14:41:07 -0800333 return flags
334 }
335
336 if !ctx.clang() {
337 ctx.ModuleErrorf("Use of sanitizers requires clang")
338 }
339
340 var sanitizers []string
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700341 var diagSanitizers []string
Colin Cross16b23492016-01-06 14:41:07 -0800342
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700343 if Bool(sanitize.Properties.Sanitize.All_undefined) {
Colin Cross16b23492016-01-06 14:41:07 -0800344 sanitizers = append(sanitizers, "undefined")
Colin Cross16b23492016-01-06 14:41:07 -0800345 } else {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700346 if Bool(sanitize.Properties.Sanitize.Undefined) {
Colin Cross16b23492016-01-06 14:41:07 -0800347 sanitizers = append(sanitizers,
348 "bool",
349 "integer-divide-by-zero",
350 "return",
351 "returns-nonnull-attribute",
352 "shift-exponent",
353 "unreachable",
354 "vla-bound",
355 // TODO(danalbert): The following checks currently have compiler performance issues.
356 //"alignment",
357 //"bounds",
358 //"enum",
359 //"float-cast-overflow",
360 //"float-divide-by-zero",
361 //"nonnull-attribute",
362 //"null",
363 //"shift-base",
364 //"signed-integer-overflow",
365 // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
366 // https://llvm.org/PR19302
367 // http://reviews.llvm.org/D6974
368 // "object-size",
369 )
370 }
371 sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...)
372 }
373
Ivan Lozano651275b2017-06-13 10:24:34 -0700374 if Bool(sanitize.Properties.Sanitize.Diag.Undefined) {
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700375 diagSanitizers = append(diagSanitizers, "undefined")
376 }
377
Ivan Lozano651275b2017-06-13 10:24:34 -0700378 diagSanitizers = append(diagSanitizers, sanitize.Properties.Sanitize.Diag.Misc_undefined...)
379
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700380 if Bool(sanitize.Properties.Sanitize.Address) {
Colin Cross635c3b02016-05-18 15:37:25 -0700381 if ctx.Arch().ArchType == android.Arm {
Colin Cross16b23492016-01-06 14:41:07 -0800382 // Frame pointer based unwinder in ASan requires ARM frame setup.
383 // TODO: put in flags?
384 flags.RequiredInstructionSet = "arm"
385 }
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700386 flags.CFlags = append(flags.CFlags, asanCflags...)
387 flags.LdFlags = append(flags.LdFlags, asanLdflags...)
Colin Cross16b23492016-01-06 14:41:07 -0800388
Colin Cross16b23492016-01-06 14:41:07 -0800389 if ctx.Host() {
390 // -nodefaultlibs (provided with libc++) prevents the driver from linking
391 // libraries needed with -fsanitize=address. http://b/18650275 (WAI)
Colin Cross16b23492016-01-06 14:41:07 -0800392 flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
393 } else {
394 flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
395 flags.DynamicLinker = "/system/bin/linker_asan"
396 if flags.Toolchain.Is64Bit() {
397 flags.DynamicLinker += "64"
398 }
399 }
400 sanitizers = append(sanitizers, "address")
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700401 diagSanitizers = append(diagSanitizers, "address")
Colin Cross16b23492016-01-06 14:41:07 -0800402 }
403
Yabin Cui6be405e2017-10-19 15:52:11 -0700404 if Bool(sanitize.Properties.Sanitize.Thread) {
405 sanitizers = append(sanitizers, "thread")
406 }
407
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700408 if Bool(sanitize.Properties.Sanitize.Coverage) {
Zach Riggle06bbd892017-08-21 17:12:32 -0400409 flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp")
Colin Cross16b23492016-01-06 14:41:07 -0800410 }
411
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700412 if Bool(sanitize.Properties.Sanitize.Safestack) {
Evgenii Stepanov0a8a0d02016-05-12 13:54:53 -0700413 sanitizers = append(sanitizers, "safe-stack")
414 }
415
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700416 if Bool(sanitize.Properties.Sanitize.Cfi) {
Evgenii Stepanov7ebf9fa2017-01-20 14:13:06 -0800417 if ctx.Arch().ArchType == android.Arm {
418 // __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp). LLVM is not set up
419 // to do this on a function basis, so force Thumb on the entire module.
420 flags.RequiredInstructionSet = "thumb"
421 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700422 sanitizers = append(sanitizers, "cfi")
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000423
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700424 flags.CFlags = append(flags.CFlags, cfiCflags...)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000425 // Only append the default visibility flag if -fvisibility has not already been set
426 // to hidden.
427 if !inList("-fvisibility=hidden", flags.CFlags) {
428 flags.CFlags = append(flags.CFlags, "-fvisibility=default")
429 }
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700430 flags.LdFlags = append(flags.LdFlags, cfiLdflags...)
Zhizhou Yang51be6322018-02-08 18:32:11 -0800431 flags.ArGoldPlugin = true
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700432 if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
433 diagSanitizers = append(diagSanitizers, "cfi")
434 }
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000435
436 if ctx.staticBinary() {
437 _, flags.CFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.CFlags)
438 _, flags.LdFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.LdFlags)
439 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700440 }
441
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700442 if Bool(sanitize.Properties.Sanitize.Integer_overflow) {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700443 sanitizers = append(sanitizers, "unsigned-integer-overflow")
444 sanitizers = append(sanitizers, "signed-integer-overflow")
445 flags.CFlags = append(flags.CFlags, intOverflowCflags...)
446 if Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) {
447 diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow")
448 diagSanitizers = append(diagSanitizers, "signed-integer-overflow")
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700449 }
450 }
451
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700452 if Bool(sanitize.Properties.Sanitize.Scudo) {
453 sanitizers = append(sanitizers, "scudo")
454 }
455
Colin Cross16b23492016-01-06 14:41:07 -0800456 if len(sanitizers) > 0 {
457 sanitizeArg := "-fsanitize=" + strings.Join(sanitizers, ",")
Ivan Lozano30c5db22018-02-21 15:49:20 -0800458
Colin Cross16b23492016-01-06 14:41:07 -0800459 flags.CFlags = append(flags.CFlags, sanitizeArg)
460 if ctx.Host() {
461 flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all")
462 flags.LdFlags = append(flags.LdFlags, sanitizeArg)
Evgenii Stepanov76cee232017-01-27 15:44:44 -0800463 // Host sanitizers only link symbols in the final executable, so
464 // there will always be undefined symbols in intermediate libraries.
465 _, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags)
Colin Cross16b23492016-01-06 14:41:07 -0800466 } else {
Colin Cross263abbd2016-07-15 13:10:48 -0700467 flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
Ivan Lozano30c5db22018-02-21 15:49:20 -0800468
469 if enableMinimalRuntime(sanitize) {
470 flags.CFlags = append(flags.CFlags, strings.Join(minimalRuntimeFlags, " "))
471 flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...)
Ivan Lozano59fdea22018-05-10 14:17:22 -0700472 flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
Ivan Lozano30c5db22018-02-21 15:49:20 -0800473 }
Colin Cross16b23492016-01-06 14:41:07 -0800474 }
475 }
476
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700477 if len(diagSanitizers) > 0 {
Ivan Lozanob7d0f522018-01-20 01:44:38 +0000478 flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap="+strings.Join(diagSanitizers, ","))
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700479 }
480 // FIXME: enable RTTI if diag + (cfi or vptr)
481
Andreas Gampe97071162017-05-08 13:15:23 -0700482 if sanitize.Properties.Sanitize.Recover != nil {
483 flags.CFlags = append(flags.CFlags, "-fsanitize-recover="+
484 strings.Join(sanitize.Properties.Sanitize.Recover, ","))
485 }
486
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700487 // Link a runtime library if needed.
488 runtimeLibrary := ""
489 if Bool(sanitize.Properties.Sanitize.Address) {
490 runtimeLibrary = config.AddressSanitizerRuntimeLibrary(ctx.toolchain())
Yabin Cui6be405e2017-10-19 15:52:11 -0700491 } else if Bool(sanitize.Properties.Sanitize.Thread) {
492 runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain())
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700493 } else if Bool(sanitize.Properties.Sanitize.Scudo) {
494 runtimeLibrary = config.ScudoRuntimeLibrary(ctx.toolchain())
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700495 } else if len(diagSanitizers) > 0 || sanitize.Properties.UbsanRuntimeDep {
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700496 runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain())
497 }
498
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700499 if runtimeLibrary != "" {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700500 runtimeLibraryPath := "${config.ClangAsanLibDir}/" + runtimeLibrary
501 if !ctx.static() {
502 runtimeLibraryPath = runtimeLibraryPath + ctx.toolchain().ShlibSuffix()
503 } else {
504 runtimeLibraryPath = runtimeLibraryPath + ".a"
505 }
506
Jiyong Park27b188b2017-07-18 13:23:39 +0900507 // ASan runtime library must be the first in the link order.
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700508 flags.libFlags = append([]string{runtimeLibraryPath}, flags.libFlags...)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700509 sanitize.runtimeLibrary = runtimeLibrary
Jiyong Park27b188b2017-07-18 13:23:39 +0900510
511 // When linking against VNDK, use the vendor variant of the runtime lib
512 sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700513 if ctx.useVndk() {
Jiyong Park27b188b2017-07-18 13:23:39 +0900514 sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix
515 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700516 }
517
Colin Cross635c3b02016-05-18 15:37:25 -0700518 blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist)
Colin Cross16b23492016-01-06 14:41:07 -0800519 if blacklist.Valid() {
520 flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String())
521 flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path())
522 }
523
524 return flags
525}
526
Colin Cross8ff9ef42017-05-08 13:44:11 -0700527func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700528 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Jiyong Park27b188b2017-07-18 13:23:39 +0900529 if sanitize.androidMkRuntimeLibrary != "" {
530 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700531 }
Colin Cross8ff9ef42017-05-08 13:44:11 -0700532 })
Vishwath Mohane7128792017-11-17 11:08:10 -0800533
534 // Add a suffix for CFI-enabled static libraries to allow surfacing both to make without a
535 // name conflict.
536 if ret.Class == "STATIC_LIBRARIES" && Bool(sanitize.Properties.Sanitize.Cfi) {
537 ret.SubName += ".cfi"
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000538 }
Colin Cross8ff9ef42017-05-08 13:44:11 -0700539}
540
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700541func (sanitize *sanitize) inSanitizerDir() bool {
542 return sanitize.Properties.InSanitizerDir
Colin Cross30d5f512016-05-03 18:02:42 -0700543}
544
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000545func (sanitize *sanitize) getSanitizerBoolPtr(t sanitizerType) *bool {
Vishwath Mohan95229302017-08-11 00:53:16 +0000546 switch t {
547 case asan:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000548 return sanitize.Properties.Sanitize.Address
Vishwath Mohan95229302017-08-11 00:53:16 +0000549 case tsan:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000550 return sanitize.Properties.Sanitize.Thread
Vishwath Mohan95229302017-08-11 00:53:16 +0000551 case intOverflow:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000552 return sanitize.Properties.Sanitize.Integer_overflow
553 case cfi:
554 return sanitize.Properties.Sanitize.Cfi
Vishwath Mohan95229302017-08-11 00:53:16 +0000555 default:
556 panic(fmt.Errorf("unknown sanitizerType %d", t))
557 }
558}
559
Dan Albert7d1eecf2018-01-19 12:30:45 -0800560func (sanitize *sanitize) isUnsanitizedVariant() bool {
561 return !sanitize.isSanitizerEnabled(asan) &&
562 !sanitize.isSanitizerEnabled(tsan) &&
563 !sanitize.isSanitizerEnabled(cfi)
564}
565
Jayant Chowdharyb7e08ca2018-05-10 15:29:24 -0700566func (sanitize *sanitize) isVariantOnProductionDevice() bool {
567 return !sanitize.isSanitizerEnabled(asan) &&
568 !sanitize.isSanitizerEnabled(tsan)
569}
570
Colin Cross16b23492016-01-06 14:41:07 -0800571func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) {
572 switch t {
573 case asan:
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700574 sanitize.Properties.Sanitize.Address = boolPtr(b)
Colin Cross91169fe2016-08-11 15:54:20 -0700575 if !b {
576 sanitize.Properties.Sanitize.Coverage = nil
577 }
Colin Cross16b23492016-01-06 14:41:07 -0800578 case tsan:
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700579 sanitize.Properties.Sanitize.Thread = boolPtr(b)
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700580 case intOverflow:
581 sanitize.Properties.Sanitize.Integer_overflow = boolPtr(b)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000582 case cfi:
583 sanitize.Properties.Sanitize.Cfi = boolPtr(b)
Colin Cross16b23492016-01-06 14:41:07 -0800584 default:
585 panic(fmt.Errorf("unknown sanitizerType %d", t))
586 }
587 if b {
588 sanitize.Properties.SanitizerEnabled = true
589 }
590}
591
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000592// Check if the sanitizer is explicitly disabled (as opposed to nil by
593// virtue of not being set).
594func (sanitize *sanitize) isSanitizerExplicitlyDisabled(t sanitizerType) bool {
595 if sanitize == nil {
596 return false
597 }
598
599 sanitizerVal := sanitize.getSanitizerBoolPtr(t)
600 return sanitizerVal != nil && *sanitizerVal == false
601}
602
603// There isn't an analog of the method above (ie:isSanitizerExplicitlyEnabled)
604// because enabling a sanitizer either directly (via the blueprint) or
605// indirectly (via a mutator) sets the bool ptr to true, and you can't
606// distinguish between the cases. It isn't needed though - both cases can be
607// treated identically.
608func (sanitize *sanitize) isSanitizerEnabled(t sanitizerType) bool {
609 if sanitize == nil {
610 return false
611 }
612
613 sanitizerVal := sanitize.getSanitizerBoolPtr(t)
614 return sanitizerVal != nil && *sanitizerVal == true
615}
616
Colin Cross6b753602018-06-21 13:03:07 -0700617func isSanitizableDependencyTag(tag blueprint.DependencyTag) bool {
618 t, ok := tag.(dependencyTag)
619 return ok && t.library || t == reuseObjTag
620}
621
Colin Cross16b23492016-01-06 14:41:07 -0800622// Propagate asan requirements down from binaries
Colin Cross635c3b02016-05-18 15:37:25 -0700623func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
624 return func(mctx android.TopDownMutatorContext) {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000625 if c, ok := mctx.Module().(*Module); ok && c.sanitize.isSanitizerEnabled(t) {
Colin Cross6b753602018-06-21 13:03:07 -0700626 mctx.WalkDeps(func(child, parent android.Module) bool {
627 if !isSanitizableDependencyTag(mctx.OtherModuleDependencyTag(child)) {
628 return false
629 }
630 if d, ok := child.(*Module); ok && d.sanitize != nil &&
Nan Zhang0007d812017-11-07 10:57:05 -0800631 !Bool(d.sanitize.Properties.Sanitize.Never) &&
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000632 !d.sanitize.isSanitizerExplicitlyDisabled(t) {
633 if (t == cfi && d.static()) || t != cfi {
634 d.sanitize.Properties.SanitizeDep = true
635 }
Colin Cross16b23492016-01-06 14:41:07 -0800636 }
Colin Cross6b753602018-06-21 13:03:07 -0700637 return true
Colin Cross16b23492016-01-06 14:41:07 -0800638 })
639 }
640 }
641}
642
Ivan Lozano30c5db22018-02-21 15:49:20 -0800643// Propagate the ubsan minimal runtime dependency when there are integer overflow sanitized static dependencies.
Colin Cross6b753602018-06-21 13:03:07 -0700644func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) {
645 if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
646 mctx.WalkDeps(func(child, parent android.Module) bool {
647 if !isSanitizableDependencyTag(mctx.OtherModuleDependencyTag(child)) {
648 return false
649 }
650 if d, ok := child.(*Module); ok && d.static() && d.sanitize != nil {
Ivan Lozano30c5db22018-02-21 15:49:20 -0800651
Colin Cross6b753602018-06-21 13:03:07 -0700652 if enableMinimalRuntime(d.sanitize) {
653 // If a static dependency is built with the minimal runtime,
654 // make sure we include the ubsan minimal runtime.
655 c.sanitize.Properties.MinimalRuntimeDep = true
656 } else if Bool(d.sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
657 len(d.sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0 {
658 // If a static dependency runs with full ubsan diagnostics,
659 // make sure we include the ubsan runtime.
660 c.sanitize.Properties.UbsanRuntimeDep = true
Ivan Lozano30c5db22018-02-21 15:49:20 -0800661 }
Colin Cross6b753602018-06-21 13:03:07 -0700662 }
663 return true
664 })
Ivan Lozano30c5db22018-02-21 15:49:20 -0800665 }
666}
667
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000668// Create sanitized variants for modules that need them
Colin Cross635c3b02016-05-18 15:37:25 -0700669func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
670 return func(mctx android.BottomUpMutatorContext) {
Vishwath Mohane6153452017-08-11 00:52:44 +0000671 if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000672 if c.isDependencyRoot() && c.sanitize.isSanitizerEnabled(t) {
Colin Cross30d5f512016-05-03 18:02:42 -0700673 modules := mctx.CreateVariations(t.String())
674 modules[0].(*Module).sanitize.SetSanitizer(t, true)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000675 } else if c.sanitize.isSanitizerEnabled(t) || c.sanitize.Properties.SanitizeDep {
676 // Save original sanitizer status before we assign values to variant
677 // 0 as that overwrites the original.
678 isSanitizerEnabled := c.sanitize.isSanitizerEnabled(t)
679
Colin Crossb0f28952016-09-19 16:46:53 -0700680 modules := mctx.CreateVariations("", t.String())
681 modules[0].(*Module).sanitize.SetSanitizer(t, false)
682 modules[1].(*Module).sanitize.SetSanitizer(t, true)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000683
Colin Crossb0f28952016-09-19 16:46:53 -0700684 modules[0].(*Module).sanitize.Properties.SanitizeDep = false
685 modules[1].(*Module).sanitize.Properties.SanitizeDep = false
Vishwath Mohane7128792017-11-17 11:08:10 -0800686
687 // We don't need both variants active for anything but CFI-enabled
688 // target static libraries, so suppress the appropriate variant in
689 // all other cases.
690 if t == cfi {
691 if c.static() {
692 if !mctx.Device() {
693 if isSanitizerEnabled {
694 modules[0].(*Module).Properties.PreventInstall = true
695 modules[0].(*Module).Properties.HideFromMake = true
696 } else {
697 modules[1].(*Module).Properties.PreventInstall = true
698 modules[1].(*Module).Properties.HideFromMake = true
699 }
700 } else {
Colin Cross6510f912017-11-29 00:27:14 -0800701 cfiStaticLibs := cfiStaticLibs(mctx.Config())
Vishwath Mohane7128792017-11-17 11:08:10 -0800702
703 cfiStaticLibsMutex.Lock()
704 *cfiStaticLibs = append(*cfiStaticLibs, c.Name())
705 cfiStaticLibsMutex.Unlock()
706 }
707 } else {
708 modules[0].(*Module).Properties.PreventInstall = true
709 modules[0].(*Module).Properties.HideFromMake = true
710 }
711 } else if t == asan {
712 if mctx.Device() {
713 // CFI and ASAN are currently mutually exclusive so disable
714 // CFI if this is an ASAN variant.
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000715 modules[1].(*Module).sanitize.Properties.InSanitizerDir = true
716 modules[1].(*Module).sanitize.SetSanitizer(cfi, false)
717 }
Vishwath Mohane21fe422017-11-01 19:42:45 -0700718 if isSanitizerEnabled {
719 modules[0].(*Module).Properties.PreventInstall = true
Vishwath Mohane7128792017-11-17 11:08:10 -0800720 modules[0].(*Module).Properties.HideFromMake = true
Vishwath Mohane21fe422017-11-01 19:42:45 -0700721 } else {
722 modules[1].(*Module).Properties.PreventInstall = true
Vishwath Mohane7128792017-11-17 11:08:10 -0800723 modules[1].(*Module).Properties.HideFromMake = true
Vishwath Mohane21fe422017-11-01 19:42:45 -0700724 }
725 }
Colin Cross16b23492016-01-06 14:41:07 -0800726 }
727 c.sanitize.Properties.SanitizeDep = false
728 }
729 }
730}
Vishwath Mohane7128792017-11-17 11:08:10 -0800731
732func cfiStaticLibs(config android.Config) *[]string {
733 return config.Once("cfiStaticLibs", func() interface{} {
734 return &[]string{}
735 }).(*[]string)
736}
737
Ivan Lozano30c5db22018-02-21 15:49:20 -0800738func enableMinimalRuntime(sanitize *sanitize) bool {
739 if !Bool(sanitize.Properties.Sanitize.Address) &&
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700740 !Bool(sanitize.Properties.Sanitize.Scudo) &&
Ivan Lozano30c5db22018-02-21 15:49:20 -0800741 (Bool(sanitize.Properties.Sanitize.Integer_overflow) ||
742 len(sanitize.Properties.Sanitize.Misc_undefined) > 0) &&
743 !(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
744 Bool(sanitize.Properties.Sanitize.Diag.Cfi) ||
745 len(sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0) {
746 return true
747 }
748 return false
749}
750
Vishwath Mohane7128792017-11-17 11:08:10 -0800751func cfiMakeVarsProvider(ctx android.MakeVarsContext) {
752 cfiStaticLibs := cfiStaticLibs(ctx.Config())
Jeff Gaston72765392017-11-28 16:37:53 -0800753 sort.Strings(*cfiStaticLibs)
Vishwath Mohane7128792017-11-17 11:08:10 -0800754 ctx.Strict("SOONG_CFI_STATIC_LIBRARIES", strings.Join(*cfiStaticLibs, " "))
755}