[PATCH] D24768: [compiler-rt] Fix Asan build on Android

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 07:34:38 PDT 2016


etienneb marked 3 inline comments as done.

================
Comment at: lib/asan/asan_rtl.cc:466
@@ -465,11 +465,3 @@
   uptr shadow_start = kLowShadowBeg;
-  if (shadow_start == 0) {
-    uptr granularity = GetMmapGranularity();
-    uptr alignment = 8 * granularity;
-    uptr left_padding = granularity;
-    uptr space_size = kHighShadowEnd + left_padding;
-
-    shadow_start = FindAvailableMemoryRange(space_size, alignment, granularity);
-    CHECK_NE((uptr)0, shadow_start);
-    CHECK(IsAligned(shadow_start, alignment));
-  }
+#if ASAN_DYNAMIC_SHADOW_ADDRESS
+  CHECK_EQ(0, shadow_start);
----------------
kcc wrote:
> vitalybuka wrote:
> > rnk wrote:
> > > I think kcc likes regular if over #if, when possible. Also, isn't this macro undefined usually?
> > Maybe ~0 instead of 0?
> Correct, kcc has very strong opinion on #ifs. 
> 1. When you can avoid an #if -- avoid it. 
> 2. When you can't avoid it, check #1 once more
> 3. If desperate, split the files and put a top-level #if on the entire file. 
I do not like #if and worse "nested" #if :)
I'm do not have a strong opinion on the way to solve this.
I just want to fix Android bots that we (ok, I broke).

> Maybe ~0 instead of 0?

We can't use ~0 here because we rely on the way macro are expanded.

Initially, the variable is assigned to zero (this is needed):
```
__asan_shadow_memory_dynamic_address = 0;
```

Because the following statement is assigned from a macro:
```
 uptr shadow_start = kLowShadowBeg;
```

That macro is expanded from other macros, ...
```
#define kLowShadowBeg   SHADOW_OFFSET
```

And ends up to be "based" on `__asan_shadow_memory_dynamic_address ` which must be zero.


I'm gonna think a something not to ugly.


https://reviews.llvm.org/D24768





More information about the llvm-commits mailing list