Merge remote-tracking branch 'aosp/upstream-master' into mymerge

Change-Id: Id7ba841d2447b1e13e9f3777b395e2a3e4e77812
diff --git a/Android.build_all.mk b/Android.build_all.mk
new file mode 100644
index 0000000..606e74c
--- /dev/null
+++ b/Android.build_all.mk
@@ -0,0 +1,36 @@
+# Copyright (C) 2014 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.
+
+vg_local_target_arch_cflags := $(target_arch_cflags)
+vg_local_target_2nd_arch_cflags := $(target_2nd_arch_cflags)
+vg_build_second_arch := false
+include $(LOCAL_PATH)/Android.build_one.mk
+
+# build second arch
+ifneq ($(TARGET_2ND_ARCH),)
+  vg_build_second_arch := true
+  include $(LOCAL_PATH)/Android.build_one.mk
+endif
+
+vg_build_second_arch := false
+vg_local_host_arch_cflags := $(host_arch_cflags)
+include $(LOCAL_PATH)/Android.build_host.mk
+
+vg_build_second_arch := true
+vg_local_host_arch_cflags := $(host_2nd_arch_cflags)
+include $(LOCAL_PATH)/Android.build_host.mk
+
+# clean vg_locals
+include $(LOCAL_PATH)/Android.clean.mk
+
diff --git a/Android.build_host.mk b/Android.build_host.mk
new file mode 100644
index 0000000..77d11ba
--- /dev/null
+++ b/Android.build_host.mk
@@ -0,0 +1,74 @@
+# Copyright (C) 2014 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.
+
+ifeq ($(HOST_OS), linux)
+include $(CLEAR_VARS)
+
+ifeq ($(vg_build_second_arch),true)
+  LOCAL_MULTILIB := 32
+  vg_local_arch := x86
+else
+  LOCAL_MULTILIB := first
+  vg_local_arch := amd64
+endif
+
+# TODO: This workaround is to avoid calling memset from VG(memset)
+# wrapper because of invalid clang optimization; This seems to be
+# limited to amd64/x86 codegen(?);
+LOCAL_CLANG := false
+
+LOCAL_MODULE := $(vg_local_module)-$(vg_local_arch)-linux
+
+LOCAL_SRC_FILES := $(vg_local_src_files)
+
+LOCAL_C_INCLUDES := $(common_includes) $(vg_local_c_includes)
+
+LOCAL_CFLAGS := $(vg_local_cflags) $(vg_local_host_arch_cflags)
+
+LOCAL_ASFLAGS := $(common_cflags) $(vg_local_host_arch_cflags)
+
+LOCAL_LDFLAGS := $(vg_local_ldflags) -lpthread
+
+LOCAL_MODULE_CLASS := $(vg_local_module_class)
+
+LOCAL_STATIC_LIBRARIES := \
+    $(foreach l,$(vg_local_static_libraries),$l-$(vg_local_arch)-linux)
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+    $(foreach l,$(vg_local_whole_static_libraries),$l-$(vg_local_arch)-linux)
+
+ifeq ($(vg_local_target),EXECUTABLE)
+  LOCAL_FORCE_STATIC_EXECUTABLE := true
+  LOCAL_NO_FPIE := true
+endif
+
+ifneq ($(vg_local_target),STATIC_LIBRARY)
+  LOCAL_MODULE_PATH=$(HOST_OUT)/lib64/valgrind
+endif
+
+ifeq ($(vg_local_without_system_shared_libraries),true)
+  LOCAL_SYSTEM_SHARED_LIBRARIES :=
+  # for host 32 bit we need -static-libgcc
+  LOCAL_LDFLAGS += -lgcc
+endif
+
+ifeq ($(vg_local_no_crt),true)
+  LOCAL_NO_CRT := true
+endif
+
+LOCAL_CXX_STL := none
+LOCAL_SANITIZE := never
+
+include $(BUILD_HOST_$(vg_local_target))
+
+endif
diff --git a/Android.build_one.mk b/Android.build_one.mk
new file mode 100644
index 0000000..b801e06
--- /dev/null
+++ b/Android.build_one.mk
@@ -0,0 +1,77 @@
+# Copyright (C) 2014 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.
+
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+ifeq ($(vg_build_second_arch),true)
+LOCAL_MULTILIB := 32
+vg_local_arch := $(TARGET_2ND_ARCH)
+else
+LOCAL_MULTILIB := first
+vg_local_arch  := $(vg_arch)
+endif
+
+# TODO: This workaround is to avoid calling memset from VG(memset)
+# wrapper because of invalid clang optimization; This seems to be
+# limited to amd64/x86 codegen(?);
+ifeq ($(filter $TARGET_ARCH,x86 x86_64),)
+  LOCAL_CLANG := false
+endif
+
+LOCAL_MODULE := $(vg_local_module)-$(vg_local_arch)-linux
+
+LOCAL_SRC_FILES := $(vg_local_src_files)
+
+LOCAL_C_INCLUDES := $(common_includes) $(vg_local_c_includes)
+
+LOCAL_PACK_MODULE_RELOCATIONS := false
+
+LOCAL_CFLAGS := $(vg_local_cflags)
+LOCAL_CFLAGS_$(TARGET_ARCH) := $(vg_local_target_arch_cflags)
+LOCAL_CFLAGS_$(TARGET_2ND_ARCH) := $(vg_local_target_2nd_arch_cflags)
+
+LOCAL_ASFLAGS := $(common_cflags)
+LOCAL_ASFLAGS_$(TARGET_ARCH) := $(vg_local_target_arch_cflags)
+LOCAL_ASFLAGS_$(TARGET_2ND_ARCH) := $(vg_local_target_2nd_arch_cflags)
+
+
+LOCAL_LDFLAGS := $(vg_local_ldflags)
+
+LOCAL_MODULE_CLASS := $(vg_local_module_class)
+
+LOCAL_STATIC_LIBRARIES := \
+    $(foreach l,$(vg_local_static_libraries),$l-$(vg_local_arch)-linux)
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+    $(foreach l,$(vg_local_whole_static_libraries),$l-$(vg_local_arch)-linux)
+
+ifeq ($(vg_local_target),EXECUTABLE)
+  LOCAL_FORCE_STATIC_EXECUTABLE := true
+  LOCAL_NO_FPIE := true
+endif
+
+ifneq ($(vg_local_target),STATIC_LIBRARY)
+  LOCAL_MODULE_PATH=$(PRODUCT_OUT)$(vg_target_module_path)
+endif
+
+ifeq ($(vg_local_without_system_shared_libraries),true)
+  LOCAL_SYSTEM_SHARED_LIBRARIES :=
+endif
+
+ifeq ($(vg_local_no_crt),true)
+  LOCAL_NO_CRT := true
+endif
+
+include $(BUILD_$(vg_local_target))
+
diff --git a/Android.clean.mk b/Android.clean.mk
new file mode 100644
index 0000000..31ae7f4
--- /dev/null
+++ b/Android.clean.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2014 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.
+
+
+vg_local_module :=
+vg_local_target :=
+vg_local_module_class :=
+vg_local_src_files :=
+vg_local_ldflags :=
+vg_local_static_libraries :=
+vg_local_whole_static_libraries :=
+vg_local_without_system_shared_libraries :=
+vg_local_no_crt :=
+vg_local_cflags :=
+vg_local_host_arch_cflags :=
+vg_local_target_arch_cflags :=
+vg_local_target_2nd_arch_cflags :=
+vg_local_c_includes :=
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..bf265cb
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,636 @@
+# 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)
+
+ANDROID_HARDWARE := ANDROID_HARDWARE_generic
+
+ifneq ($(filter arm arm64 x86 x86_64,$(TARGET_ARCH)),)
+
+vg_arch:=$(TARGET_ARCH)
+
+ifneq ($(filter x86_64, $(TARGET_ARCH)),)
+  vg_arch:=amd64
+endif
+
+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 \
+	-DVGO_linux=1 \
+	-DANDROID_SYMBOLS_DIR=\"/data/local/symbols\" \
+  -std=gnu99
+
+ifeq ($(TARGET_IS_64_BIT),true)
+  vg_target_module_path := /system/lib64/valgrind
+else
+  vg_target_module_path := /system/lib/valgrind
+endif
+
+target_arch_cflags := \
+	-DVGA_$(vg_arch)=1 \
+	-DVGP_$(vg_arch)_linux=1 \
+	-DVGPV_$(vg_arch)_linux_android=1 \
+	-DVG_LIBDIR=\"$(vg_target_module_path)\" \
+	-DVG_PLATFORM=\"$(vg_arch)-linux\"
+
+ifdef TARGET_2ND_ARCH
+target_2nd_arch_cflags := \
+	-DVGA_$(TARGET_2ND_ARCH)=1 \
+	-DVGP_$(TARGET_2ND_ARCH)_linux=1 \
+	-DVGPV_$(TARGET_2ND_ARCH)_linux_android=1 \
+	-DVG_LIBDIR=\"$(vg_target_module_path)\" \
+	-DVG_PLATFORM=\"$(TARGET_2ND_ARCH)-linux\"
+vg_second_arch := $(TARGET_2ND_ARCH)
+
+endif
+
+# The supported host platform are linux amd64 and linux x86
+host_arch_cflags := \
+  -DVGA_amd64=1 \
+  -DVGP_amd64_linux=1 \
+  -DVG_PLATFORM=\"amd64-linux\" \
+  -DVG_LIBDIR=\"$(realpath $(HOST_OUT_SHARED_LIBRARIES))/valgrind\"
+
+host_2nd_arch_cflags := \
+  -DVGA_x86=1 \
+  -DVGP_x86_linux=1 \
+  -DVG_PLATFORM=\"x86-linux\" \
+  -DVG_LIBDIR=\"$(realpath $(HOST_OUT_SHARED_LIBRARIES))/valgrind\"
+
+common_includes := \
+	external/valgrind \
+	external/valgrind/include \
+	external/valgrind/VEX/pub \
+	external/valgrind/coregrind
+
+vex_ldflags := -nodefaultlibs
+
+ifeq (,$(filter $(TARGET_ARCH),arm arm64))
+tool_ldflags := -static -Wl,--build-id=none,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -Wl,-e,_start
+else
+tool_ldflags := -static -Wl,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -Wl,-e,_start
+endif
+
+common_cflags += -D$(ANDROID_HARDWARE)
+
+preload_ldflags := -nodefaultlibs -Wl,-z,interpose,-z,initfirst
+# Remove this when the all toolchains are GCC 4.4
+ifeq ($(TARGET_ARCH),arm)
+  preload_ldflags += -Wl,--icf=none
+endif
+
+# Build libvex-($TARGET_ARCH)-linux.a
+vg_local_module=libvex
+
+vg_local_cflags := $(common_cflags) \
+    -Wbad-function-cast \
+    -Wcast-qual \
+    -Wcast-align \
+    -fstrict-aliasing \
+
+vg_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/ir_inject.c \
+	VEX/priv/guest_generic_bb_to_IR.c \
+	VEX/priv/guest_generic_x87.c \
+	VEX/priv/guest_mips_helpers.c \
+	VEX/priv/guest_mips_toIR.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/guest_arm64_helpers.c \
+	VEX/priv/guest_arm64_toIR.c \
+	VEX/priv/guest_s390_helpers.c \
+	VEX/priv/guest_s390_toIR.c \
+	VEX/priv/host_generic_maddf.c \
+	VEX/priv/host_generic_regs.c \
+	VEX/priv/host_generic_simd64.c \
+	VEX/priv/host_generic_simd128.c \
+	VEX/priv/host_generic_simd256.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_mips_defs.c \
+	VEX/priv/host_mips_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 \
+	VEX/priv/host_arm64_defs.c \
+	VEX/priv/host_arm64_isel.c \
+	VEX/priv/host_s390_defs.c \
+	VEX/priv/host_s390_isel.c \
+	VEX/priv/s390_disasm.c
+
+vg_local_target := STATIC_LIBRARY
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build libcoregrind-$(TARGET_ARCH)-linux.a
+vg_local_module := libcoregrind
+vg_local_target := STATIC_LIBRARY
+
+vg_local_src_files := \
+	coregrind/m_addrinfo.c \
+	coregrind/m_cache.c \
+	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_libcsetjmp.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_poolalloc.c \
+	coregrind/m_rangemap.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-segnames.c \
+	coregrind/m_coredump/coredump-elf.c \
+	coregrind/m_coredump/coredump-macho.c \
+	coregrind/m_debuginfo/image.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/readexidx.c \
+	coregrind/m_debuginfo/readmacho.c \
+	coregrind/m_debuginfo/readpdb.c \
+	coregrind/m_debuginfo/storage.c \
+	coregrind/m_debuginfo/tytypes.c \
+	coregrind/m_deduppoolalloc.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-ppc64be-linux.S \
+	coregrind/m_dispatch/dispatch-ppc64le-linux.S \
+	coregrind/m_dispatch/dispatch-arm-linux.S \
+	coregrind/m_dispatch/dispatch-arm64-linux.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-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_sbprofile.c \
+	coregrind/m_scheduler/sched-lock.c \
+	coregrind/m_scheduler/sched-lock-generic.c \
+	coregrind/m_scheduler/scheduler.c \
+	coregrind/m_scheduler/sema.c \
+	coregrind/m_scheduler/ticket-lock-linux.c \
+	coregrind/m_sigframe/sigframe-common.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-arm64-linux.c \
+	coregrind/m_sigframe/sigframe-x86-darwin.c \
+	coregrind/m_sigframe/sigframe-amd64-darwin.c \
+	coregrind/m_sigframe/sigframe-s390x-linux.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-ppc64be-linux.S \
+	coregrind/m_syswrap/syscall-ppc64le-linux.S \
+	coregrind/m_syswrap/syscall-arm-linux.S \
+	coregrind/m_syswrap/syscall-arm64-linux.S \
+	coregrind/m_syswrap/syscall-x86-darwin.S \
+	coregrind/m_syswrap/syscall-amd64-darwin.S \
+	coregrind/m_syswrap/syscall-s390x-linux.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-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-arm64-linux.c \
+	coregrind/m_syswrap/syswrap-x86-darwin.c \
+	coregrind/m_syswrap/syswrap-amd64-darwin.c \
+	coregrind/m_syswrap/syswrap-s390x-linux.c \
+	coregrind/m_syswrap/syswrap-xen.c \
+	coregrind/m_ume/elf.c \
+	coregrind/m_ume/macho.c \
+	coregrind/m_ume/main.c \
+	coregrind/m_ume/script.c \
+	coregrind/vgdb.c \
+	coregrind/m_gdbserver/inferiors.c \
+	coregrind/m_gdbserver/m_gdbserver.c \
+	coregrind/m_gdbserver/regcache.c \
+	coregrind/m_gdbserver/remote-utils.c \
+	coregrind/m_gdbserver/server.c \
+	coregrind/m_gdbserver/signals.c \
+	coregrind/m_gdbserver/target.c \
+	coregrind/m_gdbserver/utils.c \
+	coregrind/m_gdbserver/valgrind-low-amd64.c \
+	coregrind/m_gdbserver/valgrind-low-arm.c \
+	coregrind/m_gdbserver/valgrind-low-arm64.c \
+	coregrind/m_gdbserver/valgrind-low-ppc32.c \
+	coregrind/m_gdbserver/valgrind-low-ppc64.c \
+	coregrind/m_gdbserver/valgrind-low-s390x.c \
+	coregrind/m_gdbserver/valgrind-low-x86.c \
+	coregrind/m_gdbserver/version.c
+
+vg_local_ldflags := $(vex_ldflags)
+vg_local_cflags := $(common_cflags)
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build libreplacemalloc_toolpreload-$(TARGET_ARCH)-linux.a
+vg_local_module := libreplacemalloc_toolpreload
+vg_local_target := STATIC_LIBRARY
+
+vg_local_src_files := \
+	coregrind/m_replacemalloc/vg_replace_malloc.c
+
+vg_local_ldflags := $(preload_ldflags)
+
+vg_local_cflags := $(common_cflags)
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build vgpreload_core-$(TARGET_ARCH)-linux.so
+vg_local_module := vgpreload_core
+vg_local_target := SHARED_LIBRARY
+vg_local_module_class := SHARED_LIBRARIES
+
+vg_local_src_files := \
+	coregrind/vg_preloaded.c
+
+#LOCAL_STRIP_MODULE := false
+#vg_local_no_crt := true
+
+vg_local_ldflags := $(preload_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_arch_cflags := $(target_arch_cflags)
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build memcheck-$(TARGET_ARCH)-linux
+vg_local_module := memcheck
+vg_local_target := EXECUTABLE
+vg_local_module_class := SHARED_LIBRARIES
+vg_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
+
+vg_local_cflags := $(common_cflags)
+vg_local_ldflags := $(tool_ldflags)
+vg_local_static_libraries := libcoregrind libvex
+
+vg_local_without_system_shared_libraries := true
+vg_local_no_crt := true
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build vgpreload_memcheck-$(TARGET_ARCH)-linux.so
+vg_local_module := vgpreload_memcheck
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := SHARED_LIBRARY
+
+vg_local_src_files := \
+	memcheck/mc_replace_strmem.c
+
+vg_local_ldflags := $(preload_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_whole_static_libraries := libreplacemalloc_toolpreload
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build cachegrind-$(TARGET_ARCH)-linux
+vg_local_module := cachegrind
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+
+vg_local_src_files := \
+	cachegrind/cg_arch.c \
+	cachegrind/cg_main.c
+
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+# Build callgrind-$(TARGET_ARCH)-linux
+
+vg_local_module := callgrind
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+
+vg_local_src_files := \
+	callgrind/bb.c \
+	callgrind/bbcc.c \
+	callgrind/callstack.c \
+	callgrind/clo.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
+
+vg_local_c_includes := external/valgrind/cachegrind
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+# Build helgrind-$(TARGET_ARCH)-linux
+vg_local_module := helgrind
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+vg_local_src_files := \
+    helgrind/hg_addrdescr.c \
+    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
+
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+# Build vgpreload_helgrind-$(TARGET_ARCH)-linux.so
+vg_local_module := vgpreload_helgrind
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := SHARED_LIBRARY
+#LOCAL_STRIP_MODULE := false
+vg_local_no_crt := true
+
+vg_local_src_files := \
+	helgrind/hg_intercepts.c
+
+
+vg_local_ldflags := $(preload_ldflags)
+vg_local_cflags := $(common_cflags)
+vg_local_whole_static_libraries := libreplacemalloc_toolpreload
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build drd-$(TARGET_ARCH)-linux
+vg_local_module := drd
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+
+vg_local_src_files := \
+	drd/drd_barrier.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
+
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build vgpreload_drd-$(TARGET_ARCH)-linux.so
+vg_local_module := vgpreload_drd
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := SHARED_LIBRARY
+vg_local_no_crt := true
+
+vg_local_src_files := \
+	drd/drd_pthread_intercepts.c \
+	drd/drd_qtcore_intercepts.c \
+	drd/drd_strmem_intercepts.c
+
+vg_local_ldflags := $(preload_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_whole_static_libraries := libreplacemalloc_toolpreload
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build massif-$(TARGET_ARCH)-linux
+vg_local_module := massif
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+
+vg_local_src_files := \
+	massif/ms_main.c
+
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build vgpreload_massif-$(TARGET_ARCH)-linux.so
+vg_local_module := vgpreload_massif
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := SHARED_LIBRARY
+vg_local_no_crt := true
+
+vg_local_src_files :=
+
+vg_local_ldflags := $(preload_ldflags)
+vg_local_cflags := $(common_cflags)
+vg_local_whole_static_libraries := libreplacemalloc_toolpreload
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build none-$(TARGET_ARCH)-linux
+vg_local_module := none
+vg_local_module_class := SHARED_LIBRARIES
+vg_local_target := EXECUTABLE
+
+vg_local_no_crt := true
+vg_local_without_system_shared_libraries := true
+
+vg_local_src_files := \
+	none/nl_main.c
+
+vg_local_ldflags := $(tool_ldflags)
+vg_local_cflags := $(common_cflags)
+vg_local_static_libraries := libcoregrind libvex
+
+include $(LOCAL_PATH)/Android.build_all.mk
+
+# Build valgrind
+include $(CLEAR_VARS)
+LOCAL_MODULE := valgrind
+LOCAL_ARM_MODE := arm
+LOCAL_SRC_FILES := \
+	coregrind/launcher-linux.c \
+	coregrind/m_debuglog.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+LOCAL_CFLAGS := $(common_cflags)
+
+LOCAL_CFLAGS_$(TARGET_ARCH) = $(target_arch_cflags)
+
+include $(BUILD_EXECUTABLE)
+
+# Build valgrind for linux host
+ifeq ($(HOST_OS), linux)
+include $(CLEAR_VARS)
+LOCAL_MODULE := valgrind
+LOCAL_SRC_FILES := \
+	coregrind/launcher-linux.c \
+	coregrind/m_debuglog.c
+
+LOCAL_C_INCLUDES := $(common_includes)
+LOCAL_CFLAGS := $(common_cflags) $(host_arch_cflags)
+LOCAL_MULTILIB := 64
+
+include $(BUILD_HOST_EXECUTABLE)
+endif
+
+#vg_build_tests := true
+# Build tests (some of them)...
+# TODO: tests need separate build framework it terms of 2ND_ARCH
+ifeq ($(vg_build_tests),true)
+ifeq ($(TARGET_ARCH),arm)
+test := v6intThumb
+include $(LOCAL_PATH)/Android.test.mk
+test := vfp
+include $(LOCAL_PATH)/Android.test.mk
+endif
+
+ifeq ($(TARGET_ARCH),arm64)
+test := integer
+include $(LOCAL_PATH)/Android.test.mk
+test := fp_and_simd
+include $(LOCAL_PATH)/Android.test.mk
+test := memory
+include $(LOCAL_PATH)/Android.test.mk
+endif
+endif
+
+# Copy prebuilt suppressions
+include $(CLEAR_VARS)
+LOCAL_MODULE := default.supp
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)$(vg_target_module_path)
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES := bionic.supp
+
+include $(BUILD_PREBUILT)
+
+ifeq ($(HOST_OS), linux)
+include $(CLEAR_VARS)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE := default.supp
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(HOST_OUT_SHARED_LIBRARIES)/valgrind
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES := bionic.supp
+
+include $(BUILD_PREBUILT)
+endif
+
+endif
diff --git a/Android.test.mk b/Android.test.mk
new file mode 100644
index 0000000..77ebbd0
--- /dev/null
+++ b/Android.test.mk
@@ -0,0 +1,7 @@
+include $(CLEAR_VARS)
+
+LOCAL_MULTILIB := first
+LOCAL_MODULE := vg-$(test)
+LOCAL_SRC_FILES := none/tests/$(TARGET_ARCH)/$(test).c
+
+include $(BUILD_NATIVE_TEST)
diff --git a/LOCAL_PATCHES.txt b/LOCAL_PATCHES.txt
new file mode 100644
index 0000000..b21cf6e
--- /dev/null
+++ b/LOCAL_PATCHES.txt
@@ -0,0 +1,12 @@
+This table contains list of local patches to valgrind.
+Please add following information for every local patch:
+1. commit sha
+2. upstream bug
+3. local bug (optional)
+
+ upsteam bug #               | local bug # | commit
+-----------------------------+-------------+-----------------------------------------
+ https://bugs.kde.org/339861 | n/a         | c3be269612b500f1f590482165d2ba5d5966f23f
+ https://bugs.kde.org/342780 | 18949144    | d07e25f39ce01de1ae33f4fa151c2cbeb2385223
+ https://bugs.kde.org/348342 | n/a         | 22bcca76a224404fa81fff26437d15f17be56fd4
+ https://bugs.kde.org/342008 |             | 68b3cc44ab604e4737e13c0f4dbd62177d2a9d6b
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/NOTICE b/NOTICE
new file mode 100644
index 0000000..e90dfed
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/VEX/priv/guest_arm_toIR.c b/VEX/priv/guest_arm_toIR.c
index e0c0458..d2bcf16 100644
--- a/VEX/priv/guest_arm_toIR.c
+++ b/VEX/priv/guest_arm_toIR.c
@@ -16549,7 +16549,7 @@
      Bool writeback_already_done = False;
      if (bS == 1 /*store*/ && summary == (2 | 16)
          && rN == 13 && rN != rD && rN != rD+1
-         && bU == 0/*minus*/ && imm8 == 8) {
+         && bU == 0/*minus*/) {
         putIRegA( rN, mkexpr(eaT), condT, Ijk_Boring );
         writeback_already_done = True;
      }
diff --git a/VEX/pub/libvex_guest_offsets.h b/VEX/pub/libvex_guest_offsets.h
new file mode 100644
index 0000000..867fe52
--- /dev/null
+++ b/VEX/pub/libvex_guest_offsets.h
@@ -0,0 +1,164 @@
+#define OFFSET_x86_EAX 8
+#define OFFSET_x86_EBX 20
+#define OFFSET_x86_ECX 12
+#define OFFSET_x86_EDX 16
+#define OFFSET_x86_ESI 32
+#define OFFSET_x86_EDI 36
+#define OFFSET_x86_EBP 28
+#define OFFSET_x86_ESP 24
+#define OFFSET_x86_EIP 68
+#define OFFSET_x86_CS 288
+#define OFFSET_x86_DS 290
+#define OFFSET_x86_ES 292
+#define OFFSET_x86_FS 294
+#define OFFSET_x86_GS 296
+#define OFFSET_x86_SS 298
+#define OFFSET_amd64_RAX 16
+#define OFFSET_amd64_RBX 40
+#define OFFSET_amd64_RCX 24
+#define OFFSET_amd64_RDX 32
+#define OFFSET_amd64_RSI 64
+#define OFFSET_amd64_RDI 72
+#define OFFSET_amd64_RSP 48
+#define OFFSET_amd64_RBP 56
+#define OFFSET_amd64_R8 80
+#define OFFSET_amd64_R9 88
+#define OFFSET_amd64_R10 96
+#define OFFSET_amd64_R11 104
+#define OFFSET_amd64_R12 112
+#define OFFSET_amd64_R13 120
+#define OFFSET_amd64_R14 128
+#define OFFSET_amd64_R15 136
+#define OFFSET_amd64_RIP 184
+#define OFFSET_ppc32_GPR0 16
+#define OFFSET_ppc32_GPR1 20
+#define OFFSET_ppc32_GPR2 24
+#define OFFSET_ppc32_GPR3 28
+#define OFFSET_ppc32_GPR4 32
+#define OFFSET_ppc32_GPR5 36
+#define OFFSET_ppc32_GPR6 40
+#define OFFSET_ppc32_GPR7 44
+#define OFFSET_ppc32_GPR8 48
+#define OFFSET_ppc32_GPR9 52
+#define OFFSET_ppc32_GPR10 56
+#define OFFSET_ppc32_CIA 1168
+#define OFFSET_ppc32_CR0_0 1185
+#define OFFSET_ppc64_GPR0 16
+#define OFFSET_ppc64_GPR1 24
+#define OFFSET_ppc64_GPR2 32
+#define OFFSET_ppc64_GPR3 40
+#define OFFSET_ppc64_GPR4 48
+#define OFFSET_ppc64_GPR5 56
+#define OFFSET_ppc64_GPR6 64
+#define OFFSET_ppc64_GPR7 72
+#define OFFSET_ppc64_GPR8 80
+#define OFFSET_ppc64_GPR9 88
+#define OFFSET_ppc64_GPR10 96
+#define OFFSET_ppc64_CIA 1296
+#define OFFSET_ppc64_CR0_0 1325
+#define OFFSET_arm_R0 8
+#define OFFSET_arm_R1 12
+#define OFFSET_arm_R2 16
+#define OFFSET_arm_R3 20
+#define OFFSET_arm_R4 24
+#define OFFSET_arm_R5 28
+#define OFFSET_arm_R7 36
+#define OFFSET_arm_R13 60
+#define OFFSET_arm_R14 64
+#define OFFSET_arm_R15T 68
+#define OFFSET_arm64_X0 16
+#define OFFSET_arm64_X1 24
+#define OFFSET_arm64_X2 32
+#define OFFSET_arm64_X3 40
+#define OFFSET_arm64_X4 48
+#define OFFSET_arm64_X5 56
+#define OFFSET_arm64_X6 64
+#define OFFSET_arm64_X7 72
+#define OFFSET_arm64_X8 80
+#define OFFSET_arm64_XSP 264
+#define OFFSET_arm64_PC 272
+#define OFFSET_s390x_r2 208
+#define OFFSET_s390x_r3 216
+#define OFFSET_s390x_r4 224
+#define OFFSET_s390x_r5 232
+#define OFFSET_s390x_r6 240
+#define OFFSET_s390x_r7 248
+#define OFFSET_s390x_r15 312
+#define OFFSET_s390x_IA 336
+#define OFFSET_s390x_SYSNO 344
+#define OFFSET_s390x_IP_AT_SYSCALL 408
+#define OFFSET_s390x_fpc 328
+#define OFFSET_s390x_CC_OP 352
+#define OFFSET_s390x_CC_DEP1 360
+#define OFFSET_s390x_CC_DEP2 368
+#define OFFSET_s390x_CC_NDEP 376
+#define OFFSET_mips32_r0 0
+#define OFFSET_mips32_r1 4
+#define OFFSET_mips32_r2 8
+#define OFFSET_mips32_r3 12
+#define OFFSET_mips32_r4 16
+#define OFFSET_mips32_r5 20
+#define OFFSET_mips32_r6 24
+#define OFFSET_mips32_r7 28
+#define OFFSET_mips32_r8 32
+#define OFFSET_mips32_r9 36
+#define OFFSET_mips32_r10 40
+#define OFFSET_mips32_r11 44
+#define OFFSET_mips32_r12 48
+#define OFFSET_mips32_r13 52
+#define OFFSET_mips32_r14 56
+#define OFFSET_mips32_r15 60
+#define OFFSET_mips32_r15 60
+#define OFFSET_mips32_r17 68
+#define OFFSET_mips32_r18 72
+#define OFFSET_mips32_r19 76
+#define OFFSET_mips32_r20 80
+#define OFFSET_mips32_r21 84
+#define OFFSET_mips32_r22 88
+#define OFFSET_mips32_r23 92
+#define OFFSET_mips32_r24 96
+#define OFFSET_mips32_r25 100
+#define OFFSET_mips32_r26 104
+#define OFFSET_mips32_r27 108
+#define OFFSET_mips32_r28 112
+#define OFFSET_mips32_r29 116
+#define OFFSET_mips32_r30 120
+#define OFFSET_mips32_r31 124
+#define OFFSET_mips32_PC 128
+#define OFFSET_mips32_HI 132
+#define OFFSET_mips32_LO 136
+#define OFFSET_mips64_r0 0
+#define OFFSET_mips64_r1 8
+#define OFFSET_mips64_r2 16
+#define OFFSET_mips64_r3 24
+#define OFFSET_mips64_r4 32
+#define OFFSET_mips64_r5 40
+#define OFFSET_mips64_r6 48
+#define OFFSET_mips64_r7 56
+#define OFFSET_mips64_r8 64
+#define OFFSET_mips64_r9 72
+#define OFFSET_mips64_r10 80
+#define OFFSET_mips64_r11 88
+#define OFFSET_mips64_r12 96
+#define OFFSET_mips64_r13 104
+#define OFFSET_mips64_r14 112
+#define OFFSET_mips64_r15 120
+#define OFFSET_mips64_r15 120
+#define OFFSET_mips64_r17 136
+#define OFFSET_mips64_r18 144
+#define OFFSET_mips64_r19 152
+#define OFFSET_mips64_r20 160
+#define OFFSET_mips64_r21 168
+#define OFFSET_mips64_r22 176
+#define OFFSET_mips64_r23 184
+#define OFFSET_mips64_r24 192
+#define OFFSET_mips64_r25 200
+#define OFFSET_mips64_r26 208
+#define OFFSET_mips64_r27 216
+#define OFFSET_mips64_r28 224
+#define OFFSET_mips64_r29 232
+#define OFFSET_mips64_r30 240
+#define OFFSET_mips64_r31 248
+#define OFFSET_mips64_PC 256
+#define OFFSET_mips64_HI 264
+#define OFFSET_mips64_LO 272
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..ca09721
--- /dev/null
+++ b/config.h
@@ -0,0 +1,381 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you're using Bionic */
+/* #undef BIONIC_LIBC */
+
+/* DARWIN_VERS value for Mac OS X 10.10 */
+/* #undef DARWIN_10_10 */
+
+/* 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 */
+
+/* DARWIN_VERS value for Mac OS X 10.8 */
+/* #undef DARWIN_10_8 */
+
+/* DARWIN_VERS value for Mac OS X 10.9 */
+/* #undef DARWIN_10_9 */
+
+/* Define to 1 if you're using Darwin */
+/* #undef DARWIN_LIBC */
+
+/* Darwin / Mac OS X version */
+/* #undef DARWIN_VERS */
+
+/* Disable intercept pthread_spin_lock() on MIPS32 and MIPS64. */
+/* #undef DISABLE_PTHREAD_SPINLOCK_INTERCEPT */
+
+/* configured to run as an inner Valgrind */
+/* #undef ENABLE_INNER */
+
+/* path to GDB */
+#define GDB_PATH "/usr/bin/gdb"
+
+/* Define to 1 if index() and strlen() have been optimized heavily (x86 glibc
+   >= 2.12) */
+#ifndef __ANDROID__
+#define GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT 1
+#endif
+
+/* Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10) */
+#ifndef __ANDROID__
+#define GLIBC_MANDATORY_STRLEN_REDIRECT 1
+#endif
+
+/* 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 floating point phased out category. */
+/* #undef HAVE_AS_PPC_FPPO */
+
+/* Define to 1 if as supports mtocrf/mfocrf. */
+/* #undef HAVE_AS_PPC_MFTOCRF */
+
+/* Define to 1 if gcc supports __sync_bool_compare_and_swap() and
+   __sync_add_and_fetch() for the primary target */
+#define HAVE_BUILTIN_ATOMIC 1
+
+/* Define to 1 if g++ supports __sync_bool_compare_and_swap() and
+   __sync_add_and_fetch() */
+#define HAVE_BUILTIN_ATOMIC_CXX 1
+
+/* Define to 1 if compiler provides __builtin_clz(). */
+#define HAVE_BUILTIN_CLZ 1
+
+/* Define to 1 if compiler provides __builtin_ctz(). */
+#define HAVE_BUILTIN_CTZ 1
+
+/* Define to 1 if compiler provides __builtin_popcount(). */
+#define HAVE_BUILTIN_POPCOUT 1
+
+/* 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 a dlinfo that can do RTLD_DI_TLS_MODID. */
+#ifndef __ANDROID__
+#define HAVE_DLINFO_RTLD_DI_TLS_MODID 1
+#endif
+
+/* Define to 1 if you have the <endian.h> header file. */
+#define HAVE_ENDIAN_H 1
+
+/* 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. */
+#define HAVE_EPOLL_PWAIT 1
+
+/* 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 `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 `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#define HAVE_LIBRT 1
+
+/* 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. */
+#define HAVE_MQUEUE_H 1
+
+/* Define to 1 if you have the `mremap' function. */
+#define HAVE_MREMAP 1
+
+/* Define to 1 if you have the `ppoll' function. */
+#define HAVE_PPOLL 1
+
+/* Define to 1 if you have the `process_vm_readv' function. */
+#ifndef __ANDROID__
+#define HAVE_PROCESS_VM_READV 1
+#endif
+
+/* Define to 1 if you have the `process_vm_writev' function. */
+#ifndef __ANDROID__
+#define HAVE_PROCESS_VM_WRITEV 1
+#endif
+
+/* Define to 1 if you have the `pthread_barrier_init' function. */
+#ifndef __ANDROID__
+#define HAVE_PTHREAD_BARRIER_INIT 1
+#endif
+
+/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+
+/* 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. */
+#ifndef __ANDROID__
+#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1
+#endif
+
+/* 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. */
+#ifndef __ANDROID__
+#define HAVE_PTHREAD_MUTEX_T__DATA__KIND 1
+#endif
+
+/* 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_t' type. */
+#define HAVE_PTHREAD_RWLOCK_T 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_setname_np' function. */
+#define HAVE_PTHREAD_SETNAME_NP 1
+
+/* Define to 1 if you have the `pthread_spin_lock' function. */
+#ifndef __ANDROID__
+#define HAVE_PTHREAD_SPIN_LOCK 1
+#endif
+
+/* Define to 1 if you have the `pthread_yield' function. */
+#define HAVE_PTHREAD_YIELD 1
+
+/* Define to 1 if you have the `PTRACE_GETREGS' ptrace request. */
+#define HAVE_PTRACE_GETREGS 1
+
+/* Define to 1 if you have the `readlinkat' function. */
+#define HAVE_READLINKAT 1
+
+/* Define to 1 if you have the `semtimedop' function. */
+#define HAVE_SEMTIMEDOP 1
+
+/* Define to 1 if libstd++ supports annotating shared pointers */
+#ifndef __ANDROID__
+#define HAVE_SHARED_POINTER_ANNOTATION 1
+#endif
+
+/* Define to 1 if you have the `signalfd' function. */
+#define HAVE_SIGNALFD 1
+
+/* Define to 1 if you have the `sigwaitinfo' function. */
+#define HAVE_SIGWAITINFO 1
+
+/* 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. */
+/* #undef 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. */
+#define HAVE_SYS_SIGNALFD_H 1
+
+/* 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 <sys/user.h> defines struct user_regs_struct */
+#define HAVE_SYS_USER_REGS 1
+
+/* can use __thread to define thread-local variables */
+#define HAVE_TLS 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have a usable <linux/futex.h> header file. */
+#define HAVE_USABLE_LINUX_FUTEX_H 1
+
+/* Define to 1 if you have the `utimensat' function. */
+#define HAVE_UTIMENSAT 1
+
+/* 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 or Linux 3.x */
+#define KERNEL_2_6 1
+
+/* configured default page size 4k */
+#define MIPS_PAGE_SHIFT 12
+
+/* 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.11.0.SVN.aosp"
+
+/* 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.11.0.SVN.aosp"
+
+/* 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.11.0.SVN.aosp"
+
+/* Temporary files directory */
+#ifdef __ANDROID__
+#define VG_TMPDIR "/data/local/tmp"
+#else
+#define VG_TMPDIR "/tmp"
+#endif
+
+/* TODO (dimtiry): remove this workaround when it becomes unnecessary
+ *
+ * Gcc produces an error when trying to compile a .c file containing
+ * asm(..) instruction outside of a function. Note that this happens only
+ * if -std=c99 flag is specified. Replacing asm with __asm__ fixes this
+ * problem.
+ */
+#define asm __asm__
+
+/* 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/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c
index b4e498d..a9258a1 100644
--- a/coregrind/m_coredump/coredump-elf.c
+++ b/coregrind/m_coredump/coredump-elf.c
@@ -135,18 +135,6 @@
    phdr->p_align = VKI_PAGE_SIZE;
 }
 
-#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
-    || defined(VGPV_mips32_linux_android)
-/* Android's libc doesn't provide a definition for this.  Hence: */
-typedef
-   struct {
-      Elf32_Word n_namesz;
-      Elf32_Word n_descsz;
-      Elf32_Word n_type;
-   }
-   Elf32_Nhdr;
-#endif
-
 struct note {
    struct note *next;
    ESZ(Nhdr) note;
diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c
index ce87615..1911e2b 100644
--- a/coregrind/m_initimg/initimg-linux.c
+++ b/coregrind/m_initimg/initimg-linux.c
@@ -646,10 +646,7 @@
          case AT_GID:
          case AT_EGID:
          case AT_CLKTCK:
-#        if !defined(VGPV_arm_linux_android) \
-            && !defined(VGPV_x86_linux_android) \
-            && !defined(VGPV_mips32_linux_android) \
-            && !defined(VGPV_arm64_linux_android)
+#        if !defined(__ANDROID__)
          case AT_FPUCW: /* missing on android */
 #        endif
             /* All these are pointerless, so we don't need to do
diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c
index 2ea7a7a..85cd432 100644
--- a/coregrind/vg_preloaded.c
+++ b/coregrind/vg_preloaded.c
@@ -57,10 +57,7 @@
 void VG_NOTIFY_ON_LOAD(freeres)( void )
 {
 #  if !defined(__UCLIBC__) \
-      && !defined(VGPV_arm_linux_android) \
-      && !defined(VGPV_x86_linux_android) \
-      && !defined(VGPV_mips32_linux_android) \
-      && !defined(VGPV_arm64_linux_android)
+      && !defined(__ANDROID__)
    extern void __libc_freeres(void);
    __libc_freeres();
 #  endif
diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c
index cc528ec..d35d5b2 100644
--- a/coregrind/vgdb.c
+++ b/coregrind/vgdb.c
@@ -687,10 +687,7 @@
       sigpipe++;
    } else if (signum == SIGALRM) {
       sigalrm++;
-#if defined(VGPV_arm_linux_android) \
-    || defined(VGPV_x86_linux_android) \
-    || defined(VGPV_mips32_linux_android) \
-    || defined(VGPV_arm64_linux_android)
+#if defined(__ANDROID__)
       /* Android has no pthread_cancel. As it also does not have
          an invoker implementation, there is no need for cleanup action.
          So, we just do nothing. */
diff --git a/runtest.sh b/runtest.sh
new file mode 100755
index 0000000..9c06923
--- /dev/null
+++ b/runtest.sh
@@ -0,0 +1,60 @@
+# Copyright (C) 2014 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.
+
+source $ANDROID_BUILD_TOP/build/envsetup.sh >/dev/null
+
+root_dir=`realpath \`dirname $0\`/../../`
+
+if [ -z "$ANDROID_SERIAL" ]; then
+  echo "Please set up ANDORID_SERAL enviroment variable"
+  exit -1
+fi
+
+if [ -z "$1" ]; then
+  echo "Usage runtest.sh test-name [64]"
+  exit -1;
+fi
+
+test_name=$1
+product_out=$(cd $ANDROID_BUILD_TOP;get_build_var PRODUCT_OUT 2>/dev/null)
+test_local=$product_out/data/nativetest$2/$test_name/$test_name
+test_target=/data/nativetest$2/$test_name/$test_name
+
+cd $root_dir
+adb push $test_local $test_target
+
+logfile_native=$test_name.stdout.log
+logfile_valgrind=$test_name.stdout.vlog
+
+# reference point
+echo "Creating reference point log (run without valgrind)..."
+adb shell $test_target > $logfile_native
+# valgrind run
+echo "Running test under valgrind..."
+adb shell valgrind $test_target > $logfile_valgrind
+
+echo "Checking results..."
+dos2unix $logfile_native
+dos2unix $logfile_valgrind
+# TODO: remove last 3 grep -v; they are added to work around linker warning about unsupported DT_FLAGS_1
+diff $logfile_native $logfile_valgrind | grep -v "^> ==" | grep -v -e "^[0-9]" | grep -v "WARNING: linker: Unsupported flags" | grep -v "^> $" | grep -v "^> 0x421==" > $test_name.diff.log
+
+if [ -s $test_name.diff.log ]; then
+  echo "Test $test_name FAILED, please check the diff below"
+  cat $test_name.diff.log | sed "s/^< /expected: /" | sed "s/^> /actual  : /"
+  exit -2
+fi
+
+echo "Test $test_name PASSED"
+
diff --git a/runtests-arm.sh b/runtests-arm.sh
new file mode 100755
index 0000000..52b2f55
--- /dev/null
+++ b/runtests-arm.sh
@@ -0,0 +1,17 @@
+# Copyright (C) 2014 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.
+
+dir=`dirname $0`
+$dir/runtest.sh vg-v6intThumb
+$dir/runtest.sh vg-vfp
diff --git a/runtests-arm64.sh b/runtests-arm64.sh
new file mode 100755
index 0000000..d283a62
--- /dev/null
+++ b/runtests-arm64.sh
@@ -0,0 +1,18 @@
+# Copyright (C) 2014 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.
+
+dir=`dirname $0`
+$dir/runtest.sh vg-memory 64
+$dir/runtest.sh vg-integer 64
+$dir/runtest.sh vg-fp_and_simd 64
diff --git a/upstream.revs.txt b/upstream.revs.txt
new file mode 100644
index 0000000..41d6478
--- /dev/null
+++ b/upstream.revs.txt
@@ -0,0 +1,2 @@
+val: 14615
+vex: 2972