]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
This module supplies various replacement functions, amongst them a
authorJulian Seward <jseward@acm.org>
Mon, 27 Aug 2007 10:46:39 +0000 (10:46 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 27 Aug 2007 10:46:39 +0000 (10:46 +0000)
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

coregrind/m_trampoline.S

index daf25dd73a9c5f4c3ab3df0226ece55d8601218f..e2b66a612875019ea9dcad99083e75959a621555 100644 (file)
@@ -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)