From d2994a18c07c87bb7204ee463fcd11b9485c2239 Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Fri, 15 Dec 2017 17:30:50 +0000 Subject: [ubsan-minimal] Add a path for non-POSIX (and bare-metal) use of the library Summary: Hook on -DKERNEL_USE (which is also used in lib/builtins) to not import strlen and not rely on write() being implemented with the stderr on fd 2. With this, the only requirements to use this library are: - "Good enough" std::atomic and std::atomic - abort() being implemented - ubsan_message(const char*) being implemented Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39791 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320831 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ubsan_minimal/ubsan_minimal_handlers.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ubsan_minimal/ubsan_minimal_handlers.cc b/lib/ubsan_minimal/ubsan_minimal_handlers.cc index 92b673d9e..5a5675c98 100644 --- a/lib/ubsan_minimal/ubsan_minimal_handlers.cc +++ b/lib/ubsan_minimal/ubsan_minimal_handlers.cc @@ -5,9 +5,14 @@ #include #include +#ifdef KERNEL_USE +extern "C" void ubsan_message(const char *msg); +static void message(const char *msg) { ubsan_message(msg); } +#else static void message(const char *msg) { write(2, msg, strlen(msg)); } +#endif static const int kMaxCallerPcs = 20; static __sanitizer::atomic_uintptr_t caller_pcs[kMaxCallerPcs]; -- cgit v1.2.3