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) | 10 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) |
11 #include <crt_externs.h> // for _NSGetArgc, _NSGetArgv | 11 #include <crt_externs.h> // for _NSGetArgc, _NSGetArgv |
12 #include <string.h> | 12 #include <string.h> |
13 #endif // ADDRESS_SANITIZER && OS_MACOSX | 13 #endif // ADDRESS_SANITIZER && OS_MACOSX |
14 | 14 |
| 15 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
| 16 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) |
15 // Functions returning default options are declared weak in the tools' runtime | 17 // Functions returning default options are declared weak in the tools' runtime |
16 // libraries. To make the linker pick the strong replacements for those | 18 // libraries. To make the linker pick the strong replacements for those |
17 // functions from this module, we explicitly force its inclusion by passing | 19 // functions from this module, we explicitly force its inclusion by passing |
18 // -Wl,-u_sanitizer_options_link_helper | 20 // -Wl,-u_sanitizer_options_link_helper |
19 extern "C" | 21 extern "C" |
20 void _sanitizer_options_link_helper() { } | 22 void _sanitizer_options_link_helper() { } |
21 | 23 |
| 24 // The callbacks we define here will be called from the sanitizer runtime, but |
| 25 // aren't referenced from the Chrome executable. We must ensure that those |
| 26 // callbacks are not sanitizer-instrumented, and that they aren't stripped by |
| 27 // the linker. |
| 28 #define SANITIZER_HOOK_ATTRIBUTE \ |
| 29 extern "C" \ |
| 30 __attribute__((no_sanitize_address)) \ |
| 31 __attribute__((no_sanitize_memory)) \ |
| 32 __attribute__((no_sanitize_thread)) \ |
| 33 __attribute__((visibility("default"))) \ |
| 34 __attribute__((used)) |
| 35 #endif |
| 36 |
22 #if defined(ADDRESS_SANITIZER) | 37 #if defined(ADDRESS_SANITIZER) |
23 // Default options for AddressSanitizer in various configurations: | 38 // Default options for AddressSanitizer in various configurations: |
24 // strict_memcmp=1 - disable the strict memcmp() checking | 39 // strict_memcmp=1 - disable the strict memcmp() checking |
25 // (http://crbug.com/178677 and http://crbug.com/178404). | 40 // (http://crbug.com/178677 and http://crbug.com/178404). |
26 // malloc_context_size=5 - limit the size of stack traces collected by ASan | 41 // malloc_context_size=5 - limit the size of stack traces collected by ASan |
27 // for each malloc/free by 5 frames. These stack traces tend to accumulate | 42 // for each malloc/free by 5 frames. These stack traces tend to accumulate |
28 // very fast in applications using JIT (v8 in Chrome's case), see | 43 // very fast in applications using JIT (v8 in Chrome's case), see |
29 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 | 44 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 |
30 // symbolize=false - disable the in-process symbolization, which isn't 100% | 45 // symbolize=false - disable the in-process symbolization, which isn't 100% |
31 // compatible with the existing sandboxes and doesn't make much sense for | 46 // compatible with the existing sandboxes and doesn't make much sense for |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #elif defined(OS_MACOSX) | 86 #elif defined(OS_MACOSX) |
72 const char *kAsanDefaultOptions = | 87 const char *kAsanDefaultOptions = |
73 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " | 88 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " |
74 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " | 89 "strip_path_prefix=Release/../../ fast_unwind_on_fatal=1 " |
75 "detect_stack_use_after_return=1 detect_odr_violation=0 "; | 90 "detect_stack_use_after_return=1 detect_odr_violation=0 "; |
76 static const char kNaClDefaultOptions[] = "handle_segv=0"; | 91 static const char kNaClDefaultOptions[] = "handle_segv=0"; |
77 static const char kNaClFlag[] = "--type=nacl-loader"; | 92 static const char kNaClFlag[] = "--type=nacl-loader"; |
78 #endif // OS_LINUX | 93 #endif // OS_LINUX |
79 | 94 |
80 #if defined(OS_LINUX) || defined(OS_MACOSX) | 95 #if defined(OS_LINUX) || defined(OS_MACOSX) |
81 extern "C" | 96 SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() { |
82 __attribute__((no_sanitize_address)) | |
83 __attribute__((visibility("default"))) | |
84 // The function isn't referenced from the executable itself. Make sure it isn't | |
85 // stripped by the linker. | |
86 __attribute__((used)) | |
87 const char *__asan_default_options() { | |
88 #if defined(OS_MACOSX) | 97 #if defined(OS_MACOSX) |
89 char*** argvp = _NSGetArgv(); | 98 char*** argvp = _NSGetArgv(); |
90 int* argcp = _NSGetArgc(); | 99 int* argcp = _NSGetArgc(); |
91 if (!argvp || !argcp) return kAsanDefaultOptions; | 100 if (!argvp || !argcp) return kAsanDefaultOptions; |
92 char** argv = *argvp; | 101 char** argv = *argvp; |
93 int argc = *argcp; | 102 int argc = *argcp; |
94 for (int i = 0; i < argc; ++i) { | 103 for (int i = 0; i < argc; ++i) { |
95 if (strcmp(argv[i], kNaClFlag) == 0) { | 104 if (strcmp(argv[i], kNaClFlag) == 0) { |
96 return kNaClDefaultOptions; | 105 return kNaClDefaultOptions; |
97 } | 106 } |
(...skipping 15 matching lines...) Expand all Loading... |
113 // print_suppressions=1 - print the list of matched suppressions. | 122 // print_suppressions=1 - print the list of matched suppressions. |
114 // history_size=7 - make the history buffer proportional to 2^7 (the maximum | 123 // history_size=7 - make the history buffer proportional to 2^7 (the maximum |
115 // value) to keep more stack traces. | 124 // value) to keep more stack traces. |
116 // strip_path_prefix=Release/../../ - prefixes up to and including this | 125 // strip_path_prefix=Release/../../ - prefixes up to and including this |
117 // substring will be stripped from source file paths in symbolized reports. | 126 // substring will be stripped from source file paths in symbolized reports. |
118 const char kTsanDefaultOptions[] = | 127 const char kTsanDefaultOptions[] = |
119 "detect_deadlocks=1 second_deadlock_stack=1 report_signal_unsafe=0 " | 128 "detect_deadlocks=1 second_deadlock_stack=1 report_signal_unsafe=0 " |
120 "report_thread_leaks=0 print_suppressions=1 history_size=7 " | 129 "report_thread_leaks=0 print_suppressions=1 history_size=7 " |
121 "strip_path_prefix=Release/../../ "; | 130 "strip_path_prefix=Release/../../ "; |
122 | 131 |
123 extern "C" | 132 SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_options() { |
124 __attribute__((no_sanitize_thread)) | |
125 __attribute__((visibility("default"))) | |
126 // The function isn't referenced from the executable itself. Make sure it isn't | |
127 // stripped by the linker. | |
128 __attribute__((used)) | |
129 const char *__tsan_default_options() { | |
130 return kTsanDefaultOptions; | 133 return kTsanDefaultOptions; |
131 } | 134 } |
132 | 135 |
133 extern "C" char kTSanDefaultSuppressions[]; | 136 extern "C" char kTSanDefaultSuppressions[]; |
134 | 137 |
135 extern "C" | 138 SANITIZER_HOOK_ATTRIBUTE const char *__tsan_default_suppressions() { |
136 __attribute__((no_sanitize_thread)) | |
137 __attribute__((visibility("default"))) | |
138 // The function isn't referenced from the executable itself. Make sure it isn't | |
139 // stripped by the linker. | |
140 __attribute__((used)) | |
141 const char *__tsan_default_suppressions() { | |
142 return kTSanDefaultSuppressions; | 139 return kTSanDefaultSuppressions; |
143 } | 140 } |
144 | 141 |
145 #endif // THREAD_SANITIZER && OS_LINUX | 142 #endif // THREAD_SANITIZER && OS_LINUX |
| 143 |
| 144 #if defined(LEAK_SANITIZER) |
| 145 // Default options for LeakSanitizer: |
| 146 // print_suppressions=1 - print the list of matched suppressions. |
| 147 // strip_path_prefix=Release/../../ - prefixes up to and including this |
| 148 // substring will be stripped from source file paths in symbolized reports. |
| 149 const char kLsanDefaultOptions[] = |
| 150 "print_suppressions=1 strip_path_prefix=Release/../../ "; |
| 151 |
| 152 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_options() { |
| 153 return kLsanDefaultOptions; |
| 154 } |
| 155 |
| 156 extern "C" char kLSanDefaultSuppressions[]; |
| 157 |
| 158 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { |
| 159 return kLSanDefaultSuppressions; |
| 160 } |
| 161 |
| 162 #endif // LEAK_SANITIZER |
OLD | NEW |