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