Home | History | Annotate | Download | only in ubsan
      1 //===-- ubsan_init_standalone.cc ------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // Initialization of standalone UBSan runtime.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "ubsan_platform.h"
     15 #if !CAN_SANITIZE_UB
     16 # error "UBSan is not supported on this platform!"
     17 #endif
     18 
     19 #include "ubsan_init.h"
     20 
     21 #if SANITIZER_CAN_USE_PREINIT_ARRAY
     22 __attribute__((section(".preinit_array"), used))
     23 void (*__local_ubsan_preinit)(void) = __ubsan::InitAsStandalone;
     24 #else
     25 // Use a dynamic initializer.
     26 class UbsanStandaloneInitializer {
     27  public:
     28   UbsanStandaloneInitializer() {
     29     __ubsan::InitAsStandalone();
     30   }
     31 };
     32 static UbsanStandaloneInitializer ubsan_standalone_initializer;
     33 #endif  // SANITIZER_CAN_USE_PREINIT_ARRAY
     34 
     35