| 1 | //===-- ubsan_init_standalone.cpp -----------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Initialization of standalone UBSan runtime. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "ubsan_platform.h" |
| 14 | #if !CAN_SANITIZE_UB |
| 15 | # error "UBSan is not supported on this platform!" |
| 16 | #endif |
| 17 | |
| 18 | #include "sanitizer_common/sanitizer_internal_defs.h" |
| 19 | #include "ubsan_init.h" |
| 20 | #include "ubsan_signals_standalone.h" |
| 21 | |
| 22 | #if SANITIZER_FUCHSIA |
| 23 | namespace __sanitizer { |
| 24 | // UBSan doesn't need to do anything else special in the startup hook. |
| 25 | void EarlySanitizerInit() {} |
| 26 | } // namespace __sanitizer |
| 27 | #endif // SANITIZER_FUCHSIA |
| 28 | |
| 29 | namespace __ubsan { |
| 30 | |
| 31 | class UbsanStandaloneInitializer { |
| 32 | public: |
| 33 | UbsanStandaloneInitializer() { |
| 34 | InitAsStandalone(); |
| 35 | InitializeDeadlySignals(); |
| 36 | } |
| 37 | }; |
| 38 | static UbsanStandaloneInitializer ubsan_standalone_initializer; |
| 39 | |
| 40 | } // namespace __ubsan |
| 41 | |