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