Skip to content

Commit

Permalink
[sanitizers] asan_globals GN option
Browse files Browse the repository at this point in the history
Detect overflow/underflow for global objects.
Enabled by default with asan, except for Android & Mac.

Review-Url: https://codereview.chromium.org/2130893002
Cr-Commit-Position: refs/heads/master@{#404918}
  • Loading branch information
aizatsky-chromium authored and Commit bot committed Jul 13, 2016
1 parent 71a4104 commit da5892e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
25 changes: 8 additions & 17 deletions build/config/sanitizers/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ config("asan_flags") {
cflags = []
if (is_asan) {
cflags += [ "-fsanitize=address" ]
if (!asan_globals) {
cflags += [
"-mllvm",
"-asan-globals=0",
]
}
if (is_win) {
cflags += [ "-fsanitize-blacklist=" +
rebase_path("//tools/memory/asan/blacklist_win.txt",
Expand All @@ -216,23 +222,8 @@ config("asan_flags") {
[ "-fsanitize-blacklist=" +
rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) ]
}
if (is_android) {
# Android build relies on -Wl,--gc-sections removing unreachable code.
# ASan instrumentation for globals inhibits this and results in a
# library with unresolvable relocations.
# TODO(eugenis): find a way to reenable this.
cflags += [
"-mllvm",
"-asan-globals=0",
]
} else if (is_mac) {
# http://crbug.com/352073
cflags += [
"-mllvm",
"-asan-globals=0",
]
# TODO(GYP): deal with mac_bundles.
} else if (is_win) {

if (is_win) {
assert(current_cpu == "x86", "WinASan is 32-bit only currently")
if (is_component_build) {
libs = [
Expand Down
11 changes: 10 additions & 1 deletion build/config/sanitizers/sanitizers.gni
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ declare_args() {
# trace-pc
# Default value when unset and use_sanitizer_coverage=true:
# edge,indirect-calls,8bit-counters

sanitizer_coverage_flags = ""
}

Expand All @@ -96,6 +95,16 @@ declare_args() {
# Enable -fsanitize-coverage.
use_sanitizer_coverage =
use_libfuzzer || use_afl || sanitizer_coverage_flags != ""

# Detect overflow/underflow for global objects.
#
# Android build relies on -Wl,--gc-sections removing unreachable code.
# ASan instrumentation for globals inhibits this and results in a
# library with unresolvable relocations.
# TODO(eugenis): find a way to reenable this.
#
# Mac: http://crbug.com/352073
asan_globals = !is_android && !is_mac
}

if (use_afl && sanitizer_coverage_flags == "") {
Expand Down

0 comments on commit da5892e

Please sign in to comment.