[PATCH] Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Chris Bieneman beanz at apple.com
Wed Jun 17 10:59:29 PDT 2015


This is one of many changes needed for compiler-rt to get it building on iOS.

This change does the following:
- Don't include crt_externs on iOS (it isn't available)
- Support ARM thread state objects

Note: this change does not enable building for iOS, as there are more changes to come.

http://reviews.llvm.org/D10510

Files:
  lib/sanitizer_common/sanitizer_mac.cc

Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -30,7 +30,12 @@
 #include "sanitizer_platform_limits_posix.h"
 #include "sanitizer_procmaps.h"
 
+#if !TARGET_OS_IPHONE
 #include <crt_externs.h>  // for _NSGetEnviron
+#else
+extern char **environ;
+#endif
+
 #include <errno.h>
 #include <fcntl.h>
 #include <libkern/OSAtomic.h>
@@ -191,13 +196,15 @@
 }
 
 const char *GetEnv(const char *name) {
+#if !TARGET_OS_IPHONE
   char ***env_ptr = _NSGetEnviron();
   if (!env_ptr) {
     Report("_NSGetEnviron() returned NULL. Please make sure __asan_init() is "
            "called after libSystem_initializer().\n");
     CHECK(env_ptr);
   }
   char **environ = *env_ptr;
+#endif
   CHECK(environ);
   uptr name_len = internal_strlen(name);
   while (*environ != 0) {
@@ -358,15 +365,30 @@
 
 void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
   ucontext_t *ucontext = (ucontext_t*)context;
-# if SANITIZER_WORDSIZE == 64
+# if defined(__aarch64__)
+  *pc = ucontext->uc_mcontext->__ss.__pc;
+  // See <rdar://19552184>.
+# if defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
+  *bp = ucontext->uc_mcontext->__ss.__fp;
+# else
+  *bp = ucontext->uc_mcontext->__ss.__lr;
+# endif
+  *sp = ucontext->uc_mcontext->__ss.__sp;
+# elif defined(__x86_64__)
   *pc = ucontext->uc_mcontext->__ss.__rip;
   *bp = ucontext->uc_mcontext->__ss.__rbp;
   *sp = ucontext->uc_mcontext->__ss.__rsp;
-# else
+# elif defined(__arm__)
+  *pc = ucontext->uc_mcontext->__ss.__pc;
+  *bp = ucontext->uc_mcontext->__ss.__r[7];
+  *sp = ucontext->uc_mcontext->__ss.__sp;
+# elif defined(__i386__)
   *pc = ucontext->uc_mcontext->__ss.__eip;
   *bp = ucontext->uc_mcontext->__ss.__ebp;
   *sp = ucontext->uc_mcontext->__ss.__esp;
-# endif  // SANITIZER_WORDSIZE
+# else
+# error "Unknown architecture"
+# endif
 }
 
 }  // namespace __sanitizer

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10510.27847.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150617/7c0c8d37/attachment.bin>


More information about the llvm-commits mailing list