[PATCH] D44713: Unsubmitted part of D44599
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 21 13:54:46 PDT 2018
devnexen updated this revision to Diff 139366.
devnexen added a comment.
Adding sigcontext support
https://reviews.llvm.org/D44713
Files:
lib/sanitizer_common/sanitizer_linux.cc
Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -69,6 +69,7 @@
#endif
#if SANITIZER_OPENBSD
#include <sys/futex.h>
+#include <signal.h>
#endif
#include <unistd.h>
@@ -308,8 +309,8 @@
return internal_syscall_ptr(SYSCALL(fstatat), AT_FDCWD, (uptr)path, (uptr)buf,
0);
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
- return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
- 0);
+ return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
+ (uptr)buf, 0);
#elif SANITIZER_LINUX_USES_64BIT_SYSCALLS
# if defined(__mips64)
// For mips64, stat syscall fills buffer in the format of kernel_stat
@@ -391,9 +392,12 @@
}
uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
-#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD
- return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf,
- bufsize);
+#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+ return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path,
+ (uptr)buf, bufsize);
+#elif SANITIZER_OPENBSD
+ return internal_syscall_ptr(SYSCALL(readlinkat), AT_FDCWD, (uptr)path,
+ (uptr)buf, bufsize);
#else
return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
#endif
@@ -409,8 +413,8 @@
uptr internal_rename(const char *oldpath, const char *newpath) {
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD
- return internal_syscall(SYSCALL(renameat), AT_FDCWD, (uptr)oldpath, AT_FDCWD,
- (uptr)newpath);
+ return internal_syscall_ptr(SYSCALL(renameat), AT_FDCWD, (uptr)oldpath,
+ AT_FDCWD, (uptr)newpath);
#else
return internal_syscall_ptr(SYSCALL(rename), (uptr)oldpath, (uptr)newpath);
#endif
@@ -1705,12 +1709,16 @@
SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
#if !SANITIZER_OPENBSD
ucontext_t *ucontext = (ucontext_t *)context;
+#else
+ sigcontext *ucontext = (sigcontext *)context;
#if defined(__x86_64__) || defined(__i386__)
static const uptr PF_WRITE = 1U << 1;
#if SANITIZER_FREEBSD
uptr err = ucontext->uc_mcontext.mc_err;
#elif SANITIZER_NETBSD
uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
+#elif SANITIZER_OPENBSD
+ uptr err = ucontext->sc_err;
#elif SANITIZER_SOLARIS && defined(__i386__)
# define ERR 13
uptr err = ucontext->uc_mcontext.gregs[ERR];
@@ -1737,8 +1745,6 @@
(void)ucontext;
return UNKNOWN; // FIXME: Implement.
#endif
-#else // !SANITIZER_OPENBSD
- return UNKNOWN;
#endif // !SANITIZER_OPENBSD
}
@@ -1775,6 +1781,11 @@
*pc = ucontext->uc_mcontext.mc_rip;
*bp = ucontext->uc_mcontext.mc_rbp;
*sp = ucontext->uc_mcontext.mc_rsp;
+#elif SANITIZER_OPENBSD
+ sigcontext *ucontext = (sigcontext *)context;
+ *pc = ucontext->sc_rip;
+ *bp = ucontext->sc_rbp;
+ *sp = ucontext->sc_rsp;
# else
ucontext_t *ucontext = (ucontext_t*)context;
*pc = ucontext->uc_mcontext.gregs[REG_RIP];
@@ -1787,6 +1798,11 @@
*pc = ucontext->uc_mcontext.mc_eip;
*bp = ucontext->uc_mcontext.mc_ebp;
*sp = ucontext->uc_mcontext.mc_esp;
+#elif SANITIZER_OPENBSD
+ sigcontext *ucontext = (sigcontext *)context;
+ *pc = ucontext->sc_eip;
+ *bp = ucontext->sc_ebp;
+ *sp = ucontext->sc_esp;
# else
ucontext_t *ucontext = (ucontext_t*)context;
# if SANITIZER_SOLARIS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44713.139366.patch
Type: text/x-patch
Size: 3632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180321/a8bdda18/attachment.bin>
More information about the llvm-commits
mailing list