[PATCH] D44713: Unsubmitted part of D44599

David CARLIER via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 15:46:23 PDT 2018


devnexen created this revision.
devnexen added reviewers: krytarowski, vitalybuka.
Herald added subscribers: Sanitizers, llvm-commits, kubamracek.

- Conversion for Linux from internal_syscall to internal_syscall_ptr
- contest is not supported under OpenBSD
- Adding global environ


Repository:
  rCRT Compiler Runtime

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>
+extern char **environ;
 #endif
 #include <unistd.h>
 
@@ -310,21 +311,21 @@
   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_ptr(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
   struct kernel_stat kbuf;
-  int res = internal_syscall(SYSCALL(stat), path, &kbuf);
+  int res = internal_syscall_ptr(SYSCALL(stat), path, &kbuf);
   kernel_stat_to_stat(&kbuf, (struct stat *)buf);
   return res;
 # else
-  return internal_syscall(SYSCALL(stat), (uptr)path, (uptr)buf);
+  return internal_syscall_ptr(SYSCALL(stat), (uptr)path, (uptr)buf);
 # endif
 #else
   struct stat64 buf64;
-  int res = internal_syscall(SYSCALL(stat64), path, &buf64);
+  int res = internal_syscall_ptr(SYSCALL(stat64), path, &buf64);
   stat64_to_stat(&buf64, (struct stat *)buf);
   return res;
 #endif
@@ -394,25 +395,25 @@
 
 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);
+  return internal_syscall_ptr(SYSCALL(readlinkat), AT_FDCWD, (uptr)path,
+                              (uptr)buf, bufsize);
 #else
   return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
 #endif
 }
 
 uptr internal_unlink(const char *path) {
 #if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD
-  return internal_syscall(SYSCALL(unlinkat), AT_FDCWD, (uptr)path, 0);
+  return internal_syscall_ptr(SYSCALL(unlinkat), AT_FDCWD, (uptr)path, 0);
 #else
   return internal_syscall_ptr(SYSCALL(unlink), (uptr)path);
 #endif
 }
 
 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
@@ -1749,7 +1750,11 @@
 }
 
 static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
-#if SANITIZER_NETBSD
+#if SANITIZER_OPENBSD
+  *pc = 0;
+  *bp = 0;
+  *sp = 0;
+#elif SANITIZER_NETBSD
   // This covers all NetBSD architectures
   ucontext_t *ucontext = (ucontext_t *)context;
   *pc = _UC_MACHINE_PC(ucontext);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44713.139216.patch
Type: text/x-patch
Size: 3130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180320/5b495736/attachment.bin>


More information about the llvm-commits mailing list