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