[llvm-branch-commits] [compiler-rt-branch] r271372 - Merging r263621:

Mohit K. Bhakkad via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 1 01:20:17 PDT 2016


Author: mohit.bhakkad
Date: Wed Jun  1 03:17:03 2016
New Revision: 271372

URL: http://llvm.org/viewvc/llvm-project?rev=271372&view=rev
Log:
Merging r263621:
------------------------------------------------------------------------
r263621 | mohit.bhakkad | 2016-03-16 13:53:10 +0530 (Wed, 16 Mar 2016) | 9 lines

[ASAN] Add support for mips/mips64 android

Patch by Duane Sand

Reviewers: samsonov

Subscribers: duanesand, jaydeep, sagar, llvm-commits, filcab.

Differential Revision: http://reviews.llvm.org/D17883
------------------------------------------------------------------------

Modified:
    compiler-rt/branches/release_38/   (props changed)
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux.cc
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux_libcdep.cc
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.h
    compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

Propchange: compiler-rt/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun  1 03:17:03 2016
@@ -1 +1 @@
-/compiler-rt/trunk:258916,259755,260669,260839,260946,261073,261142,261148,261193,261263,261513,261721,261723,261837,261980,261982,262209,262302-262303,262690,263001,263218,267674,269882
+/compiler-rt/trunk:258916,259755,260669,260839,260946,261073,261142,261148,261193,261263,261513,261721,261723,261837,261980,261982,262209,262302-262303,262690,263001,263218,263621,267674,269882

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux.cc?rev=271372&r1=271371&r2=271372&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux.cc Wed Jun  1 03:17:03 2016
@@ -602,7 +602,9 @@ int internal_sigaction_norestorer(int si
     // rt_sigaction, so we need to do the same (we'll need to reimplement the
     // restorers; for x86_64 the restorer address can be obtained from
     // oldact->sa_restorer upon a call to sigaction(xxx, NULL, oldact).
+#if !SANITIZER_ANDROID || !SANITIZER_MIPS32
     k_act.sa_restorer = u_act->sa_restorer;
+#endif
   }
 
   uptr result = internal_syscall(SYSCALL(rt_sigaction), (uptr)signum,
@@ -616,7 +618,9 @@ int internal_sigaction_norestorer(int si
     internal_memcpy(&u_oldact->sa_mask, &k_oldact.sa_mask,
                     sizeof(__sanitizer_kernel_sigset_t));
     u_oldact->sa_flags = k_oldact.sa_flags;
+#if !SANITIZER_ANDROID || !SANITIZER_MIPS32
     u_oldact->sa_restorer = k_oldact.sa_restorer;
+#endif
   }
   return result;
 }

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=271372&r1=271371&r2=271372&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_linux_libcdep.cc Wed Jun  1 03:17:03 2016
@@ -158,7 +158,6 @@ bool SanitizerGetThreadName(char *name,
 
 #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
 static uptr g_tls_size;
-#endif
 
 #ifdef __i386__
 # define DL_INTERNAL_FUNCTION __attribute__((regparm(3), stdcall))
@@ -166,26 +165,7 @@ static uptr g_tls_size;
 # define DL_INTERNAL_FUNCTION
 #endif
 
-#if defined(__mips__) || defined(__powerpc64__)
-// TlsPreTcbSize includes size of struct pthread_descr and size of tcb
-// head structure. It lies before the static tls blocks.
-static uptr TlsPreTcbSize() {
-# if defined(__mips__)
-  const uptr kTcbHead = 16; // sizeof (tcbhead_t)
-# elif defined(__powerpc64__)
-  const uptr kTcbHead = 88; // sizeof (tcbhead_t)
-# endif
-  const uptr kTlsAlign = 16;
-  const uptr kTlsPreTcbSize =
-    (ThreadDescriptorSize() + kTcbHead + kTlsAlign - 1) & ~(kTlsAlign - 1);
-  InitTlsSize();
-  g_tls_size = (g_tls_size + kTlsPreTcbSize + kTlsAlign -1) & ~(kTlsAlign - 1);
-  return kTlsPreTcbSize;
-}
-#endif
-
 void InitTlsSize() {
-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
 // all current supported platforms have 16 bytes stack alignment
   const size_t kStackAlign = 16;
   typedef void (*get_tls_func)(size_t*, size_t*) DL_INTERNAL_FUNCTION;
@@ -201,8 +181,10 @@ void InitTlsSize() {
   if (tls_align < kStackAlign)
     tls_align = kStackAlign;
   g_tls_size = RoundUpTo(tls_size, tls_align);
-#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
 }
+#else
+void InitTlsSize() { }
+#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
 
 #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
     || defined(__aarch64__) || defined(__powerpc64__)) \
@@ -278,6 +260,24 @@ uptr ThreadSelfOffset() {
   return kThreadSelfOffset;
 }
 
+#if defined(__mips__) || defined(__powerpc64__)
+// TlsPreTcbSize includes size of struct pthread_descr and size of tcb
+// head structure. It lies before the static tls blocks.
+static uptr TlsPreTcbSize() {
+# if defined(__mips__)
+  const uptr kTcbHead = 16; // sizeof (tcbhead_t)
+# elif defined(__powerpc64__)
+  const uptr kTcbHead = 88; // sizeof (tcbhead_t)
+# endif
+  const uptr kTlsAlign = 16;
+  const uptr kTlsPreTcbSize =
+    (ThreadDescriptorSize() + kTcbHead + kTlsAlign - 1) & ~(kTlsAlign - 1);
+  InitTlsSize();
+  g_tls_size = (g_tls_size + kTlsPreTcbSize + kTlsAlign -1) & ~(kTlsAlign - 1);
+  return kTlsPreTcbSize;
+}
+#endif
+
 uptr ThreadSelf() {
   uptr descr_addr;
 # if defined(__i386__)

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=271372&r1=271371&r2=271372&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Wed Jun  1 03:17:03 2016
@@ -1056,7 +1056,7 @@ COMPILER_CHECK(sizeof(__sanitizer_sigact
 // preprocessor macros.
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && (!SANITIZER_ANDROID || !SANITIZER_MIPS32)
 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
 #endif
 

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=271372&r1=271371&r2=271372&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_platform_limits_posix.h Wed Jun  1 03:17:03 2016
@@ -77,11 +77,9 @@ namespace __sanitizer {
   const unsigned struct_kernel_stat_sz = 144;
   const unsigned struct_kernel_stat64_sz = 104;
 #elif defined(__mips__)
-  #if SANITIZER_WORDSIZE == 64
-  const unsigned struct_kernel_stat_sz = 216;
-  #else
-  const unsigned struct_kernel_stat_sz = 144;
-  #endif
+  const unsigned struct_kernel_stat_sz =
+                 SANITIZER_ANDROID ? FIRST_32_SECOND_64(104, 128) :
+                                     FIRST_32_SECOND_64(144, 216);
   const unsigned struct_kernel_stat64_sz = 104;
 #endif
   struct __sanitizer_perf_event_attr {
@@ -516,7 +514,11 @@ namespace __sanitizer {
   };
 
 #if SANITIZER_ANDROID
+# if SANITIZER_MIPS
+  typedef unsigned long __sanitizer_sigset_t[16/sizeof(unsigned long)];
+# else
   typedef unsigned long __sanitizer_sigset_t;
+# endif
 #elif SANITIZER_MAC
   typedef unsigned __sanitizer_sigset_t;
 #elif SANITIZER_LINUX
@@ -542,6 +544,15 @@ namespace __sanitizer {
     __sanitizer_sigset_t sa_mask;
     void (*sa_restorer)();
   };
+#elif SANITIZER_ANDROID && SANITIZER_MIPS32  // check this before WORDSIZE == 32
+  struct __sanitizer_sigaction {
+    unsigned sa_flags;
+    union {
+      void (*sigaction)(int sig, void *siginfo, void *uctx);
+      void (*handler)(int sig);
+    };
+    __sanitizer_sigset_t sa_mask;
+  };
 #elif SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)
   struct __sanitizer_sigaction {
     union {

Modified: compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=271372&r1=271371&r2=271372&view=diff
==============================================================================
--- compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)
+++ compiler-rt/branches/release_38/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Wed Jun  1 03:17:03 2016
@@ -38,6 +38,9 @@
 #  include <asm/ptrace.h>
 # endif
 # include <sys/user.h>  // for user_regs_struct
+# if SANITIZER_ANDROID && SANITIZER_MIPS
+#   include <asm/reg.h>  // for mips SP register in sys/user.h
+# endif
 #endif
 #include <sys/wait.h> // for signal-related stuff
 
@@ -467,7 +470,11 @@ typedef pt_regs regs_struct;
 
 #elif defined(__mips__)
 typedef struct user regs_struct;
-#define REG_SP regs[EF_REG29]
+# if SANITIZER_ANDROID
+#  define REG_SP regs[EF_R29]
+# else
+#  define REG_SP regs[EF_REG29]
+# endif
 
 #elif defined(__aarch64__)
 typedef struct user_pt_regs regs_struct;




More information about the llvm-branch-commits mailing list