From: Julian Seward Date: Mon, 27 Aug 2007 10:46:39 +0000 (+0000) Subject: This module supplies various replacement functions, amongst them a X-Git-Tag: svn/VALGRIND_3_3_0~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f44a25e14134b991a9ea1e562e9349ff342d12a5;p=thirdparty%2Fvalgrind.git This module supplies various replacement functions, amongst them a replacement for index/strchr in ld.so. Unfortunately the replacement functionality was actually rindex/strrchr and amazingly it has taken about 2.5 years for anyone to notice. This fixes the x86-linux case; ppc32-linux and ppc64-linux fixes to follow. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6783 --- diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index daf25dd73a..e2b66a6128 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -84,12 +84,11 @@ VG_(x86_linux_SUBST_FOR_rt_sigreturn): unsigned char* REDIR_FOR_index ( const char* s, int c ) { - unsigned char ch = (unsigned char)((unsigned int)c); - unsigned char* p = (unsigned char*)s; - unsigned char* last = 0; + unsigned char ch = (unsigned char)((unsigned int)c); + unsigned char* p = (unsigned char*)s; while (1) { - if (*p == ch) last = p; - if (*p == 0) return last; + if (*p == ch) return p; + if (*p == 0) return 0; p++; } } @@ -99,23 +98,22 @@ VG_(x86_linux_SUBST_FOR_rt_sigreturn): VG_(x86_linux_REDIR_FOR_index): pushl %ebp movl %esp, %ebp - pushl %ebx - movb 12(%ebp), %al - movl 8(%ebp), %ecx - movl $0, %ebx -.L2: - movb (%ecx), %dl - cmpb %dl, %al - jne .L3 - movl %ecx, %ebx -.L3: - testb %dl, %dl - je .L8 - addl $1, %ecx + movl 8(%ebp), %eax + movzbl 12(%ebp), %ecx + movzbl (%eax), %edx + cmpb %dl, %cl + jne .L9 jmp .L2 -.L8: - movl %ebx, %eax - popl %ebx +.L11: + addl $1, %eax + movzbl (%eax), %edx + cmpb %dl, %cl + je .L2 +.L9: + testb %dl, %dl + jne .L11 + xorl %eax, %eax +.L2: popl %ebp ret .size VG_(x86_linux_REDIR_FOR_index), .-VG_(x86_linux_REDIR_FOR_index)