xref: /freebsd/contrib/llvm-project/compiler-rt/lib/ubsan/ubsan_init_standalone_preinit.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
168d75effSDimitry Andric //===-- ubsan_init_standalone_preinit.cpp --------------------------------===//
268d75effSDimitry Andric //
368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
668d75effSDimitry Andric //
768d75effSDimitry Andric //===----------------------------------------------------------------------===//
868d75effSDimitry Andric //
968d75effSDimitry Andric // Initialization of standalone UBSan runtime.
1068d75effSDimitry Andric //
1168d75effSDimitry Andric //===----------------------------------------------------------------------===//
1268d75effSDimitry Andric 
1368d75effSDimitry Andric #include "ubsan_platform.h"
1468d75effSDimitry Andric #if !CAN_SANITIZE_UB
1568d75effSDimitry Andric #error "UBSan is not supported on this platform!"
1668d75effSDimitry Andric #endif
1768d75effSDimitry Andric 
1868d75effSDimitry Andric #include "sanitizer_common/sanitizer_internal_defs.h"
1968d75effSDimitry Andric #include "ubsan_init.h"
2068d75effSDimitry Andric #include "ubsan_signals_standalone.h"
2168d75effSDimitry Andric 
2268d75effSDimitry Andric #if SANITIZER_CAN_USE_PREINIT_ARRAY
2368d75effSDimitry Andric 
2468d75effSDimitry Andric namespace __ubsan {
2568d75effSDimitry Andric 
PreInitAsStandalone()2668d75effSDimitry Andric static void PreInitAsStandalone() {
2768d75effSDimitry Andric   InitAsStandalone();
2868d75effSDimitry Andric   InitializeDeadlySignals();
2968d75effSDimitry Andric }
3068d75effSDimitry Andric 
3168d75effSDimitry Andric } // namespace __ubsan
3268d75effSDimitry Andric 
33*0fca6ea1SDimitry Andric __attribute__((section(".preinit_array"), used)) static auto preinit =
34*0fca6ea1SDimitry Andric     __ubsan::PreInitAsStandalone;
3568d75effSDimitry Andric #endif // SANITIZER_CAN_USE_PREINIT_ARRAY
36