Apply changes to migrate to compiler-rt upstream.

Change-Id: Icf463f4b5aa004794ace9acb34a22e434ae71b53
diff --git a/Android.mk b/Android.mk
index d06525c..4d6070d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -99,4 +99,6 @@
 
 include $(COMPILER_RT_PATH)/lib/Android.mk
 
+include $(COMPILER_RT_PATH)/lib/sanitizer_common/Android.mk
+
 include $(COMPILER_RT_PATH)/lib/asan/Android.mk
diff --git a/lib/asan/Android.mk b/lib/asan/Android.mk
index 3495f8d..ef473bf 100644
--- a/lib/asan/Android.mk
+++ b/lib/asan/Android.mk
@@ -38,8 +38,15 @@
 	asan_stack.cc	\
 	asan_stats.cc	\
 	asan_thread.cc	\
-	asan_thread_registry.cc	\
-	interception/interception_linux.cc
+	asan_thread_registry.cc \
+	../interception/interception_linux.cc \
+	../sanitizer_common/sanitizer_allocator.cc \
+	../sanitizer_common/sanitizer_common.cc \
+	../sanitizer_common/sanitizer_libc.cc \
+	../sanitizer_common/sanitizer_linux.cc \
+	../sanitizer_common/sanitizer_posix.cc \
+	../sanitizer_common/sanitizer_printf.cc \
+	../sanitizer_common/sanitizer_symbolizer.cc
 
 asan_rtl_cflags := \
 	-fvisibility=hidden \
@@ -76,7 +83,7 @@
 
 LOCAL_MODULE := libasan
 LOCAL_MODULE_TAGS := optional
-LOCAL_C_INCLUDES := bionic
+LOCAL_C_INCLUDES := bionic external/compiler-rt/lib
 LOCAL_CFLAGS += $(asan_rtl_cflags)
 LOCAL_SRC_FILES := asan_android_stub.cc
 LOCAL_CPP_EXTENSION := .cc
@@ -90,7 +97,8 @@
 LOCAL_MODULE_TAGS := eng
 LOCAL_C_INCLUDES := \
   bionic \
-  external/stlport/stlport
+  external/stlport/stlport \
+  external/compiler-rt/lib
 LOCAL_CFLAGS += $(asan_rtl_cflags)
 LOCAL_SRC_FILES := $(asan_rtl_files)
 LOCAL_CPP_EXTENSION := .cc
@@ -120,7 +128,8 @@
 LOCAL_C_INCLUDES := \
         bionic \
         external/stlport/stlport \
-        external/gtest/include
+        external/gtest/include \
+        external/compiler-rt/lib
 LOCAL_CFLAGS += \
         -Wno-unused-parameter \
         -Wno-sign-compare \
@@ -138,7 +147,8 @@
 LOCAL_C_INCLUDES := \
         bionic \
         external/stlport/stlport \
-        external/gtest/include
+        external/gtest/include \
+        external/compiler-rt/lib
 LOCAL_CFLAGS += $(asan_test_cflags)
 LOCAL_SRC_FILES := $(asan_test_files)
 LOCAL_CPP_EXTENSION := .cc
diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc
index b6134c6..0097cb3 100644
--- a/lib/sanitizer_common/sanitizer_allocator.cc
+++ b/lib/sanitizer_common/sanitizer_allocator.cc
@@ -15,7 +15,7 @@
 
 // FIXME: We should probably use more low-level allocator that would
 // mmap some pages and split them into chunks to fulfill requests.
-#ifdef __linux__
+#if defined(__linux__) && !defined(ANDROID)
 extern "C" void *__libc_malloc(__sanitizer::uptr size);
 extern "C" void __libc_free(void *ptr);
 # define LIBC_MALLOC __libc_malloc