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