Add support for building on Android.

Change-Id: Iac8ac88f6a8af927530c9e16e588ead7c3bd63ee
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..fa39108
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,626 @@
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+ifeq ($(TARGET_ARCH),arm)
+	arch := arm
+else ifeq ($(TARGET_ARCH),x86)
+	arch := x86
+endif
+ifdef arch
+
+common_cflags := \
+	-Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wmissing-declarations \
+	-Wno-pointer-sign -Wno-sign-compare -Wno-unused-parameter -Wno-shadow \
+	-fno-strict-aliasing -fno-stack-protector \
+	-DVGA_$(arch)=1 \
+	-DVGO_linux=1 \
+	-DVGP_$(arch)_linux=1 \
+	-DVG_PLATFORM=\"$(arch)-linux\" \
+	-DVG_LIBDIR=\"/system/lib/valgrind\"
+
+common_includes := \
+	external/valgrind \
+	external/valgrind/include \
+	external/valgrind/VEX/pub \
+	external/valgrind/coregrind
+
+vex_ldflags := -nodefaultlibs
+
+tool_ldflags := -static -Wl,--build-id=none,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -u _start -e_start
+
+preload_ldflags := -nodefaultlibs -Wl,-z,interpose,-z,initfirst
+
+# Build libvex-($arch)-linux.a
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libvex-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES := \
+	VEX/priv/main_globals.c \
+	VEX/priv/main_main.c \
+	VEX/priv/main_util.c \
+	VEX/priv/ir_defs.c \
+	VEX/priv/ir_match.c \
+	VEX/priv/ir_opt.c \
+	VEX/priv/guest_generic_bb_to_IR.c \
+	VEX/priv/guest_generic_x87.c \
+	VEX/priv/guest_x86_helpers.c \
+	VEX/priv/guest_x86_toIR.c \
+	VEX/priv/guest_amd64_helpers.c \
+	VEX/priv/guest_amd64_toIR.c \
+	VEX/priv/guest_ppc_helpers.c \
+	VEX/priv/guest_ppc_toIR.c \
+	VEX/priv/guest_arm_helpers.c \
+	VEX/priv/guest_arm_toIR.c \
+	VEX/priv/host_generic_regs.c \
+	VEX/priv/host_generic_simd64.c \
+	VEX/priv/host_generic_simd128.c \
+	VEX/priv/host_generic_reg_alloc2.c \
+	VEX/priv/host_x86_defs.c \
+	VEX/priv/host_x86_isel.c \
+	VEX/priv/host_amd64_defs.c \
+	VEX/priv/host_amd64_isel.c \
+	VEX/priv/host_ppc_defs.c \
+	VEX/priv/host_ppc_isel.c \
+	VEX/priv/host_arm_defs.c \
+	VEX/priv/host_arm_isel.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_CFLAGS := $(common_cflags) \
+	-Wbad-function-cast \
+	-Wcast-qual \
+	-Wcast-align \
+	-fstrict-aliasing
+
+include $(BUILD_STATIC_LIBRARY)
+
+# Build libcoregrind-$(arch)-linux.a
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libcoregrind-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES := \
+	coregrind/m_commandline.c \
+	coregrind/m_clientstate.c \
+	coregrind/m_cpuid.S \
+	coregrind/m_debugger.c \
+	coregrind/m_debuglog.c \
+	coregrind/m_errormgr.c \
+	coregrind/m_execontext.c \
+	coregrind/m_hashtable.c \
+	coregrind/m_libcbase.c \
+	coregrind/m_libcassert.c \
+	coregrind/m_libcfile.c \
+	coregrind/m_libcprint.c \
+	coregrind/m_libcproc.c \
+	coregrind/m_libcsignal.c \
+	coregrind/m_machine.c \
+	coregrind/m_main.c \
+	coregrind/m_mallocfree.c \
+	coregrind/m_options.c \
+	coregrind/m_oset.c \
+	coregrind/m_redir.c \
+	coregrind/m_seqmatch.c \
+	coregrind/m_signals.c \
+	coregrind/m_sparsewa.c \
+	coregrind/m_stacks.c \
+	coregrind/m_stacktrace.c \
+	coregrind/m_syscall.c \
+	coregrind/m_threadstate.c \
+	coregrind/m_tooliface.c \
+	coregrind/m_trampoline.S \
+	coregrind/m_translate.c \
+	coregrind/m_transtab.c \
+	coregrind/m_vki.c \
+	coregrind/m_vkiscnums.c \
+	coregrind/m_wordfm.c \
+	coregrind/m_xarray.c \
+	coregrind/m_aspacehl.c \
+	coregrind/m_aspacemgr/aspacemgr-common.c \
+	coregrind/m_aspacemgr/aspacemgr-linux.c \
+	coregrind/m_aspacemgr/aspacemgr-aix5.c \
+	coregrind/m_coredump/coredump-elf.c \
+	coregrind/m_coredump/coredump-macho.c \
+	coregrind/m_coredump/coredump-xcoff.c \
+	coregrind/m_debuginfo/misc.c \
+	coregrind/m_debuginfo/d3basics.c \
+	coregrind/m_debuginfo/debuginfo.c \
+	coregrind/m_debuginfo/readdwarf.c \
+	coregrind/m_debuginfo/readdwarf3.c \
+	coregrind/m_debuginfo/readelf.c \
+	coregrind/m_debuginfo/readmacho.c \
+	coregrind/m_debuginfo/readpdb.c \
+	coregrind/m_debuginfo/readstabs.c \
+	coregrind/m_debuginfo/readxcoff.c \
+	coregrind/m_debuginfo/storage.c \
+	coregrind/m_debuginfo/tytypes.c \
+	coregrind/m_demangle/cp-demangle.c \
+	coregrind/m_demangle/cplus-dem.c \
+	coregrind/m_demangle/demangle.c \
+	coregrind/m_demangle/dyn-string.c \
+	coregrind/m_demangle/safe-ctype.c \
+	coregrind/m_dispatch/dispatch-x86-linux.S \
+	coregrind/m_dispatch/dispatch-amd64-linux.S \
+	coregrind/m_dispatch/dispatch-ppc32-linux.S \
+	coregrind/m_dispatch/dispatch-ppc64-linux.S \
+	coregrind/m_dispatch/dispatch-arm-linux.S \
+	coregrind/m_dispatch/dispatch-ppc32-aix5.S \
+	coregrind/m_dispatch/dispatch-ppc64-aix5.S \
+	coregrind/m_dispatch/dispatch-x86-darwin.S \
+	coregrind/m_dispatch/dispatch-amd64-darwin.S \
+	coregrind/m_initimg/initimg-linux.c \
+	coregrind/m_initimg/initimg-aix5.c \
+	coregrind/m_initimg/initimg-darwin.c \
+	coregrind/m_initimg/initimg-pathscan.c \
+	coregrind/m_mach/mach_basics.c \
+	coregrind/m_mach/mach_msg.c \
+	coregrind/m_mach/mach_traps-x86-darwin.S \
+	coregrind/m_mach/mach_traps-amd64-darwin.S \
+	coregrind/m_replacemalloc/replacemalloc_core.c \
+	coregrind/m_scheduler/scheduler.c \
+	coregrind/m_scheduler/sema.c \
+	coregrind/m_sigframe/sigframe-x86-linux.c \
+	coregrind/m_sigframe/sigframe-amd64-linux.c \
+	coregrind/m_sigframe/sigframe-ppc32-linux.c \
+	coregrind/m_sigframe/sigframe-ppc64-linux.c \
+	coregrind/m_sigframe/sigframe-arm-linux.c \
+	coregrind/m_sigframe/sigframe-ppc32-aix5.c \
+	coregrind/m_sigframe/sigframe-ppc64-aix5.c \
+	coregrind/m_sigframe/sigframe-x86-darwin.c \
+	coregrind/m_sigframe/sigframe-amd64-darwin.c \
+	coregrind/m_syswrap/syscall-x86-linux.S \
+	coregrind/m_syswrap/syscall-amd64-linux.S \
+	coregrind/m_syswrap/syscall-ppc32-linux.S \
+	coregrind/m_syswrap/syscall-ppc64-linux.S \
+	coregrind/m_syswrap/syscall-arm-linux.S \
+	coregrind/m_syswrap/syscall-ppc32-aix5.S \
+	coregrind/m_syswrap/syscall-ppc64-aix5.S \
+	coregrind/m_syswrap/syscall-x86-darwin.S \
+	coregrind/m_syswrap/syscall-amd64-darwin.S \
+	coregrind/m_syswrap/syswrap-main.c \
+	coregrind/m_syswrap/syswrap-generic.c \
+	coregrind/m_syswrap/syswrap-linux.c \
+	coregrind/m_syswrap/syswrap-linux-variants.c \
+	coregrind/m_syswrap/syswrap-aix5.c \
+	coregrind/m_syswrap/syswrap-darwin.c \
+	coregrind/m_syswrap/syswrap-x86-linux.c \
+	coregrind/m_syswrap/syswrap-amd64-linux.c \
+	coregrind/m_syswrap/syswrap-ppc32-linux.c \
+	coregrind/m_syswrap/syswrap-ppc64-linux.c \
+	coregrind/m_syswrap/syswrap-arm-linux.c \
+	coregrind/m_syswrap/syswrap-ppc32-aix5.c \
+	coregrind/m_syswrap/syswrap-ppc64-aix5.c \
+	coregrind/m_syswrap/syswrap-x86-darwin.c \
+	coregrind/m_syswrap/syswrap-amd64-darwin.c \
+	coregrind/m_ume/elf.c \
+	coregrind/m_ume/macho.c \
+	coregrind/m_ume/main.c \
+	coregrind/m_ume/script.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(vex_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+include $(BUILD_STATIC_LIBRARY)
+
+# Build libreplacemalloc_toolpreload-$(arch)-linux.a
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libreplacemalloc_toolpreload-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES := \
+	coregrind/m_replacemalloc/vg_replace_malloc.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+include $(BUILD_STATIC_LIBRARY)
+
+# Build vgpreload_core-$(arch)-linux.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vgpreload_core-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_NO_CRT := true
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_SRC_FILES := \
+	coregrind/vg_preloaded.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Build memcheck-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := memcheck-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	memcheck/mc_leakcheck.c \
+	memcheck/mc_malloc_wrappers.c \
+	memcheck/mc_main.c \
+	memcheck/mc_translate.c \
+	memcheck/mc_machine.c \
+	memcheck/mc_errors.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build vgpreload_memcheck-$(arch)-linux.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vgpreload_memcheck-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_NO_CRT := true
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_SRC_FILES := \
+	memcheck/mc_replace_strmem.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libreplacemalloc_toolpreload-$(arch)-linux
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Build cachegrind-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := cachegrind-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	cachegrind/cg_main.c \
+	cachegrind/cg-x86-amd64.c \
+	cachegrind/cg-ppc32.c \
+	cachegrind/cg-ppc64.c \
+	cachegrind/cg-arm.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build callgrind-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := callgrind-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	callgrind/bb.c \
+	callgrind/bbcc.c \
+	callgrind/callstack.c \
+	callgrind/clo.c \
+	callgrind/command.c \
+	callgrind/context.c \
+	callgrind/costs.c \
+	callgrind/debug.c \
+	callgrind/dump.c \
+	callgrind/events.c \
+	callgrind/fn.c \
+	callgrind/jumps.c \
+	callgrind/main.c \
+	callgrind/sim.c \
+	callgrind/threads.c \
+	cachegrind/cg-x86-amd64.c \
+	cachegrind/cg-ppc32.c \
+	cachegrind/cg-ppc64.c \
+	cachegrind/cg-arm.c
+
+LOCAL_C_INCLUDES := $(common_includes) \
+	external/valgrind/cachegrind
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build helgrind-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := helgrind-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	helgrind/hg_basics.c \
+	helgrind/hg_errors.c \
+	helgrind/hg_lock_n_thread.c \
+	helgrind/hg_main.c \
+	helgrind/hg_wordset.c \
+	helgrind/libhb_core.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build vgpreload_helgrind-$(arch)-linux.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vgpreload_helgrind-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_NO_CRT := true
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_SRC_FILES := \
+	helgrind/hg_intercepts.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libreplacemalloc_toolpreload-$(arch)-linux
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Build drd-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := drd-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	drd/drd_barrier.c \
+	drd/drd_bitmap2_node.c \
+	drd/drd_clientobj.c \
+	drd/drd_clientreq.c \
+	drd/drd_cond.c \
+	drd/drd_cond_initializer.c \
+	drd/drd_error.c \
+	drd/drd_hb.c \
+	drd/drd_load_store.c \
+	drd/drd_main.c \
+	drd/drd_malloc_wrappers.c \
+	drd/drd_mutex.c \
+	drd/drd_rwlock.c \
+	drd/drd_semaphore.c \
+	drd/drd_suppression.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build vgpreload_drd-$(arch)-linux.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vgpreload_drd-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_NO_CRT := true
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_SRC_FILES := \
+	drd/drd_pthread_intercepts.c \
+	drd/drd_qtcore_intercepts.c \
+	drd/drd_strmem_intercepts.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libreplacemalloc_toolpreload-$(arch)-linux
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Build massif-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := massif-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	massif/ms_main.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build vgpreload_massif-$(arch)-linux.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := vgpreload_massif-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_NO_CRT := true
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_SRC_FILES :=
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(preload_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libreplacemalloc_toolpreload-$(arch)-linux
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Build none-$(arch)-linux
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := none-$(arch)-linux
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_STRIP_MODULE := false
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_NO_CRT := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+
+LOCAL_SRC_FILES := \
+	none/nl_main.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_LDFLAGS := $(tool_ldflags)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux
+
+include $(BUILD_EXECUTABLE)
+
+# Build valgrind
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := valgrind
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES := \
+	coregrind/launcher-linux.c \
+	coregrind/m_debuglog.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+
+LOCAL_CFLAGS := $(common_cflags)
+
+include $(BUILD_EXECUTABLE)
+
+# Copy prebuilt suppressions
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := default.supp
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_SRC_FILES := bionic.supp
+
+include $(BUILD_PREBUILT)
+
+endif
+
diff --git a/MODULE_LICENSE_GPL b/MODULE_LICENSE_GPL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_GPL
diff --git a/VEX/priv/guest_arm_toIR.c b/VEX/priv/guest_arm_toIR.c
index c1f9211..398e36b 100644
--- a/VEX/priv/guest_arm_toIR.c
+++ b/VEX/priv/guest_arm_toIR.c
@@ -11942,11 +11942,25 @@
          stmt( IRStmt_MBE(Imbe_Fence) );
          DIP("ISB\n");
          return True;
-      case 0xF57FF04F: /* DSB */
+      case 0xF57FF04F: /* DSB sy */
+      case 0xF57FF04E: /* DSB st */
+      case 0xF57FF04B: /* DSB ish */
+      case 0xF57FF04A: /* DSB ishst */
+      case 0xF57FF047: /* DSB nsh */
+      case 0xF57FF046: /* DSB nshst */
+      case 0xF57FF043: /* DSB osh */
+      case 0xF57FF042: /* DSB oshst */
          stmt( IRStmt_MBE(Imbe_Fence) );
          DIP("DSB\n");
          return True;
-      case 0xF57FF05F: /* DMB */
+      case 0xF57FF05F: /* DMB sy */
+      case 0xF57FF05E: /* DMB st */
+      case 0xF57FF05B: /* DMB ish */
+      case 0xF57FF05A: /* DMB ishst */
+      case 0xF57FF057: /* DMB nsh */
+      case 0xF57FF056: /* DMB nshst */
+      case 0xF57FF053: /* DMB osh */
+      case 0xF57FF052: /* DMB oshst */
          stmt( IRStmt_MBE(Imbe_Fence) );
          DIP("DMB\n");
          return True;
@@ -17722,6 +17736,24 @@
       }
    }
 
