[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:49:16 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317843: [sanitizer] Allow sanitizers to redefine implementation of signal interceptors (authored by vitalybuka).
Changed prior to commit:
https://reviews.llvm.org/D39870?vs=122335&id=122336#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39870
Files:
compiler-rt/trunk/lib/asan/asan_interceptors.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_signal_interceptors.inc
Index: compiler-rt/trunk/lib/asan/asan_interceptors.h
===================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h
@@ -19,6 +19,10 @@
#include "interception/interception.h"
#include "sanitizer_common/sanitizer_platform_interceptors.h"
+namespace __sanitizer {
+struct __sanitizer_sigaction;
+}
+
namespace __asan {
void InitializeAsanInterceptors();
@@ -106,8 +110,9 @@
DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)
DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
struct sigaction;
-DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act,
- struct sigaction *oldact)
+DECLARE_REAL(int, sigaction, int signum,
+ const __sanitizer::__sanitizer_sigaction *act,
+ __sanitizer::__sanitizer_sigaction *oldact)
#if !SANITIZER_MAC
#define ASAN_INTERCEPT_FUNC(name) \
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_signal_interceptors.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_signal_interceptors.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_signal_interceptors.inc
@@ -18,34 +18,48 @@
using namespace __sanitizer;
+namespace __sanitizer {
+struct __sanitizer_sigaction;
+}
+
+#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) {
+INTERCEPTOR(void *, bsd_signal, int signum, uptr 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
#define INIT_BSD_SIGNAL
#endif // SANITIZER_INTERCEPT_BSD_SIGNAL
#if SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
-INTERCEPTOR(void *, signal, int signum, void *handler) {
+INTERCEPTOR(void *, signal, int signum, uptr 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) {
+INTERCEPTOR(int, sigaction, int signum, const __sanitizer_sigaction *act,
+ __sanitizer_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)
namespace __sanitizer {
int real_sigaction(int signum, const void *act, void *oldact) {
- return REAL(sigaction)(signum, (const struct sigaction *)act,
- (struct sigaction *)oldact);
+ return REAL(sigaction)(signum, (const __sanitizer_sigaction *)act,
+ (__sanitizer_sigaction *)oldact);
}
} // namespace __sanitizer
#else // SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39870.122336.patch
Type: text/x-patch
Size: 3575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/2dcfbee4/attachment.bin>
More information about the llvm-commits
mailing list