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

Justin Bogner mail at justinbogner.com
Fri Jun 19 17:14:44 PDT 2015


Chris Bieneman <beanz at apple.com> writes:
> This is one of many changes needed for compiler-rt to get it building on iOS.
>
> This change ifdefs out headers and functionality that aren't available
> on iOS, and adds support for iOS and the iOS simulator to as an.
>
> Note: this change does not enable building for iOS, as there are more
> changes to come.

LGTM with a couple of minor comments.

> http://reviews.llvm.org/D10515
>
> Files:
>   lib/asan/asan_mac.cc
>   lib/asan/asan_mapping.h
>
> Index: lib/asan/asan_mac.cc
> ===================================================================
> --- lib/asan/asan_mac.cc
> +++ lib/asan/asan_mac.cc
> @@ -24,7 +24,15 @@
>  #include "sanitizer_common/sanitizer_libc.h"
>  #include "sanitizer_common/sanitizer_mac.h"
>  
> -#include <crt_externs.h>  // for _NSGetArgv
> +#if !TARGET_OS_IPHONE
> +#include <crt_externs.h>  // for _NSGetArgv and _NSGetEnviron
> +#else
> +extern char **environ;
> +extern "C" {
> +  extern char ***_NSGetArgv(void);
> +}
> +#endif
> +
>  #include <dlfcn.h>  // for dladdr()
>  #include <mach-o/dyld.h>
>  #include <mach-o/loader.h>
> @@ -62,9 +70,11 @@
>  // otherwise the corresponding "NAME=value" string is replaced with
>  // |name_value|.
>  void LeakyResetEnv(const char *name, const char *name_value) {
> +#if !TARGET_OS_IPHONE
>    char ***env_ptr = _NSGetEnviron();
>    CHECK(env_ptr);
>    char **environ = *env_ptr;
> +#endif
>    CHECK(environ);
>    uptr name_len = internal_strlen(name);
>    while (*environ != 0) {
> Index: lib/asan/asan_mapping.h
> ===================================================================
> --- lib/asan/asan_mapping.h
> +++ lib/asan/asan_mapping.h
> @@ -100,6 +100,9 @@
>  static const u64 kDefaultShadowOffset32 = 1ULL << 29;  // 0x20000000
>  static const u64 kIosShadowOffset32 = 1ULL << 30;  // 0x40000000
>  static const u64 kDefaultShadowOffset64 = 1ULL << 44;
> +static const u64 kIosShadowOffset64 = 0x130000000;
> +static const u64 kIosSimShadowOffset32 = 1ULL << 30;
> +static const u64 kIosSimShadowOffset64 = kDefaultShadowOffset64;

I can't see much rhyme or reason in how these constants are ordered
today, but it seems odd to have "default" in between two "ios" values.
Maybe put all the Ios constants together?

>  static const u64 kDefaultShort64bitShadowOffset = 0x7FFF8000;  // < 2G.
>  static const u64 kAArch64_ShadowOffset64 = 1ULL << 36;
>  static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000;
> @@ -112,6 +115,20 @@
>  #define SHADOW_SCALE kDefaultShadowScale
>  #if SANITIZER_ANDROID
>  # define SHADOW_OFFSET (0)
> +#elif SANITIZER_IOS
> +# if SANITIZER_WORDSIZE == 32
> +#   if SANITIZER_IOSSIM
> +#     define SHADOW_OFFSET kIosSimShadowOffset32
> +#   else
> +#     define SHADOW_OFFSET kIosShadowOffset32
> +#   endif
> +# else
> +#   if SANITIZER_IOSSIM
> +#     define SHADOW_OFFSET kIosSimShadowOffset64
> +#   else
> +#     define SHADOW_OFFSET kIosShadowOffset64
> +#   endif
> +# endif

These should be wrapped into the #if chain below, rather than
duplicating the WORDSIZE == 32 checks.

>  #else
>  # if SANITIZER_WORDSIZE == 32
>  #  if defined(__mips__)
>



More information about the llvm-commits mailing list