+   /* -------------- read CP15 TPIDRURO register ------------- */
+   /* mrc     p15, 0, r0, c13, c0, 3  up to
+      mrc     p15, 0, r14, c13, c0, 3
+   */
+   /* I don't know whether this is really v7-only.  But anyway, we
+      have to support it since arm-linux uses TPIDRURO as a thread
+      state register. */
+   if (INSN0(15,0) == 0xEE1D && INSN1(11,0) == 0xF70) {
+      UInt rD = INSN1(15,12);
+      if (rD <= 14) {
+         /* skip r15, that's too stupid to handle */
+         putIRegT(rD, IRExpr_Get(OFFB_TPIDRURO, Ity_I32),
+                      condT);
+         DIP("mrc p15,0, r%u, c13, c0, 3\n", rD);
+         goto decode_success;
+      }
+   }
+
    /* -------------- v7 barrier insns -------------- */
    if (INSN0(15,0) == 0xF3BF && (INSN1(15,0) & 0xFF0F) == 0x8F0F) {
       /* XXX this isn't really right, is it?  The generated IR does
diff --git a/bionic.supp b/bionic.supp
new file mode 100644
index 0000000..13d4476
--- /dev/null
+++ b/bionic.supp
@@ -0,0 +1,9 @@
+#
+# Suppressions for Bionic libc on Android.
+#
+
+##----------------------------------------------------------------------##
+# Memcheck
+##----------------------------------------------------------------------##
+
+# TODO: Nothing here yet.
diff --git a/clean-targets.sh b/clean-targets.sh
new file mode 100755
index 0000000..aa88891
--- /dev/null
+++ b/clean-targets.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Handy script to delete all Valgrind related targets from the build output
+# directory.  Useful when working on the Android makefiles.
+#
+obj=$ANDROID_BUILD_TOP/out/target/product/stingray/obj
+
+rm -r $obj/STATIC_LIBRARIES/libvex-arm-linux_intermediates \
+	$obj/STATIC_LIBRARIES/libcoregrind-arm-linux_intermediates \
+	$obj/STATIC_LIBRARIES/libreplacemalloc_toolpreload-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/vgpreload_core-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/memcheck-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/vgpreload_memcheck-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/cachegrind-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/callgrind-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/helgrind-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/vgpreload_helgrind-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/drd-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/vgpreload_drd-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/massif-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/vgpreload_massif-arm-linux_intermediates \
+	$obj/SHARED_LIBRARIES/none-arm-linux_intermediates \
+	$obj/EXECUTABLES/valgrind_intermediates
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..133763b
--- /dev/null
+++ b/config.h
@@ -0,0 +1,327 @@
+/* config.h.in.  Generated from configure.in by autoheader.  */
+
+/* Define to 1 if you're using AIX 5.1 or 5.2 or 5.3 */
+/* #undef AIX5_LIBC */
+
+/* DARWIN_VERS value for Mac OS X 10.5 */
+/* #undef DARWIN_10_5 */
+
+/* DARWIN_VERS value for Mac OS X 10.6 */
+/* #undef DARWIN_10_6 */
+
+/* DARWIN_VERS value for Mac OS X 10.7 */
+/* #undef DARWIN_10_7 */
+
+/* Define to 1 if you're using Darwin */
+/* #undef DARWIN_LIBC */
+
+/* Darwin / Mac OS X version */
+/* #undef DARWIN_VERS */
+
+/* configured to run as an inner Valgrind */
+/* #undef ENABLE_INNER */
+
+/* path to GDB */
+#define GDB_PATH "/system/bin/gdb"
+
+/* Define to 1 if you're using glibc 2.10.x */
+/* #undef GLIBC_2_10 */
+
+/* Define to 1 if you're using glibc 2.11.x */
+/* #undef GLIBC_2_11 */
+
+/* Define to 1 if you're using glibc 2.12.x */
+/* #undef GLIBC_2_12 */
+
+/* Define to 1 if you're using glibc 2.2.x */
+/* #undef GLIBC_2_2 */
+
+/* Define to 1 if you're using glibc 2.3.x */
+/* #undef GLIBC_2_3 */
+
+/* Define to 1 if you're using glibc 2.4.x */
+/* #undef GLIBC_2_4 */
+
+/* Define to 1 if you're using glibc 2.5.x */
+/* #undef GLIBC_2_5 */
+
+/* Define to 1 if you're using glibc 2.6.x */
+/* #undef GLIBC_2_6 */
+
+/* Define to 1 if you're using glibc 2.7.x */
+/* #undef GLIBC_2_7 */
+
+/* Define to 1 if you're using glibc 2.8.x */
+/* #undef GLIBC_2_8 */
+
+/* Define to 1 if you're using glibc 2.9.x */
+/* #undef GLIBC_2_9 */
+
+/* Define to 1 if gcc/as can do Altivec. */
+/* #undef HAS_ALTIVEC */
+
+/* Define to 1 if you have the <asm/unistd.h> header file. */
+#define HAVE_ASM_UNISTD_H 1
+
+/* Define to 1 if as supports mtocrf/mfocrf. */
+/* #undef HAVE_AS_PPC_MFTOCRF */
+
+/* Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o. */
+/* #undef HAVE_BUILTIN_ATOMIC */
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
+
+/* Define to 1 if you have the `CLOCK_MONOTONIC' constant. */
+#define HAVE_CLOCK_MONOTONIC 1
+
+/* Define to 1 if you have the <endian.h> header file. */
+/* #define HAVE_ENDIAN_H 1 -- already defined in AndroidConfig.h */
+
+/* Define to 1 if you have the `epoll_create' function. */
+#define HAVE_EPOLL_CREATE 1
+
+/* Define to 1 if you have the `epoll_pwait' function. */
+/* #undef HAVE_EPOLL_PWAIT */
+
+/* Define to 1 if you have the `eventfd' function. */
+#define HAVE_EVENTFD 1
+
+/* Define to 1 if you have the `eventfd_read' function. */
+#define HAVE_EVENTFD_READ 1
+
+/* Define to 1 if you have the `floor' function. */
+#define HAVE_FLOOR 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `klogctl' function. */
+#define HAVE_KLOGCTL 1
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+/* #undef HAVE_LIBRT */
+
+/* Define to 1 if you have the `mallinfo' function. */
+#define HAVE_MALLINFO 1
+
+/* Define to 1 if you have the `memchr' function. */
+#define HAVE_MEMCHR 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkdir' function. */
+#define HAVE_MKDIR 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the <mqueue.h> header file. */
+/* #undef HAVE_MQUEUE_H */
+
+/* Define to 1 if you have the `mremap' function. */
+#define HAVE_MREMAP 1
+
+/* Define to 1 if you have the `ppoll' function. */
+/* #undef HAVE_PPOLL */
+
+/* Define to 1 if you have the `pthread_barrier_init' function. */
+/* #undef HAVE_PTHREAD_BARRIER_INIT */
+
+/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+/* #undef HAVE_PTHREAD_CONDATTR_SETCLOCK */
+
+/* Define to 1 if you have the `pthread_create@glibc2.0' function. */
+/* #undef HAVE_PTHREAD_CREATE_GLIBC_2_0 */
+
+/* Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant. */
+/* #undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
+
+/* Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant. */
+#define HAVE_PTHREAD_MUTEX_ERRORCHECK_NP 1
+
+/* Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant. */
+#define HAVE_PTHREAD_MUTEX_RECURSIVE_NP 1
+
+/* Define to 1 if you have the `pthread_mutex_timedlock' function. */
+#define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1
+
+/* Define to 1 if pthread_mutex_t has a member __data.__kind. */
+/* #undef HAVE_PTHREAD_MUTEX_T__DATA__KIND */
+
+/* Define to 1 if pthread_mutex_t has a member called __m_kind. */
+/* #undef HAVE_PTHREAD_MUTEX_T__M_KIND */
+
+/* Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP'
+   constant. */
+#define HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 1
+
+/* Define to 1 if you have the `pthread_rwlock_timedrdlock' function. */
+#define HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK 1
+
+/* Define to 1 if you have the `pthread_rwlock_timedwrlock' function. */
+#define HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 1
+
+/* Define to 1 if you have the `pthread_spin_lock' function. */
+/* #undef HAVE_PTHREAD_SPIN_LOCK */
+
+/* Define to 1 if you have the `pthread_yield' function. */
+/* #undef HAVE_PTHREAD_YIELD */
+
+/* Define to 1 if the installed version of Qt4 provides QAtomicInt. */
+/* #undef HAVE_QTCORE_QATOMICINT */
+
+/* Define to 1 if the installed version of Qt4 provides QMutex::tryLock(int).
+   */
+/* #undef HAVE_QTCORE_QMUTEX_TRYLOCK_INT */
+
+/* Define to 1 if you have the `readlinkat' function. */
+/* #undef HAVE_READLINKAT */
+
+/* Define to 1 if you have the `semtimedop' function. */
+/* #undef HAVE_SEMTIMEDOP */
+
+/* Define to 1 if you have the `signalfd' function. */
+/* #undef HAVE_SIGNALFD */
+
+/* Define to 1 if you have the `sigwaitinfo' function. */
+/* #undef HAVE_SIGWAITINFO */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strpbrk' function. */
+#define HAVE_STRPBRK 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strstr' function. */
+#define HAVE_STRSTR 1
+
+/* Define to 1 if you have the `syscall' function. */
+#define HAVE_SYSCALL 1
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#define HAVE_SYS_ENDIAN_H 1
+
+/* Define to 1 if you have the <sys/epoll.h> header file. */
+#define HAVE_SYS_EPOLL_H 1
+
+/* Define to 1 if you have the <sys/eventfd.h> header file. */
+#define HAVE_SYS_EVENTFD_H 1
+
+/* Define to 1 if you have the <sys/klog.h> header file. */
+#define HAVE_SYS_KLOG_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#define HAVE_SYS_POLL_H 1
+
+/* Define to 1 if you have the <sys/signalfd.h> header file. */
+/* #undef HAVE_SYS_SIGNALFD_H */
+
+/* Define to 1 if you have the <sys/signal.h> header file. */
+#define HAVE_SYS_SIGNAL_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#define HAVE_SYS_SYSCALL_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `timerfd' function. */
+/* #undef HAVE_TIMERFD */
+
+/* can use __thread to define thread-local variables */
+/* #undef HAVE_TLS */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `utimensat' function. */
+/* #undef HAVE_UTIMENSAT */
+
+/* Define to 1 if you're using Linux 2.4.x */
+/* #undef KERNEL_2_4 */
+
+/* Define to 1 if you're using Linux 2.6.x */
+#define KERNEL_2_6 1
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "valgrind"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "valgrind-users@lists.sourceforge.net"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "Valgrind"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "Valgrind 3.6.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "valgrind"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "3.6.0"
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Version number of package */
+#define VERSION "3.6.0"
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+/* #undef gid_t */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+/* #undef uid_t */
diff --git a/coregrind/launcher-linux.c b/coregrind/launcher-linux.c
index e7c9c7f..888887f 100644
--- a/coregrind/launcher-linux.c
+++ b/coregrind/launcher-linux.c
@@ -52,7 +52,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
+#ifdef ANDROID
+#include <linux/user.h>
+#else
 #include <sys/user.h>
+#endif
 #include <unistd.h>
 
 
@@ -63,6 +67,9 @@
 #ifndef EM_X86_64
 #define EM_X86_64 62    // elf.h doesn't define this on some older systems
 #endif
+#ifndef EM_PPC64
+#define EM_PPC64 21     // elf.h doesn't define this on Android
+#endif
 
 /* Report fatal errors */
 __attribute__((noreturn))
diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c
index c47562e..25fb7dc 100644
--- a/coregrind/m_coredump/coredump-elf.c
+++ b/coregrind/m_coredump/coredump-elf.c
@@ -53,7 +53,12 @@
   Generate a standard ELF core file corresponding to the client state
   at the time of a crash.
  */
+#ifdef ANDROID
+#include <linux/elf.h>
+#define NT_FPREGSET 2
+#else
 #include <elf.h>
+#endif
 #ifndef NT_PRXFPREG
 #define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
 #endif /* NT_PRXFPREG */
diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c
index 303c001..7b67b71 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -652,6 +652,9 @@
    if (sr_isError(statres)) {
       DebugInfo fake_di;
       Bool quiet = VG_(strstr)(filename, "/var/run/nscd/") != NULL;
+#ifdef ANDROID
+      quiet |= VG_(strstr)(filename, "/dev/__properties__") != NULL;
+#endif
       if (!quiet && VG_(clo_verbosity) > 1) {
          VG_(memset)(&fake_di, 0, sizeof(fake_di));
          fake_di.filename = filename;
diff --git a/coregrind/m_debuginfo/readstabs.c b/coregrind/m_debuginfo/readstabs.c
index e91faf4..cfa7438 100644
--- a/coregrind/m_debuginfo/readstabs.c
+++ b/coregrind/m_debuginfo/readstabs.c
@@ -50,7 +50,11 @@
 
 /* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
 #if defined(VGO_linux)
+#ifdef ANDROID
+#  include <linux/a.out.h>
+#else
 #  include <a.out.h> /* stabs defns */
+#endif
 #elif defined(VGO_darwin)
 #  include <mach-o/nlist.h>
 #  define n_other n_sect
diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c
index ad7dedd..3a726d7 100644
--- a/coregrind/m_initimg/initimg-linux.c
+++ b/coregrind/m_initimg/initimg-linux.c
@@ -56,7 +56,12 @@
 #define _GNU_SOURCE
 #define _FILE_OFFSET_BITS 64
 /* This is for ELF types etc, and also the AT_ constants. */
+#ifdef ANDROID
+#include <linux/elf.h>
+#define AT_FPUCW 18
+#else
 #include <elf.h>
+#endif
 /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
 
 
diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c
index 9c1847b..16ccd27 100644
--- a/coregrind/m_libcfile.c
+++ b/coregrind/m_libcfile.c
@@ -612,10 +612,18 @@
 
    tries = 0;
    while (True) {
-      if (tries > 10) 
+      if (++tries > 10)
          return -1;
+#ifdef ANDROID
+      // FIXME: It's lame to create these temporary files in a persistent store
+      // let alone the root of /sdcard.  We are a little stuck though unless we
+      // mount tmpfs somewhere or implement some new syscall wrappers (like mkdir).
+      VG_(sprintf)( buf, "/sdcard/valgrind_%s_%08x",
+                         part_of_name, VG_(random)( &seed ));
+#else
       VG_(sprintf)( buf, "/tmp/valgrind_%s_%08x", 
                          part_of_name, VG_(random)( &seed ));
+#endif
       if (0)
          VG_(printf)("VG_(mkstemp): trying: %s\n", buf);
 
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index e5871c4..192097f 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -2773,7 +2773,9 @@
 );
 #elif defined(VGP_arm_linux)
 asm("\n"
-    "\t.align 2\n"
+    "\t.text\n"
+    "\t.align 4\n"
+    "\t.type _start,#function\n"
     "\t.global _start\n"
     "_start:\n"
     "\tldr  r0, [pc, #36]\n"
diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c
index 95756d2..779d3e4 100644
--- a/coregrind/m_replacemalloc/vg_replace_malloc.c
+++ b/coregrind/m_replacemalloc/vg_replace_malloc.c
@@ -587,7 +587,7 @@
 /*---------------------- valloc ----------------------*/
 
 static int local__getpagesize ( void ) {
-#  if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+#  if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(ANDROID)
    return 4096; /* kludge - toc problems prevent calling getpagesize() */
 #  else
    extern int getpagesize (void);
@@ -613,9 +613,8 @@
    void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( void *zone, SizeT size )  \
    { \
       static int pszB = 0; \
-      extern int getpagesize (void); \
       if (pszB == 0) \
-         pszB = getpagesize(); \
+         pszB = local__getpagesize(); \
       return VG_REPLACE_FUNCTION_ZU(VG_Z_LIBC_SONAME,memalign) \
                 ((SizeT)pszB, size); \
    }
diff --git a/coregrind/m_ume/elf.c b/coregrind/m_ume/elf.c
index 39e6f0b..234b470 100644
--- a/coregrind/m_ume/elf.c
+++ b/coregrind/m_ume/elf.c
@@ -393,7 +393,13 @@
             if (iph->p_type != PT_LOAD)
                continue;
             
+#ifdef ANDROID
+            // The first LOAD segment of /system/bin/linker has vaddr=0, memsz=0
+            // but subsequent segments start at 0xb0001000.
+            if (!baseaddr_set && iph->p_vaddr) {
+#else
             if (!baseaddr_set) {
+#endif
                interp_addr  = iph->p_vaddr;
                interp_align = iph->p_align;
                baseaddr_set = 1;
diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c
index f74b52a..e9723d9 100644
--- a/coregrind/vg_preloaded.c
+++ b/coregrind/vg_preloaded.c
@@ -57,7 +57,7 @@
 void VG_NOTIFY_ON_LOAD(freeres)( void )
 {
    int res;
-#if !defined(__UCLIBC__) && !defined(VGO_aix5)
+#if !defined(__UCLIBC__) && !defined(VGO_aix5) && !defined(ANDROID)
    extern void __libc_freeres(void);
    __libc_freeres();
 #endif
diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c
index 01e6ab2..74202a0 100644
--- a/helgrind/hg_intercepts.c
+++ b/helgrind/hg_intercepts.c
@@ -2155,6 +2155,9 @@
          long  recmode)
 {
    assert(0);
+#ifdef ANDROID // error: control reaches end of non-void function
+   return 0;
+#endif
 }
 
 
@@ -2163,6 +2166,9 @@
 QT4_FUNC(void*, _ZN6QMutexD2Ev, void* mutex)
 {
    assert(0);
+#ifdef ANDROID // error: control reaches end of non-void function
+   return 0;
+#endif
 }
 
 
diff --git a/include/vki/vki-arm-linux.h b/include/vki/vki-arm-linux.h
index 678e268..12de6fd 100644
--- a/include/vki/vki-arm-linux.h
+++ b/include/vki/vki-arm-linux.h
@@ -618,7 +618,7 @@
 	vki_stack_t		uc_stack;
 	struct vki_sigcontext	uc_mcontext;
 	vki_sigset_t		uc_sigmask;	/* mask last for extensibility */
-	int               __unused[32 - (sizeof (vki_sigset_t) / sizeof (int))];
+	int               __unused1[32 - (sizeof (vki_sigset_t) / sizeof (int))];
 	unsigned long     uc_regspace[128] __attribute__((__aligned__(8)));
 
 };
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
index 537f0e0..8dfba34 100644
--- a/include/vki/vki-linux.h
+++ b/include/vki/vki-linux.h
@@ -1319,7 +1319,7 @@
 	vki_size_t __user *oldlenp;
 	void __user *newval;
 	vki_size_t newlen;
-	unsigned long __unused[4];
+	unsigned long __unused1[4];
 };
 
 //----------------------------------------------------------------------