xref: /netbsd-src/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_preinit.cpp (revision ff6d591ca308ed13e9c5ae142cf113a246c2cdc6)
1*ff6d591cSmrg //===-- tsan_preinit.cpp --------------------------------------------------===//
2*ff6d591cSmrg //
3*ff6d591cSmrg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*ff6d591cSmrg // See https://llvm.org/LICENSE.txt for license information.
5*ff6d591cSmrg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*ff6d591cSmrg //
7*ff6d591cSmrg //===----------------------------------------------------------------------===//
8*ff6d591cSmrg //
9*ff6d591cSmrg // This file is a part of ThreadSanitizer.
10*ff6d591cSmrg //
11*ff6d591cSmrg // Call __tsan_init at the very early stage of process startup.
12*ff6d591cSmrg //===----------------------------------------------------------------------===//
13*ff6d591cSmrg 
14*ff6d591cSmrg #include "sanitizer_common/sanitizer_internal_defs.h"
15*ff6d591cSmrg #include "tsan_interface.h"
16*ff6d591cSmrg 
17*ff6d591cSmrg #if SANITIZER_CAN_USE_PREINIT_ARRAY
18*ff6d591cSmrg 
19*ff6d591cSmrg // The symbol is called __local_tsan_preinit, because it's not intended to be
20*ff6d591cSmrg // exported.
21*ff6d591cSmrg // This code linked into the main executable when -fsanitize=thread is in
22*ff6d591cSmrg // the link flags. It can only use exported interface functions.
23*ff6d591cSmrg __attribute__((section(".preinit_array"), used))
24*ff6d591cSmrg void (*__local_tsan_preinit)(void) = __tsan_init;
25*ff6d591cSmrg 
26*ff6d591cSmrg #endif
27