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) || \ | 15 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
16 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) | 16 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ |
| 17 defined(UNDEFINED_SANITIZER) |
17 // Functions returning default options are declared weak in the tools' runtime | 18 // Functions returning default options are declared weak in the tools' runtime |
18 // libraries. To make the linker pick the strong replacements for those | 19 // libraries. To make the linker pick the strong replacements for those |
19 // functions from this module, we explicitly force its inclusion by passing | 20 // functions from this module, we explicitly force its inclusion by passing |
20 // -Wl,-u_sanitizer_options_link_helper | 21 // -Wl,-u_sanitizer_options_link_helper |
21 extern "C" | 22 extern "C" |
22 void _sanitizer_options_link_helper() { } | 23 void _sanitizer_options_link_helper() { } |
23 | 24 |
24 // The callbacks we define here will be called from the sanitizer runtime, but | 25 // 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 // 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 // callbacks are not sanitizer-instrumented, and that they aren't stripped by |
27 // the linker. | 28 // the linker. |
28 #define SANITIZER_HOOK_ATTRIBUTE \ | 29 #define SANITIZER_HOOK_ATTRIBUTE \ |
29 extern "C" \ | 30 extern "C" \ |
30 __attribute__((no_sanitize_address)) \ | 31 __attribute__((no_sanitize("address", "memory", "thread", "undefined"))) \ |
31 __attribute__((no_sanitize_memory)) \ | 32 __attribute__((visibility("default"))) \ |
32 __attribute__((no_sanitize_thread)) \ | |
33 __attribute__((visibility("default"))) \ | |
34 __attribute__((used)) | 33 __attribute__((used)) |
35 #endif | 34 #endif |
36 | 35 |
37 #if defined(ADDRESS_SANITIZER) | 36 #if defined(ADDRESS_SANITIZER) |
38 // Default options for AddressSanitizer in various configurations: | 37 // Default options for AddressSanitizer in various configurations: |
39 // malloc_context_size=5 - limit the size of stack traces collected by ASan | 38 // malloc_context_size=5 - limit the size of stack traces collected by ASan |
40 // for each malloc/free by 5 frames. These stack traces tend to accumulate | 39 // for each malloc/free by 5 frames. These stack traces tend to accumulate |
41 // very fast in applications using JIT (v8 in Chrome's case), see | 40 // very fast in applications using JIT (v8 in Chrome's case), see |
42 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 | 41 // https://code.google.com/p/address-sanitizer/issues/detail?id=177 |
43 // symbolize=false - disable the in-process symbolization, which isn't 100% | 42 // symbolize=false - disable the in-process symbolization, which isn't 100% |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return kLsanDefaultOptions; | 169 return kLsanDefaultOptions; |
171 } | 170 } |
172 | 171 |
173 extern "C" char kLSanDefaultSuppressions[]; | 172 extern "C" char kLSanDefaultSuppressions[]; |
174 | 173 |
175 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { | 174 SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { |
176 return kLSanDefaultSuppressions; | 175 return kLSanDefaultSuppressions; |
177 } | 176 } |
178 | 177 |
179 #endif // LEAK_SANITIZER | 178 #endif // LEAK_SANITIZER |
| 179 |
| 180 #if defined(UNDEFINED_SANITIZER) |
| 181 // Default options for UndefinedBehaviorSanitizer: |
| 182 // print_stacktrace=1 - print the stacktrace when UBSan reports an error. |
| 183 const char kUbsanDefaultOptions[] = "print_stacktrace=1"; |
| 184 |
| 185 SANITIZER_HOOK_ATTRIBUTE const char* __ubsan_default_options() { |
| 186 return kUbsanDefaultOptions; |
| 187 } |
| 188 |
| 189 #endif // UNDEFINED_SANITIZER |
OLD | NEW |