File gcc6-libsanitizer-aarch64-vma48.patch of Package gcc6

Index: gcc-6.2.1-r239849/libsanitizer/sanitizer_common/sanitizer_platform.h
===================================================================
--- gcc-6.2.1-r239849.orig/libsanitizer/sanitizer_common/sanitizer_platform.h
+++ gcc-6.2.1-r239849/libsanitizer/sanitizer_common/sanitizer_platform.h
@@ -82,7 +82,7 @@
 // VMA size definition for architecture that support multiple sizes.
 // AArch64 has 3 VMA sizes: 39, 42 and 48.
 #if !defined(SANITIZER_AARCH64_VMA)
-# define SANITIZER_AARCH64_VMA 39
+# define SANITIZER_AARCH64_VMA 48
 #else
 # if SANITIZER_AARCH64_VMA != 39 && SANITIZER_AARCH64_VMA != 42
 #  error "invalid SANITIZER_AARCH64_VMA size"
@@ -107,6 +107,8 @@
 // will still work but will consume more memory for TwoLevelByteMap.
 #if defined(__mips__)
 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40)
+#elif defined(__aarch64__)
+# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48)
 #else
 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
 #endif
Index: gcc-6.2.1-r239849/libsanitizer/tsan/tsan_platform.h
===================================================================
--- gcc-6.2.1-r239849.orig/libsanitizer/tsan/tsan_platform.h
+++ gcc-6.2.1-r239849/libsanitizer/tsan/tsan_platform.h
@@ -142,6 +142,24 @@ const uptr kHiAppMemEnd   = 0x3fffff0000
 const uptr kAppMemMsk     = 0x3c000000000ull;
 const uptr kAppMemXor     = 0x04000000000ull;
 const uptr kVdsoBeg       = 0x37f00000000ull;
+# elif SANITIZER_AARCH64_VMA == 48
+const uptr kLoAppMemBeg   = 0x0000000001000ull;
+const uptr kLoAppMemEnd   = 0x0000200000000ull;
+const uptr kShadowBeg     = 0x0002000000000ull;
+const uptr kShadowEnd     = 0x0004000000000ull;
+const uptr kMetaShadowBeg = 0x0005000000000ull;
+const uptr kMetaShadowEnd = 0x0006000000000ull;
+const uptr kMidAppMemBeg  = 0x0aaaa00000000ull;
+const uptr kMidAppMemEnd  = 0x0aaaf00000000ull;
+const uptr kTraceMemBeg   = 0x0f06000000000ull;
+const uptr kTraceMemEnd   = 0x0f06200000000ull;
+const uptr kHeapMemBeg    = 0x0ffff00000000ull;
+const uptr kHeapMemEnd    = 0x0ffff00000000ull;
+const uptr kHiAppMemBeg   = 0x0ffff00000000ull;
+const uptr kHiAppMemEnd   = 0x1000000000000ull;
+const uptr kAppMemMsk     = 0x0fff800000000ull;
+const uptr kAppMemXor     = 0x0000800000000ull;
+const uptr kVdsoBeg       = 0xffff000000000ull;
 # endif
 #endif
 
Index: gcc-6.2.1-r239849/libsanitizer/tsan/tsan_rtl.cc
===================================================================
--- gcc-6.2.1-r239849.orig/libsanitizer/tsan/tsan_rtl.cc
+++ gcc-6.2.1-r239849/libsanitizer/tsan/tsan_rtl.cc
@@ -286,6 +286,10 @@ static void CheckShadowMapping() {
   for (uptr i = 0; i < ARRAY_SIZE(UserRegions); i += 2) {
     const uptr beg = UserRegions[i];
     const uptr end = UserRegions[i + 1];
+    // Skip cases for empty regions (heap definition for architectures that
+    // do not use 64-bit allocator).
+    if (beg ==end)
+      continue;
     VPrintf(3, "checking shadow region %p-%p\n", beg, end);
     for (uptr p0 = beg; p0 <= end; p0 += (end - beg) / 4) {
       for (int x = -1; x <= 1; x++) {
Index: gcc-6.2.1-r239849/libsanitizer/tsan/tsan_sync.h
===================================================================
--- gcc-6.2.1-r239849.orig/libsanitizer/tsan/tsan_sync.h
+++ gcc-6.2.1-r239849/libsanitizer/tsan/tsan_sync.h
@@ -48,16 +48,16 @@ struct SyncVar {
   void Reset(ThreadState *thr);
 
   u64 GetId() const {
-    // 47 lsb is addr, then 14 bits is low part of uid, then 3 zero bits.
-    return GetLsb((u64)addr | (uid << 47), 61);
+    // 48 lsb is addr, then 14 bits is low part of uid, then 2 zero bits.
+    return GetLsb((u64)addr | (uid << 48), 60);
   }
   bool CheckId(u64 uid) const {
     CHECK_EQ(uid, GetLsb(uid, 14));
     return GetLsb(this->uid, 14) == uid;
   }
   static uptr SplitId(u64 id, u64 *uid) {
-    *uid = id >> 47;
-    return (uptr)GetLsb(id, 47);
+    *uid = id >> 48;
+    return (uptr)GetLsb(id, 48);
   }
 };