OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/chrome_build.gni") | 5 import("//build/config/chrome_build.gni") |
6 import("//build/config/chromecast_build.gni") | 6 import("//build/config/chromecast_build.gni") |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
8 import("//build/toolchain/toolchain.gni") | 8 import("//build/toolchain/toolchain.gni") |
9 | 9 |
10 # Contains the dependencies needed for sanitizers to link into executables and | 10 # Contains the dependencies needed for sanitizers to link into executables and |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 if (is_lsan) { | 118 if (is_lsan) { |
119 ldflags += [ "-fsanitize=leak" ] | 119 ldflags += [ "-fsanitize=leak" ] |
120 } | 120 } |
121 if (is_tsan) { | 121 if (is_tsan) { |
122 ldflags += [ "-fsanitize=thread" ] | 122 ldflags += [ "-fsanitize=thread" ] |
123 } | 123 } |
124 if (is_msan) { | 124 if (is_msan) { |
125 ldflags += [ "-fsanitize=memory" ] | 125 ldflags += [ "-fsanitize=memory" ] |
126 } | 126 } |
127 if (is_ubsan || is_ubsan_security) { | 127 if (is_ubsan || is_ubsan_security) { |
128 ldflags += [ "-fsanitize=undefined" ] | 128 ldflags += [ "-fsanitize=undefined" ] |
Nico
2016/06/02 21:06:09
but is having to set a toggle really easier than j
| |
129 } | 129 } |
130 if (is_ubsan_null) { | |
131 ldflags += [ "-fsanitize=null" ] | |
132 } | |
130 if (is_ubsan_vptr) { | 133 if (is_ubsan_vptr) { |
131 ldflags += [ "-fsanitize=vptr" ] | 134 ldflags += [ "-fsanitize=vptr" ] |
132 } | 135 } |
133 | 136 |
134 if (is_cfi && !is_nacl) { | 137 if (is_cfi && !is_nacl) { |
135 ldflags += [ | 138 ldflags += [ |
136 "-fsanitize=cfi-vcall", | 139 "-fsanitize=cfi-vcall", |
137 "-fsanitize=cfi-derived-cast", | 140 "-fsanitize=cfi-derived-cast", |
138 "-fsanitize=cfi-unrelated-cast", | 141 "-fsanitize=cfi-unrelated-cast", |
139 ] | 142 ] |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 if (is_ubsan_security) { | 357 if (is_ubsan_security) { |
355 ubsan_security_blacklist_path = | 358 ubsan_security_blacklist_path = |
356 rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir) | 359 rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir) |
357 cflags = [ | 360 cflags = [ |
358 "-fsanitize=signed-integer-overflow,shift,vptr", | 361 "-fsanitize=signed-integer-overflow,shift,vptr", |
359 "-fsanitize-blacklist=$ubsan_security_blacklist_path", | 362 "-fsanitize-blacklist=$ubsan_security_blacklist_path", |
360 ] | 363 ] |
361 } | 364 } |
362 } | 365 } |
363 | 366 |
367 config("ubsan_null_flags") { | |
368 if (is_ubsan_null) { | |
369 cflags = [ "-fsanitize=null" ] | |
370 } | |
371 } | |
372 | |
364 config("ubsan_vptr_flags") { | 373 config("ubsan_vptr_flags") { |
365 if (is_ubsan_vptr) { | 374 if (is_ubsan_vptr) { |
366 ubsan_vptr_blacklist_path = | 375 ubsan_vptr_blacklist_path = |
367 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) | 376 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) |
368 cflags = [ | 377 cflags = [ |
369 "-fsanitize=vptr", | 378 "-fsanitize=vptr", |
370 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", | 379 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", |
371 ] | 380 ] |
372 } | 381 } |
373 } | 382 } |
374 | 383 |
375 all_sanitizer_configs = [ | 384 all_sanitizer_configs = [ |
376 ":common_sanitizer_flags", | 385 ":common_sanitizer_flags", |
377 ":coverage_flags", | 386 ":coverage_flags", |
378 ":default_sanitizer_ldflags", | 387 ":default_sanitizer_ldflags", |
379 ":asan_flags", | 388 ":asan_flags", |
380 ":cfi_flags", | 389 ":cfi_flags", |
381 ":lsan_flags", | 390 ":lsan_flags", |
382 ":msan_flags", | 391 ":msan_flags", |
383 ":tsan_flags", | 392 ":tsan_flags", |
384 ":ubsan_flags", | 393 ":ubsan_flags", |
385 ":ubsan_no_recover", | 394 ":ubsan_no_recover", |
395 ":ubsan_null_flags", | |
386 ":ubsan_security_flags", | 396 ":ubsan_security_flags", |
387 ":ubsan_vptr_flags", | 397 ":ubsan_vptr_flags", |
388 ] | 398 ] |
389 | 399 |
390 # This config is applied by default to all targets. It sets the compiler flags | 400 # This config is applied by default to all targets. It sets the compiler flags |
391 # for sanitizer usage, or, if no sanitizer is set, does nothing. | 401 # for sanitizer usage, or, if no sanitizer is set, does nothing. |
392 # | 402 # |
393 # This needs to be in a separate config so that targets can opt out of | 403 # This needs to be in a separate config so that targets can opt out of |
394 # sanitizers (by removing the config) if they desire. Even if a target | 404 # sanitizers (by removing the config) if they desire. Even if a target |
395 # removes this config, executables & shared libraries should still depend on | 405 # removes this config, executables & shared libraries should still depend on |
396 # :deps if any of their dependencies have not opted out of sanitizers. | 406 # :deps if any of their dependencies have not opted out of sanitizers. |
397 # Keep this list in sync with default_sanitizer_flags_but_ubsan_vptr. | 407 # Keep this list in sync with default_sanitizer_flags_but_ubsan_vptr. |
398 config("default_sanitizer_flags") { | 408 config("default_sanitizer_flags") { |
399 configs = all_sanitizer_configs | 409 configs = all_sanitizer_configs |
400 } | 410 } |
401 | 411 |
402 # This config is equivalent to default_sanitizer_flags, but excludes ubsan_vptr. | 412 # This config is equivalent to default_sanitizer_flags, but excludes ubsan_vptr. |
403 # This allows to selectively disable ubsan_vptr, when needed. In particular, | 413 # This allows to selectively disable ubsan_vptr, when needed. In particular, |
404 # if some third_party code is required to be compiled without rtti, which | 414 # if some third_party code is required to be compiled without rtti, which |
405 # is a requirement for ubsan_vptr. | 415 # is a requirement for ubsan_vptr. |
406 config("default_sanitizer_flags_but_ubsan_vptr") { | 416 config("default_sanitizer_flags_but_ubsan_vptr") { |
407 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] | 417 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] |
408 } | 418 } |
409 | 419 |
410 config("default_sanitizer_flags_but_coverage") { | 420 config("default_sanitizer_flags_but_coverage") { |
411 configs = all_sanitizer_configs - [ ":coverage_flags" ] | 421 configs = all_sanitizer_configs - [ ":coverage_flags" ] |
412 } | 422 } |
OLD | NEW |