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
3 // found in the LICENSE file.
5 // This file contains the default options for various compiler-based dynamic
8 #include "build/build_config.h"
10 // Functions returning default options are declared weak in the tools' runtime
11 // libraries. To make the linker pick the strong replacements for those
12 // functions from this module, we explicitly force its inclusion by passing
13 // -Wl,-u_sanitizer_options_link_helper
15 void _sanitizer_options_link_helper() { }
17 #if defined(ADDRESS_SANITIZER)
18 // Default options for AddressSanitizer in various configurations:
19 // strict_memcmp=1 - disable the strict memcmp() checking
20 // (http://crbug.com/178677 and http://crbug.com/178404).
21 // malloc_context_size=5 - limit the size of stack traces collected by ASan
22 // for each malloc/free by 5 frames. These stack traces tend to accumulate
23 // very fast in applications using JIT (v8 in Chrome's case), see
24 // https://code.google.com/p/address-sanitizer/issues/detail?id=177
25 // symbolize=false - disable the in-process symbolization, which isn't 100%
26 // compatible with the existing sandboxes and doesn't make much sense for
27 // stripped official binaries.
28 // legacy_pthread_cond=1 - run in the libpthread 2.2.5 compatibility mode to
29 // work around libGL.so using the obsolete API, see
30 // http://crbug.com/341805. This may break if pthread_cond_t objects are
31 // accessed by both instrumented and non-instrumented binaries (e.g. if
32 // they reside in shared memory). This option is going to be deprecated in
33 // upstream AddressSanitizer and must not be used anywhere except the
35 // replace_intrin=0 - do not intercept memcpy(), memmove() and memset() to
36 // work around http://crbug.com/162461 (ASan report in OpenCL on Mac).
37 // check_printf=1 - check the memory accesses to printf (and other formatted
38 // output routines) arguments.
39 // use_sigaltstack=1 - handle signals on an alternate signal stack. Useful
40 // for stack overflow detection.
42 #if defined(GOOGLE_CHROME_BUILD)
43 // Default AddressSanitizer options for the official build. These do not affect
44 // tests on buildbots (which don't set GOOGLE_CHROME_BUILD) or non-official
46 const char kAsanDefaultOptions
[] =
47 "legacy_pthread_cond=1 malloc_context_size=5 strict_memcmp=0 "
48 "symbolize=false check_printf=1 use_sigaltstack=1 detect_leaks=0";
50 // Default AddressSanitizer options for buildbots and non-official builds.
51 const char *kAsanDefaultOptions
=
52 "strict_memcmp=0 symbolize=false check_printf=1 use_sigaltstack=1 "
54 #endif // GOOGLE_CHROME_BUILD
56 #elif defined(OS_MACOSX)
57 const char *kAsanDefaultOptions
=
58 "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1";
61 #if defined(OS_LINUX) || defined(OS_MACOSX)
63 __attribute__((no_sanitize_address
))
64 __attribute__((visibility("default")))
65 // The function isn't referenced from the executable itself. Make sure it isn't
66 // stripped by the linker.
68 const char *__asan_default_options() {
69 return kAsanDefaultOptions
;
71 #endif // OS_LINUX || OS_MACOSX
72 #endif // ADDRESS_SANITIZER
74 #if defined(THREAD_SANITIZER) && defined(OS_LINUX)
75 // Default options for ThreadSanitizer in various configurations:
76 // detect_deadlocks=1 - enable deadlock (lock inversion) detection.
77 // second_deadlock_stack=1 - more verbose deadlock reports.
78 // report_signal_unsafe=0 - do not report async-signal-unsafe functions
79 // called from signal handlers.
80 // report_thread_leaks=0 - do not report unjoined threads at the end of
81 // the program execution.
82 // print_suppressions=1 - print the list of matched suppressions.
83 const char kTsanDefaultOptions
[] =
84 "detect_deadlocks=1 second_deadlock_stack=1 report_signal_unsafe=0 "
85 "report_thread_leaks=0 print_suppressions=1 ";
88 __attribute__((no_sanitize_thread
))
89 __attribute__((visibility("default")))
90 // The function isn't referenced from the executable itself. Make sure it isn't
91 // stripped by the linker.
93 const char *__tsan_default_options() {
94 return kTsanDefaultOptions
;
97 #endif // THREAD_SANITIZER && OS_LINUX