aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-hung Hsieh <chh@google.com>2016-09-01 20:22:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-09-01 20:22:18 +0000
commit450d0058068a4a245bb0a189db780f4ffcf84bdc (patch)
tree7abfc78deed199148d3ee88d384bb2e213623251
parent2a8a3b47a434974eb622355ccc6dd6f0a2e280dd (diff)
parentd8fe08f2466ae86d5a3ecf9f2e58ef9d3f2892ca (diff)
downloadvalgrind-450d0058068a4a245bb0a189db780f4ffcf84bdc.tar.gz
Merge "Make host valgrind work with clang/llvm." am: 5318c4000d am: 9a25385f22
am: d8fe08f246 Change-Id: Ie3c3a3a65090dcaf6e242f0c0b08251e3951cfa2
-rw-r--r--Android.build_host.mk6
-rw-r--r--Android.build_one.mk8
-rw-r--r--coregrind/m_main.c3
-rw-r--r--coregrind/m_syswrap/syswrap-x86-linux.c10
4 files changed, 15 insertions, 12 deletions
diff --git a/Android.build_host.mk b/Android.build_host.mk
index 77d11ba4d..ee07d2de3 100644
--- a/Android.build_host.mk
+++ b/Android.build_host.mk
@@ -23,10 +23,8 @@ else
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
+# Do not call (builtin) memset from VG(memset).
+LOCAL_CLANG_CFLAGS += -fno-builtin-memset
LOCAL_MODULE := $(vg_local_module)-$(vg_local_arch)-linux
diff --git a/Android.build_one.mk b/Android.build_one.mk
index 9ab3a2b60..1705cf2ef 100644
--- a/Android.build_one.mk
+++ b/Android.build_one.mk
@@ -25,13 +25,15 @@ vg_local_arch := $(vg_arch)
vg_local_android_arch := $(TARGET_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(?);
+# For arm and arm64 targets, clang compiled module has other
+# undefined errors, see bug 28454823.
ifeq ($(filter $TARGET_ARCH,x86 x86_64),)
LOCAL_CLANG := false
endif
+# Do not call (builtin) memset from VG(memset).
+LOCAL_CLANG_CFLAGS += -fno-builtin-memset
+
LOCAL_MODULE := $(vg_local_module)-$(vg_local_arch)-linux
LOCAL_MODULE_TARGET_ARCH := $(vg_local_android_arch)
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index 1821c9412..140efbf23 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -2925,12 +2925,13 @@ asm("\n"
"\tmovl $vgPlain_interim_stack, %eax\n"
"\taddl $"VG_STRINGIFY(VG_STACK_GUARD_SZB)", %eax\n"
"\taddl $"VG_STRINGIFY(VG_DEFAULT_STACK_ACTIVE_SZB)", %eax\n"
+ /* allocate at least 16 bytes on the new stack, and aligned */
"\tsubl $16, %eax\n"
"\tandl $~15, %eax\n"
/* install it, and collect the original one */
"\txchgl %eax, %esp\n"
/* call _start_in_C_linux, passing it the startup %esp */
- "\tpushl %eax\n"
+ "\tmovl %eax, (%esp)\n"
"\tcall _start_in_C_linux\n"
"\thlt\n"
".previous\n"
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index 24d7dc18a..233886d2f 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -83,8 +83,9 @@ asm(
".globl vgModuleLocal_call_on_new_stack_0_1\n"
"vgModuleLocal_call_on_new_stack_0_1:\n"
" movl %esp, %esi\n" // remember old stack pointer
-" movl 4(%esi), %esp\n" // set stack
-" pushl 16(%esi)\n" // arg1 to stack
+" movl 4(%esi), %esp\n" // set stack, assume %esp is now 16-byte aligned
+" subl $12, %esp\n" // skip 12 bytes
+" pushl 16(%esi)\n" // arg1 to stack, %esp is 16-byte aligned
" pushl 8(%esi)\n" // retaddr to stack
" pushl 12(%esi)\n" // f to stack
" movl $0, %eax\n" // zero all GP regs
@@ -150,7 +151,8 @@ asm(
" movl 4+"FSZ"(%esp), %ecx\n" /* syscall arg2: child stack */
" movl 12+"FSZ"(%esp), %ebx\n" /* fn arg */
" movl 0+"FSZ"(%esp), %eax\n" /* fn */
-" lea -8(%ecx), %ecx\n" /* make space on stack */
+" andl $-16, %ecx\n" /* align to 16-byte */
+" lea -20(%ecx), %ecx\n" /* allocate 16*n+4 bytes on stack */
" movl %ebx, 4(%ecx)\n" /* fn arg */
" movl %eax, 0(%ecx)\n" /* fn */
@@ -165,7 +167,7 @@ asm(
" jnz 1f\n"
/* CHILD - call thread function */
-" popl %eax\n"
+" popl %eax\n" /* child %esp is 16-byte aligned */
" call *%eax\n" /* call fn */
/* exit with result */