xref: /freebsd/contrib/llvm-project/compiler-rt/lib/asan/asan_preinit.cpp (revision 68d75eff68281c1b445e3010bb975eae07aac225)
1*68d75effSDimitry Andric //===-- asan_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 AddressSanitizer, an address sanity checker.
10*68d75effSDimitry Andric //
11*68d75effSDimitry Andric // Call __asan_init at the very early stage of process startup.
12*68d75effSDimitry Andric //===----------------------------------------------------------------------===//
13*68d75effSDimitry Andric #include "asan_internal.h"
14*68d75effSDimitry Andric 
15*68d75effSDimitry Andric using namespace __asan;
16*68d75effSDimitry Andric 
17*68d75effSDimitry Andric #if SANITIZER_CAN_USE_PREINIT_ARRAY
18*68d75effSDimitry Andric   // The symbol is called __local_asan_preinit, because it's not intended to be
19*68d75effSDimitry Andric   // exported.
20*68d75effSDimitry Andric   // This code linked into the main executable when -fsanitize=address is in
21*68d75effSDimitry Andric   // the link flags. It can only use exported interface functions.
22*68d75effSDimitry Andric   __attribute__((section(".preinit_array"), used))
23*68d75effSDimitry Andric   void (*__local_asan_preinit)(void) = __asan_init;
24*68d75effSDimitry Andric #endif
25