diff options
authorFilipe Cabecinhas <>2017-12-15 17:30:50 +0000
committerFilipe Cabecinhas <>2017-12-15 17:30:50 +0000
commitd2994a18c07c87bb7204ee463fcd11b9485c2239 (patch)
parentc81be8bd5687559a577b3828f623261b5edce399 (diff)
[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<void*> and std::atomic<int> - abort() being implemented - ubsan_message(const char*) being implemented Reviewers: eugenis Subscribers: llvm-commits Differential Revision: git-svn-id: 91177308-0d34-0410-b5e6-96231b3b80d8
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ubsan_minimal/ b/lib/ubsan_minimal/
index 92b673d9e..5a5675c98 100644
--- a/lib/ubsan_minimal/
+++ b/lib/ubsan_minimal/
@@ -5,9 +5,14 @@
#include <string.h>
#include <unistd.h>
+#ifdef KERNEL_USE
+extern "C" void ubsan_message(const char *msg);
+static void message(const char *msg) { ubsan_message(msg); }
static void message(const char *msg) {
write(2, msg, strlen(msg));
static const int kMaxCallerPcs = 20;
static __sanitizer::atomic_uintptr_t caller_pcs[kMaxCallerPcs];