|
From: <sv...@va...> - 2011-03-28 08:23:09
|
Author: sewardj
Date: 2011-03-28 09:22:55 +0100 (Mon, 28 Mar 2011)
New Revision: 11668
Log:
Intercept strlen in ld.so on x86. Fixes #266961.
(Jakub Jelinek, ja...@re...)
Modified:
trunk/coregrind/m_redir.c
trunk/coregrind/m_trampoline.S
trunk/coregrind/pub_core_trampoline.h
Modified: trunk/coregrind/m_redir.c
===================================================================
--- trunk/coregrind/m_redir.c 2011-03-26 07:30:39 UTC (rev 11667)
+++ trunk/coregrind/m_redir.c 2011-03-28 08:22:55 UTC (rev 11668)
@@ -924,20 +924,23 @@
/* If we're using memcheck, use this intercept right from the
start, otherwise ld.so (glibc-2.3.5) makes a lot of noise. */
if (0==VG_(strcmp)("Memcheck", VG_(details).name)) {
+ const HChar** mandatory;
+# if defined(GLIBC_2_2) || defined(GLIBC_2_3) || defined(GLIBC_2_4) \
+ || defined(GLIBC_2_5) || defined(GLIBC_2_6) || defined(GLIBC_2_7) \
+ || defined(GLIBC_2_8) || defined(GLIBC_2_9) \
+ || defined(GLIBC_2_10) || defined(GLIBC_2_11)
+ mandatory = NULL;
+# else
+ /* for glibc-2.12 and later, this is mandatory - can't sanely
+ continue without it */
+ mandatory = complain_about_stripped_glibc_ldso;
+# endif
add_hardwired_spec(
"ld-linux.so.2", "index",
- (Addr)&VG_(x86_linux_REDIR_FOR_index),
-# if defined(GLIBC_2_2) || defined(GLIBC_2_3) || defined(GLIBC_2_4) \
- || defined(GLIBC_2_5) || defined(GLIBC_2_6) || defined(GLIBC_2_7) \
- || defined(GLIBC_2_8) || defined(GLIBC_2_9) \
- || defined(GLIBC_2_10) || defined(GLIBC_2_11)
- NULL
-# else
- /* for glibc-2.12 and later, this is mandatory - can't sanely
- continue without it */
- complain_about_stripped_glibc_ldso
-# endif
- );
+ (Addr)&VG_(x86_linux_REDIR_FOR_index), mandatory);
+ add_hardwired_spec(
+ "ld-linux.so.2", "strlen",
+ (Addr)&VG_(x86_linux_REDIR_FOR_strlen), mandatory);
}
# elif defined(VGP_amd64_linux)
Modified: trunk/coregrind/m_trampoline.S
===================================================================
--- trunk/coregrind/m_trampoline.S 2011-03-26 07:30:39 UTC (rev 11667)
+++ trunk/coregrind/m_trampoline.S 2011-03-28 08:22:55 UTC (rev 11668)
@@ -112,6 +112,27 @@
ret
.size VG_(x86_linux_REDIR_FOR_index), .-VG_(x86_linux_REDIR_FOR_index)
+/* There's no particular reason that this needs to be handwritten
+ assembly, but since that's what this file contains, here's a
+ simple strlen implementation (written in C and compiled by gcc.)
+*/
+.global VG_(x86_linux_REDIR_FOR_strlen)
+.type VG_(x86_linux_REDIR_FOR_strlen), @function
+VG_(x86_linux_REDIR_FOR_strlen):
+ pushl %ebp
+ movl %esp, %ebp
+ movl 8(%ebp), %edx
+ movl %edx, %eax
+ jmp 2f
+1: incl %eax
+2: cmpb $0, (%eax)
+ jne 1b
+ subl %edx, %eax
+ popl %ebp
+ ret
+.size VG_(x86_linux_REDIR_FOR_strlen), .-VG_(x86_linux_REDIR_FOR_strlen)
+
+
.global VG_(trampoline_stuff_end)
VG_(trampoline_stuff_end):
Modified: trunk/coregrind/pub_core_trampoline.h
===================================================================
--- trunk/coregrind/pub_core_trampoline.h 2011-03-26 07:30:39 UTC (rev 11667)
+++ trunk/coregrind/pub_core_trampoline.h 2011-03-28 08:22:55 UTC (rev 11668)
@@ -60,6 +60,7 @@
extern Addr VG_(x86_linux_SUBST_FOR_sigreturn);
extern Addr VG_(x86_linux_SUBST_FOR_rt_sigreturn);
extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
+extern UInt VG_(x86_linux_REDIR_FOR_strlen)( void* );
#endif
#if defined(VGP_amd64_linux)
|