xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/lib/asan/asan_preinit.cc (revision a7c257b03e4462df2b1020128fb82716512d7856)
1*a7c257b0Skamil //===-- asan_preinit.cc ---------------------------------------------------===//
2*a7c257b0Skamil //
3*a7c257b0Skamil //                     The LLVM Compiler Infrastructure
4*a7c257b0Skamil //
5*a7c257b0Skamil // This file is distributed under the University of Illinois Open Source
6*a7c257b0Skamil // License. See LICENSE.TXT for details.
7*a7c257b0Skamil //
8*a7c257b0Skamil //===----------------------------------------------------------------------===//
9*a7c257b0Skamil //
10*a7c257b0Skamil // This file is a part of AddressSanitizer, an address sanity checker.
11*a7c257b0Skamil //
12*a7c257b0Skamil // Call __asan_init at the very early stage of process startup.
13*a7c257b0Skamil //===----------------------------------------------------------------------===//
14*a7c257b0Skamil #include "asan_internal.h"
15*a7c257b0Skamil 
16*a7c257b0Skamil using namespace __asan;
17*a7c257b0Skamil 
18*a7c257b0Skamil #if SANITIZER_CAN_USE_PREINIT_ARRAY
19*a7c257b0Skamil   // The symbol is called __local_asan_preinit, because it's not intended to be
20*a7c257b0Skamil   // exported.
21*a7c257b0Skamil   // This code linked into the main executable when -fsanitize=address is in
22*a7c257b0Skamil   // the link flags. It can only use exported interface functions.
23*a7c257b0Skamil   __attribute__((section(".preinit_array"), used))
24*a7c257b0Skamil   void (*__local_asan_preinit)(void) = __asan_init;
25*a7c257b0Skamil #endif
26