xref: /freebsd/contrib/llvm-project/compiler-rt/lib/asan/asan_preinit.cpp (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 //===-- asan_preinit.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of AddressSanitizer, an address sanity checker.
10 //
11 // Call __asan_init at the very early stage of process startup.
12 //===----------------------------------------------------------------------===//
13 #include "asan_internal.h"
14 
15 using namespace __asan;
16 
17 #if SANITIZER_CAN_USE_PREINIT_ARRAY
18   // The symbol is called __local_asan_preinit, because it's not intended to be
19   // exported.
20   // This code linked into the main executable when -fsanitize=address is in
21   // the link flags. It can only use exported interface functions.
22   __attribute__((section(".preinit_array"), used))
23   void (*__local_asan_preinit)(void) = __asan_init;
24 #endif
25