aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt/lib/rtsan/rtsan.h
diff options
context:
space:
mode:
authorChris Apple <cja-private@pm.me>2024-07-09 11:00:38 -0700
committerGitHub <noreply@github.com>2024-07-09 11:00:38 -0700
commit1adb55b1c4bfd21752e6b2718c3c4b8abb203d09 (patch)
treea395d7d8931339db84065f86fdb51a01bba84ba9 /compiler-rt/lib/rtsan/rtsan.h
parent8492ad5964606c0b96e32c697def7e9701bb5d5a (diff)
downloadllvm-1adb55b1c4bfd21752e6b2718c3c4b8abb203d09.zip
llvm-1adb55b1c4bfd21752e6b2718c3c4b8abb203d09.tar.gz
llvm-1adb55b1c4bfd21752e6b2718c3c4b8abb203d09.tar.bz2
[compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (#92460)
Introducing the main runtime of realtime sanitizer. For more information, please see the [discourse thread](https://discourse.llvm.org/t/rfc-nolock-and-noalloc-attributes/76837). We have also put together a [reviewer support document](https://github.com/realtime-sanitizer/radsan/blob/doc/review-support/doc/review.md) to show what our intention is. This review introduces the sanitizer backend. This includes: * CMake build files (largely adapted from asan). * Main RTSan architecture (the external API, thread local context, stack). * Interceptors. * Many unit tests. Please see the [reviewer support document](https://github.com/realtime-sanitizer/radsan/blob/doc/review-support/doc/review.md) for what our next steps are. We are moving in lockstep with this PR #84983 for the codegen coming up next. Note to reviewers: If you see support documentation mention "RADSan", this was the "old acronym" for the realtime sanitizer, they refer to the same thing. If you see it let us know and we can correct it (especially in the llvm codebase) --------- Co-authored-by: David Trevelyan <david.trevelyan@gmail.com>
Diffstat (limited to 'compiler-rt/lib/rtsan/rtsan.h')
-rw-r--r--compiler-rt/lib/rtsan/rtsan.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/compiler-rt/lib/rtsan/rtsan.h b/compiler-rt/lib/rtsan/rtsan.h
new file mode 100644
index 0000000..8b1219c
--- /dev/null
+++ b/compiler-rt/lib/rtsan/rtsan.h
@@ -0,0 +1,40 @@
+//===--- rtsan.h - Realtime Sanitizer ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+//===----------------------------------------------------------------------===//
+
+#pragma once
+
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+extern "C" {
+
+// Initialise rtsan interceptors.
+// A call to this method is added to the preinit array on Linux systems.
+SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_init();
+
+// Enter real-time context.
+// When in a real-time context, RTSan interceptors will error if realtime
+// violations are detected. Calls to this method are injected at the code
+// generation stage when RTSan is enabled.
+SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_enter();
+
+// Exit the real-time context.
+// When not in a real-time context, RTSan interceptors will simply forward
+// intercepted method calls to the real methods.
+SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_exit();
+
+// Disable all RTSan error reporting.
+// Injected into the code if "nosanitize(realtime)" is on a function.
+SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_off();
+
+// Re-enable all RTSan error reporting.
+// The counterpart to `__rtsan_off`.
+SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_on();
+
+} // extern "C"