[compiler-rt] r320831 - [ubsan-minimal] Add a path for non-POSIX (and bare-metal) use of the library

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 09:30:50 PST 2017


Author: filcab
Date: Fri Dec 15 09:30:50 2017
New Revision: 320831

URL: http://llvm.org/viewvc/llvm-project?rev=320831&view=rev
Log:
[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: https://reviews.llvm.org/D39791

Modified:
    compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc

Modified: compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc?rev=320831&r1=320830&r2=320831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc (original)
+++ compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc Fri Dec 15 09:30:50 2017
@@ -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); }
+#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];




More information about the llvm-commits mailing list