xref: /llvm-project/compiler-rt/lib/ubsan/ubsan_init_standalone_preinit.cpp (revision bb8230bb2bcc9b68fbe9b9c02ac1c85dee4c80a0)
146ba9697SNico Weber //===-- ubsan_init_standalone_preinit.cpp --------------------------------===//
246ba9697SNico Weber //
346ba9697SNico Weber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
446ba9697SNico Weber // See https://llvm.org/LICENSE.txt for license information.
546ba9697SNico Weber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
646ba9697SNico Weber //
746ba9697SNico Weber //===----------------------------------------------------------------------===//
846ba9697SNico Weber //
946ba9697SNico Weber // Initialization of standalone UBSan runtime.
1046ba9697SNico Weber //
1146ba9697SNico Weber //===----------------------------------------------------------------------===//
1246ba9697SNico Weber 
1346ba9697SNico Weber #include "ubsan_platform.h"
1446ba9697SNico Weber #if !CAN_SANITIZE_UB
1546ba9697SNico Weber #error "UBSan is not supported on this platform!"
1646ba9697SNico Weber #endif
1746ba9697SNico Weber 
1846ba9697SNico Weber #include "sanitizer_common/sanitizer_internal_defs.h"
1946ba9697SNico Weber #include "ubsan_init.h"
2046ba9697SNico Weber #include "ubsan_signals_standalone.h"
2146ba9697SNico Weber 
2246ba9697SNico Weber #if SANITIZER_CAN_USE_PREINIT_ARRAY
2346ba9697SNico Weber 
2446ba9697SNico Weber namespace __ubsan {
2546ba9697SNico Weber 
2646ba9697SNico Weber static void PreInitAsStandalone() {
2746ba9697SNico Weber   InitAsStandalone();
2846ba9697SNico Weber   InitializeDeadlySignals();
2946ba9697SNico Weber }
3046ba9697SNico Weber 
3146ba9697SNico Weber } // namespace __ubsan
3246ba9697SNico Weber 
33*bb8230bbSFangrui Song __attribute__((section(".preinit_array"), used)) static auto preinit =
34*bb8230bbSFangrui Song     __ubsan::PreInitAsStandalone;
3546ba9697SNico Weber #endif // SANITIZER_CAN_USE_PREINIT_ARRAY
36