1163953Srrs//===-- ubsan_init_standalone_preinit.cpp --------------------------------===//
2185694Srrs//
3235828Stuexen// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4235828Stuexen// See https://llvm.org/LICENSE.txt for license information.
5163953Srrs// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6163953Srrs//
7163953Srrs//===----------------------------------------------------------------------===//
8163953Srrs//
9163953Srrs// Initialization of standalone UBSan runtime.
10228653Stuexen//
11163953Srrs//===----------------------------------------------------------------------===//
12163953Srrs
13163953Srrs#include "ubsan_platform.h"
14228653Stuexen#if !CAN_SANITIZE_UB
15163953Srrs#error "UBSan is not supported on this platform!"
16163953Srrs#endif
17163953Srrs
18163953Srrs#include "sanitizer_common/sanitizer_internal_defs.h"
19163953Srrs#include "ubsan_init.h"
20163953Srrs#include "ubsan_signals_standalone.h"
21163953Srrs
22163953Srrs#if SANITIZER_CAN_USE_PREINIT_ARRAY
23163953Srrs
24163953Srrsnamespace __ubsan {
25163953Srrs
26163953Srrsstatic void PreInitAsStandalone() {
27163953Srrs  InitAsStandalone();
28163953Srrs  InitializeDeadlySignals();
29163953Srrs}
30163953Srrs
31163953Srrs} // namespace __ubsan
32163953Srrs
33163953Srrs__attribute__((section(".preinit_array"), used)) void (*__local_ubsan_preinit)(
34163953Srrs    void) = __ubsan::PreInitAsStandalone;
35235828Stuexen#endif // SANITIZER_CAN_USE_PREINIT_ARRAY
36166086Srrs