Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common More fi...



details:   https://anonhg.NetBSD.org/src/rev/4d0b975efc16
branches:  trunk
changeset: 816001:4d0b975efc16
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 11 13:39:26 2016 +0000

description:
More fixed from Rin Okuyama
fix waitpid, getdents, explain ptrace, cleanup redefinitions

diffstat:

 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc            |  25 ++++++++++
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc |   4 +-
 2 files changed, 26 insertions(+), 3 deletions(-)

diffs (76 lines):

diff -r 29b60eae00fd -r 4d0b975efc16 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc   Sat Jun 11 06:58:42 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc   Sat Jun 11 13:39:26 2016 +0000
@@ -56,6 +56,7 @@
 extern char **environ;  // provided by crt1
 #endif  // SANITIZER_FREEBSD
 #if SANITIZER_NETBSD
+#include <limits.h>    // For NAME_MAX
 #include <sys/sysctl.h>
 extern char **environ;  // provided by crt1
 #endif  // SANITIZER_NETBSD
@@ -494,6 +495,17 @@
 // The actual size of this structure is specified by d_reclen.
 // Note that getdents64 uses a different structure format. We only provide the
 // 32-bit syscall here.
+#if SANITIZER_NETBSD
+// struct dirent is different for Linux and us. At this moment, we use only
+// d_fileno (Linux call this d_ino), d_reclen, and d_name.
+struct linux_dirent {
+  u64  d_ino;     // d_fileno
+  u16  d_reclen;
+  u16  d_namlen;  // not used
+  u8   d_type;    // not used
+  char d_name[NAME_MAX + 1];
+};
+#else
 struct linux_dirent {
 #if SANITIZER_X32
   u64 d_ino;
@@ -505,10 +517,18 @@
   unsigned short     d_reclen;
   char               d_name[256];
 };
+#endif
 
 // Syscall wrappers.
 uptr internal_ptrace(int request, int pid, void *addr, void *data) {
 #if SANITIZER_NETBSD
+// XXX We need additional work for ptrace:
+//   - for request, we use PT_FOO whereas Linux uses PTRACE_FOO
+//   - data is int for us, but void * for Linux
+//   - Linux sometimes uses data in the case where we use addr instead
+// At this moment, this function is used only within
+// "#if SANITIZER_LINUX && defined(__x86_64__)" block in
+// sanitizer_stoptheworld_linux_libcdep.cc.
   return internal_syscall_ptr(SYSCALL(ptrace), request, pid, (uptr)addr,
                           (uptr)data);
 #else
@@ -518,8 +538,13 @@
 }
 
 uptr internal_waitpid(int pid, int *status, int options) {
++#if SANITIZER_NETBSD
+  return internal_syscall(SYSCALL(wait4), pid, status, options,
+                          NULL /* rusage */);
+#else
   return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options,
                           0 /* rusage */);
+#endif
 }
 
 uptr internal_getpid() {
diff -r 29b60eae00fd -r 4d0b975efc16 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc        Sat Jun 11 06:58:42 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc        Sat Jun 11 13:39:26 2016 +0000
@@ -38,9 +38,7 @@
 # else
 #  define internal_syscall_ptr syscall
 # endif
-#endif
-
-#if (SANITIZER_FREEBSD && defined(__x86_64__))
+#elif (SANITIZER_FREEBSD && defined(__x86_64__))
 # define internal_syscall __syscall
 # else
 # define internal_syscall syscall



Home | Main Index | Thread Index | Old Index