[PATCH] D39870: [sanitizer] Allow sanitizers to redefine implementation of signal interceptors

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 14:06:00 PST 2017


vitalybuka created this revision.
Herald added a subscriber: kubamracek.

https://reviews.llvm.org/D39870

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc


Index: compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
+++ compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
@@ -18,10 +18,22 @@
 
 using namespace __sanitizer;
 
+#ifndef SIGNAL_INTERCEPTOR_SIGNAL_IMPL
+#define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) { \
+  return REAL(func)(signum, handler); \
+}
+#endif
+
+#ifndef SIGNAL_INTERCEPTOR_SIGACTION_IMPL
+#define SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact) { \
+  return REAL(sigaction)(signum, act, oldact); \
+}
+#endif
+
 #if SANITIZER_INTERCEPT_BSD_SIGNAL
 INTERCEPTOR(void *, bsd_signal, int signum, void *handler) {
   if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
-  return REAL(bsd_signal)(signum, handler);
+  SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler);
 }
 #define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
 #else  // SANITIZER_INTERCEPT_BSD_SIGNAL
@@ -31,14 +43,14 @@
 #if SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
 INTERCEPTOR(void *, signal, int signum, void *handler) {
   if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return nullptr;
-  return REAL(signal)(signum, handler);
+  SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
 }
 #define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)
 
 INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act,
             struct sigaction *oldact) {
   if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
-  return REAL(sigaction)(signum, act, oldact);
+  SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
 }
 #define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39870.122331.patch
Type: text/x-patch
Size: 1779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/2adb6f49/attachment.bin>


More information about the llvm-commits mailing list