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 // 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 | |
15 // Functions returning default options are declared weak in the tools' runtime | 10 // Functions returning default options are declared weak in the tools' runtime |
16 // libraries. To make the linker pick the strong replacements for those | 11 // libraries. To make the linker pick the strong replacements for those |
17 // functions from this module, we explicitly force its inclusion by passing | 12 // functions from this module, we explicitly force its inclusion by passing |
18 // -Wl,-u_sanitizer_options_link_helper | 13 // -Wl,-u_sanitizer_options_link_helper |
19 extern "C" | 14 extern "C" |
20 void _sanitizer_options_link_helper() { } | 15 void _sanitizer_options_link_helper() { } |
21 | 16 |
22 #if defined(ADDRESS_SANITIZER) | 17 #if defined(ADDRESS_SANITIZER) |
23 // Default options for AddressSanitizer in various configurations: | 18 // Default options for AddressSanitizer in various configurations: |
24 // strict_memcmp=1 - disable the strict memcmp() checking | 19 // strict_memcmp=1 - disable the strict memcmp() checking |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Default AddressSanitizer options for buildbots and non-official builds. | 54 // Default AddressSanitizer options for buildbots and non-official builds. |
60 const char *kAsanDefaultOptions = | 55 const char *kAsanDefaultOptions = |
61 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 " | 56 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 " |
62 "detect_leaks=0 strip_path_prefix=Release/../../ "; | 57 "detect_leaks=0 strip_path_prefix=Release/../../ "; |
63 #endif // GOOGLE_CHROME_BUILD | 58 #endif // GOOGLE_CHROME_BUILD |
64 | 59 |
65 #elif defined(OS_MACOSX) | 60 #elif defined(OS_MACOSX) |
66 const char *kAsanDefaultOptions = | 61 const char *kAsanDefaultOptions = |
67 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " | 62 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " |
68 "strip_path_prefix=Release/../../ "; | 63 "strip_path_prefix=Release/../../ "; |
69 static const char kNaClDefaultOptions[] = "handle_segv=0"; | |
70 static const char kNaClFlag[] = "--type=nacl-loader"; | |
71 #endif // OS_LINUX | 64 #endif // OS_LINUX |
72 | 65 |
73 #if defined(OS_LINUX) || defined(OS_MACOSX) | 66 #if defined(OS_LINUX) || defined(OS_MACOSX) |
74 extern "C" | 67 extern "C" |
75 __attribute__((no_sanitize_address)) | 68 __attribute__((no_sanitize_address)) |
76 __attribute__((visibility("default"))) | 69 __attribute__((visibility("default"))) |
77 // The function isn't referenced from the executable itself. Make sure it isn't | 70 // The function isn't referenced from the executable itself. Make sure it isn't |
78 // stripped by the linker. | 71 // stripped by the linker. |
79 __attribute__((used)) | 72 __attribute__((used)) |
80 const char *__asan_default_options() { | 73 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 | |
93 return kAsanDefaultOptions; | 74 return kAsanDefaultOptions; |
94 } | 75 } |
95 #endif // OS_LINUX || OS_MACOSX | 76 #endif // OS_LINUX || OS_MACOSX |
96 #endif // ADDRESS_SANITIZER | 77 #endif // ADDRESS_SANITIZER |
97 | 78 |
98 #if defined(THREAD_SANITIZER) && defined(OS_LINUX) | 79 #if defined(THREAD_SANITIZER) && defined(OS_LINUX) |
99 // Default options for ThreadSanitizer in various configurations: | 80 // Default options for ThreadSanitizer in various configurations: |
100 // detect_deadlocks=1 - enable deadlock (lock inversion) detection. | 81 // detect_deadlocks=1 - enable deadlock (lock inversion) detection. |
101 // second_deadlock_stack=1 - more verbose deadlock reports. | 82 // second_deadlock_stack=1 - more verbose deadlock reports. |
102 // report_signal_unsafe=0 - do not report async-signal-unsafe functions | 83 // report_signal_unsafe=0 - do not report async-signal-unsafe functions |
(...skipping 26 matching lines...) Expand all Loading... |
129 __attribute__((no_sanitize_thread)) | 110 __attribute__((no_sanitize_thread)) |
130 __attribute__((visibility("default"))) | 111 __attribute__((visibility("default"))) |
131 // The function isn't referenced from the executable itself. Make sure it isn't | 112 // The function isn't referenced from the executable itself. Make sure it isn't |
132 // stripped by the linker. | 113 // stripped by the linker. |
133 __attribute__((used)) | 114 __attribute__((used)) |
134 const char *__tsan_default_suppressions() { | 115 const char *__tsan_default_suppressions() { |
135 return kTSanDefaultSuppressions; | 116 return kTSanDefaultSuppressions; |
136 } | 117 } |
137 | 118 |
138 #endif // THREAD_SANITIZER && OS_LINUX | 119 #endif // THREAD_SANITIZER && OS_LINUX |
OLD | NEW |