Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: build/sanitizers/sanitizer_options.cc

Issue 581983003: Enable ASan default options on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the dependency to target_defaults Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/common.gypi ('k') | build/sanitizers/sanitizers.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file contains the default options for various compiler-based dynamic 5 // This file contains the default options for various compiler-based dynamic
6 // tools. 6 // tools.
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX)
11 #include <crt_externs.h> // for _NSGetArgc, _NSGetArgv
12 #include <string.h>
13 #endif // ADDRESS_SANITIZER && OS_MACOSX
14
10 // Functions returning default options are declared weak in the tools' runtime 15 // Functions returning default options are declared weak in the tools' runtime
11 // libraries. To make the linker pick the strong replacements for those 16 // libraries. To make the linker pick the strong replacements for those
12 // functions from this module, we explicitly force its inclusion by passing 17 // functions from this module, we explicitly force its inclusion by passing
13 // -Wl,-u_sanitizer_options_link_helper 18 // -Wl,-u_sanitizer_options_link_helper
14 extern "C" 19 extern "C"
15 void _sanitizer_options_link_helper() { } 20 void _sanitizer_options_link_helper() { }
16 21
17 #if defined(ADDRESS_SANITIZER) 22 #if defined(ADDRESS_SANITIZER)
18 // Default options for AddressSanitizer in various configurations: 23 // Default options for AddressSanitizer in various configurations:
19 // strict_memcmp=1 - disable the strict memcmp() checking 24 // strict_memcmp=1 - disable the strict memcmp() checking
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Default AddressSanitizer options for buildbots and non-official builds. 59 // Default AddressSanitizer options for buildbots and non-official builds.
55 const char *kAsanDefaultOptions = 60 const char *kAsanDefaultOptions =
56 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 " 61 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 "
57 "detect_leaks=0 strip_path_prefix=Release/../../ "; 62 "detect_leaks=0 strip_path_prefix=Release/../../ ";
58 #endif // GOOGLE_CHROME_BUILD 63 #endif // GOOGLE_CHROME_BUILD
59 64
60 #elif defined(OS_MACOSX) 65 #elif defined(OS_MACOSX)
61 const char *kAsanDefaultOptions = 66 const char *kAsanDefaultOptions =
62 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " 67 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 "
63 "strip_path_prefix=Release/../../ "; 68 "strip_path_prefix=Release/../../ ";
69 static const char kNaClDefaultOptions[] = "handle_segv=0";
70 static const char kNaClFlag[] = "--type=nacl-loader";
64 #endif // OS_LINUX 71 #endif // OS_LINUX
65 72
66 #if defined(OS_LINUX) || defined(OS_MACOSX) 73 #if defined(OS_LINUX) || defined(OS_MACOSX)
67 extern "C" 74 extern "C"
68 __attribute__((no_sanitize_address)) 75 __attribute__((no_sanitize_address))
69 __attribute__((visibility("default"))) 76 __attribute__((visibility("default")))
70 // The function isn't referenced from the executable itself. Make sure it isn't 77 // The function isn't referenced from the executable itself. Make sure it isn't
71 // stripped by the linker. 78 // stripped by the linker.
72 __attribute__((used)) 79 __attribute__((used))
73 const char *__asan_default_options() { 80 const char *__asan_default_options() {
81 #if defined(OS_MACOSX)
82 char*** argvp = _NSGetArgv();
83 int* argcp = _NSGetArgc();
84 if (!argvp || !argcp) return kAsanDefaultOptions;
85 char** argv = *argvp;
86 int argc = *argcp;
87 for (int i = 0; i < argc; ++i) {
88 if (strcmp(argv[i], kNaClFlag) == 0) {
89 return kNaClDefaultOptions;
90 }
91 }
92 #endif
74 return kAsanDefaultOptions; 93 return kAsanDefaultOptions;
75 } 94 }
76 #endif // OS_LINUX || OS_MACOSX 95 #endif // OS_LINUX || OS_MACOSX
77 #endif // ADDRESS_SANITIZER 96 #endif // ADDRESS_SANITIZER
78 97
79 #if defined(THREAD_SANITIZER) && defined(OS_LINUX) 98 #if defined(THREAD_SANITIZER) && defined(OS_LINUX)
80 // Default options for ThreadSanitizer in various configurations: 99 // Default options for ThreadSanitizer in various configurations:
81 // detect_deadlocks=1 - enable deadlock (lock inversion) detection. 100 // detect_deadlocks=1 - enable deadlock (lock inversion) detection.
82 // second_deadlock_stack=1 - more verbose deadlock reports. 101 // second_deadlock_stack=1 - more verbose deadlock reports.
83 // report_signal_unsafe=0 - do not report async-signal-unsafe functions 102 // report_signal_unsafe=0 - do not report async-signal-unsafe functions
(...skipping 26 matching lines...) Expand all
110 __attribute__((no_sanitize_thread)) 129 __attribute__((no_sanitize_thread))
111 __attribute__((visibility("default"))) 130 __attribute__((visibility("default")))
112 // The function isn't referenced from the executable itself. Make sure it isn't 131 // The function isn't referenced from the executable itself. Make sure it isn't
113 // stripped by the linker. 132 // stripped by the linker.
114 __attribute__((used)) 133 __attribute__((used))
115 const char *__tsan_default_suppressions() { 134 const char *__tsan_default_suppressions() {
116 return kTSanDefaultSuppressions; 135 return kTSanDefaultSuppressions;
117 } 136 }
118 137
119 #endif // THREAD_SANITIZER && OS_LINUX 138 #endif // THREAD_SANITIZER && OS_LINUX
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | build/sanitizers/sanitizers.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698