xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/ubsan/ubsan_init_standalone_preinit.cc (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 //===-- ubsan_init_standalone_preinit.cc ---------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Initialization of standalone UBSan runtime.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #include "ubsan_platform.h"
13 #if !CAN_SANITIZE_UB
14 #error "UBSan is not supported on this platform!"
15 #endif
16 
17 #include "sanitizer_common/sanitizer_internal_defs.h"
18 #include "ubsan_init.h"
19 #include "ubsan_signals_standalone.h"
20 
21 #if SANITIZER_CAN_USE_PREINIT_ARRAY
22 
23 namespace __ubsan {
24 
PreInitAsStandalone()25 static void PreInitAsStandalone() {
26   InitAsStandalone();
27   InitializeDeadlySignals();
28 }
29 
30 } // namespace __ubsan
31 
32 __attribute__((section(".preinit_array"), used)) void (*__local_ubsan_preinit)(
33     void) = __ubsan::PreInitAsStandalone;
34 #endif // SANITIZER_CAN_USE_PREINIT_ARRAY
35