ubsan_init_standalone_preinit.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===-- ubsan_init_standalone_preinit.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. #include "ubsan_platform.h"
  13. #if !CAN_SANITIZE_UB
  14. #error "UBSan is not supported on this platform!"
  15. #endif
  16. #include "sanitizer_common/sanitizer_internal_defs.h"
  17. #include "ubsan_init.h"
  18. #include "ubsan_signals_standalone.h"
  19. #if SANITIZER_CAN_USE_PREINIT_ARRAY
  20. namespace __ubsan {
  21. static void PreInitAsStandalone() {
  22. InitAsStandalone();
  23. InitializeDeadlySignals();
  24. }
  25. } // namespace __ubsan
  26. __attribute__((section(".preinit_array"), used)) void (*__local_ubsan_preinit)(
  27. void) = __ubsan::PreInitAsStandalone;
  28. #endif // SANITIZER_CAN_USE_PREINIT_ARRAY