[compiler-rt] r183105 - [asan] ASan Linux MIPS32 support (compiler-rt part), patch by Jyun-Yan Y

Kostya Serebryany kcc at google.com
Mon Jun 3 07:49:26 PDT 2013


Author: kcc
Date: Mon Jun  3 09:49:25 2013
New Revision: 183105

URL: http://llvm.org/viewvc/llvm-project?rev=183105&view=rev
Log:
[asan] ASan Linux MIPS32 support (compiler-rt part), patch by Jyun-Yan Y

Modified:
    compiler-rt/trunk/lib/asan/asan_linux.cc
    compiler-rt/trunk/lib/asan/asan_mapping.h
    compiler-rt/trunk/lib/asan/asan_thread.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=183105&r1=183104&r2=183105&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Mon Jun  3 09:49:25 2013
@@ -89,6 +89,11 @@ void GetPcSpBp(void *context, uptr *pc,
   stk_ptr = (uptr *) *sp;
   *bp = stk_ptr[15];
 # endif
+# elif defined(__mips__)
+  ucontext_t *ucontext = (ucontext_t*)context;
+  *pc = ucontext->uc_mcontext.gregs[31];
+  *bp = ucontext->uc_mcontext.gregs[30];
+  *sp = ucontext->uc_mcontext.gregs[29];
 #else
 # error "Unsupported arch"
 #endif

Modified: compiler-rt/trunk/lib/asan/asan_mapping.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mapping.h?rev=183105&r1=183104&r2=183105&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mapping.h (original)
+++ compiler-rt/trunk/lib/asan/asan_mapping.h Mon Jun  3 09:49:25 2013
@@ -49,6 +49,13 @@
 // || `[0x24000000, 0x27ffffff]` || ShadowGap  ||
 // || `[0x20000000, 0x23ffffff]` || LowShadow  ||
 // || `[0x00000000, 0x1fffffff]` || LowMem     ||
+//
+// Default Linux/MIPS mapping:
+// || `[0x2aaa8000, 0xffffffff]` || HighMem    ||
+// || `[0x0fffd000, 0x2aaa7fff]` || HighShadow ||
+// || `[0x0bffd000, 0x0fffcfff]` || ShadowGap  ||
+// || `[0x0aaa8000, 0x0bffcfff]` || LowShadow  ||
+// || `[0x00000000, 0x0aaa7fff]` || LowMem     ||
 
 #if ASAN_FLEXIBLE_MAPPING_AND_OFFSET == 1
 extern SANITIZER_INTERFACE_ATTRIBUTE uptr __asan_mapping_scale;
@@ -62,7 +69,11 @@ extern SANITIZER_INTERFACE_ATTRIBUTE upt
 # else
 #  define SHADOW_SCALE (3)
 #  if SANITIZER_WORDSIZE == 32
-#   define SHADOW_OFFSET (1 << 29)
+#   if defined(__mips__)
+#     define SHADOW_OFFSET 0x0aaa8000
+#   else
+#     define SHADOW_OFFSET (1 << 29)
+#   endif
 #  else
 #   if defined(__powerpc64__)
 #    define SHADOW_OFFSET (1ULL << 41)

Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=183105&r1=183104&r2=183105&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Mon Jun  3 09:49:25 2013
@@ -39,7 +39,8 @@ void AsanThreadContext::OnFinished() {
   thread = 0;
 }
 
-static char thread_registry_placeholder[sizeof(ThreadRegistry)];
+// MIPS requires aligned address
+static char thread_registry_placeholder[sizeof(ThreadRegistry)] ALIGNED(16);
 static ThreadRegistry *asan_thread_registry;
 
 static ThreadContextBase *GetAsanThreadContext(u32 tid) {

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=183105&r1=183104&r2=183105&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Mon Jun  3 09:49:25 2013
@@ -21,7 +21,8 @@ static const uptr kStackTraceMax = 256;
 
 #if SANITIZER_LINUX && (defined(__arm__) || \
     defined(__powerpc__) || defined(__powerpc64__) || \
-    defined(__sparc__))
+    defined(__sparc__) || \
+    defined(__mips__))
 #define SANITIZER_CAN_FAST_UNWIND 0
 #else
 #define SANITIZER_CAN_FAST_UNWIND 1

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=183105&r1=183104&r2=183105&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Mon Jun  3 09:49:25 2013
@@ -373,6 +373,10 @@ typedef user_regs_struct regs_struct;
 typedef pt_regs regs_struct;
 #define REG_SP gpr[PT_R1]
 
+#elif defined(__mips__)
+typedef struct user regs_struct;
+#define REG_SP regs[EF_REG29]
+
 #else
 #error "Unsupported architecture"
 #endif // SANITIZER_ANDROID && defined(__arm__)





More information about the llvm-commits mailing list