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