]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
As with ppc it's necessary to have an initial redirect for index(strchr)
authorJulian Seward <jseward@acm.org>
Sun, 20 Nov 2005 19:37:54 +0000 (19:37 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 20 Nov 2005 19:37:54 +0000 (19:37 +0000)
on x86 glibc-2.3.5.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5223

coregrind/m_redir.c
coregrind/m_trampoline.S
coregrind/pub_core_trampoline.h

index 5d8056dd172b638900bc63db48663875b149fe6e..56a89e499d4db70c870a697318a73cbca63e1874 100644 (file)
@@ -160,7 +160,11 @@ static void add_redir_to_resolved_list(CodeRedirect *redir, Bool need_discard)
          TRACE_REDIR("  redir %s:%s:%p->%p duplicated\n",
                      redir->from_lib, redir->from_sym, redir->from_addr,
                      redir->to_addr);
-         VG_(arena_free)(VG_AR_SYMTAB, redir);
+         // jrs 20 Nov 05: causes this: m_mallocfree.c:170
+         // (mk_plain_bszB): Assertion 'bszB != 0' failed.
+         // Perhaps it is an invalid free?  Disable for now
+         // XXX leak?
+         //VG_(arena_free)(VG_AR_SYMTAB, redir);
       }
       break;
    }
@@ -362,6 +366,14 @@ void VG_(setup_code_redirect_table) ( void )
       "soname:ld-linux.so.2", "_dl_sysinfo_int80",
       (Addr)&VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80)
    );
+   /* 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)) {
+      add_redirect_sym_to_addr(
+         "soname:ld-linux.so.2", "index",
+         (Addr)&VG_(x86_linux_REDIR_FOR_index)
+      );   
+   }
 
 #elif defined(VGP_amd64_linux)
 
index 54a6a76d6a8307b8c23b053a3df2ccb529e45f8b..e4930f9702364cae0a0c2028d2031ac049cffe7b 100644 (file)
@@ -73,7 +73,49 @@ VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80):
        /* We can point our sysinfo stuff here */
        int     $0x80
        ret
-       
+
+/* There's no particular reason that this needs to be handwritten
+   assembly, but since that's what this file contains, here's a
+   simple index implementation (written in C and compiled by gcc.)
+
+   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; 
+      while (1) { 
+         if (*p == ch) last = p; 
+         if (*p == 0) return last; 
+         p++; 
+      } 
+   }
+*/
+.global VG_(x86_linux_REDIR_FOR_index)
+.type   VG_(x86_linux_REDIR_FOR_index), @function
+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
+        jmp     .L2
+.L8:
+        movl    %ebx, %eax
+        popl    %ebx
+        popl    %ebp
+        ret
+.size VG_(x86_linux_REDIR_FOR_index), .-VG_(x86_linux_REDIR_FOR_index)
+
 .global VG_(trampoline_stuff_end)
 VG_(trampoline_stuff_end):
 
index 95f58d4bffb36c688bf55c994803be652d8bd30c..68e1f7a3d354b7b4a8353a324cde325a96a8512a 100644 (file)
@@ -51,6 +51,7 @@ extern void VG_(trampoline_stuff_end);
 extern void VG_(x86_linux_SUBST_FOR_sigreturn);
 extern void VG_(x86_linux_SUBST_FOR_rt_sigreturn);
 extern void VG_(x86_linux_REDIR_FOR__dl_sysinfo_int80);
+extern Char* VG_(x86_linux_REDIR_FOR_index) ( const Char*, Int );
 #endif
 
 #if defined(VGP_amd64_linux)