From a3a0be70abf5d1cecd7e04e6d28d5579c8853ee0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 28 Aug 2014 14:59:04 +0000 Subject: [PATCH] Bug 338615 suppress glibc 2.20 optimized strcmp implementation for ARMv7. Add an add_hardwired_spec for strcmp in VG_(redir_initialise) for ld-linux.so.3 and ld-linux-armhf.so.3 to use a simple strcmp implementation in m_trampoline.S (compiled from the trivial .c code to asm with gcc like the other implementations in that file). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14374 --- NEWS | 1 + coregrind/m_redir.c | 11 +++++++++++ coregrind/m_trampoline.S | 16 ++++++++++++++++ coregrind/pub_core_trampoline.h | 1 + 4 files changed, 29 insertions(+) diff --git a/NEWS b/NEWS index 2078d006fd..ca9973e0a0 100644 --- a/NEWS +++ b/NEWS @@ -216,6 +216,7 @@ where XXXXXX is the bug number as listed below. 338205 configure.ac and check for -Wno-tautological-compare 338445 amd64 vbit-test fails with unknown opcodes used by arm64 VEX 338499 --sim-hints parsing broken due to wrong order in tokens +338615 suppress glibc 2.20 optimized strcmp implementation for ARMv7 n-i-bz Fix KVM_CREATE_IRQCHIP ioctl handling n-i-bz s390x: Fix memory corruption for multithreaded applications n-i-bz vex arm->IR: allow PC as basereg in some LDRD cases diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c index 1fb3df2961..374b796bbc 100644 --- a/coregrind/m_redir.c +++ b/coregrind/m_redir.c @@ -1388,6 +1388,17 @@ void VG_(redir_initialise) ( void ) (Addr)&VG_(arm_linux_REDIR_FOR_memcpy), complain_about_stripped_glibc_ldso ); + /* strcmp */ + add_hardwired_spec( + "ld-linux.so.3", "strcmp", + (Addr)&VG_(arm_linux_REDIR_FOR_strcmp), + complain_about_stripped_glibc_ldso + ); + add_hardwired_spec( + "ld-linux-armhf.so.3", "strcmp", + (Addr)&VG_(arm_linux_REDIR_FOR_strcmp), + complain_about_stripped_glibc_ldso + ); } # elif defined(VGP_arm64_linux) diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index 23941007fa..81a1b1e57a 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -700,6 +700,22 @@ VG_(arm_linux_REDIR_FOR_memcpy): ldmfd sp!, {r4, r5, pc} UD2_4 +.global VG_(arm_linux_REDIR_FOR_strcmp) +VG_(arm_linux_REDIR_FOR_strcmp): +.L64: + ldrb r3, [r0], #1 @ zero_extendqisi2 + ldrb r2, [r1], #1 @ zero_extendqisi2 + cmp r3, #0 + beq .L67 + cmp r3, r2 + beq .L64 + rsb r0, r2, r3 + bx lr +.L67: + rsb r0, r2, #0 + bx lr + UD2_4 + .global VG_(trampoline_stuff_end) VG_(trampoline_stuff_end): diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h index b4c056bd46..51dbc13c73 100644 --- a/coregrind/pub_core_trampoline.h +++ b/coregrind/pub_core_trampoline.h @@ -101,6 +101,7 @@ extern Addr VG_(arm_linux_SUBST_FOR_rt_sigreturn); extern UInt VG_(arm_linux_REDIR_FOR_strlen)( void* ); //extern void* VG_(arm_linux_REDIR_FOR_index) ( void*, Int ); extern void* VG_(arm_linux_REDIR_FOR_memcpy)( void*, void*, Int ); +extern void* VG_(arm_linux_REDIR_FOR_strcmp)( void*, void* ); #endif #if defined(VGP_arm64_linux) -- 2.47.2