]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 359733 amd64 implement ld.so strchr/index override like x86
authorMark Wielaard <mark@klomp.org>
Wed, 24 Feb 2016 11:12:01 +0000 (11:12 +0000)
committerMark Wielaard <mark@klomp.org>
Wed, 24 Feb 2016 11:12:01 +0000 (11:12 +0000)
The suppression and redirection for ld.so strchr/index isn't needed for
x86. When testing a newer glibc or calling the ld.so through an alternative
path neither the suppression (doesn't match path/name) nor the redirection
(triggers too late) works. Since there is already an hardwire override for
strlen in amd64 ld.so anyway it makes sense to also hardware index (it is
always called when ld.so loads the preload images).

This was also explained in the easy hacks Fosdem session.
See https://bugs.kde.org/show_bug.cgi?id=359733 for a pointer.

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

NEWS
coregrind/m_redir.c
coregrind/m_trampoline.S
coregrind/pub_core_trampoline.h
shared/vg_replace_strmem.c

diff --git a/NEWS b/NEWS
index 9d4ed1ace01330f45c12c7ab1d68ba3dd1cc9b5c..a851aa48e91b921e40ea9fa01d80dd6370b86c67 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,7 @@ where XXXXXX is the bug number as listed below.
 359472  The Power PC vsubuqm instruction doesn't always give the correct result
 359703  s390: wire up separate socketcalls system calls
 359724  getsockname might crash - deref_UInt should call safe_to_deref
+359733  amd64 implement ld.so strchr/index override like x86
 
 n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 and amd64
 n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap
index dcf1fb45ff0cb1bc89809a93242a83bb1375624a..dae47f1804f71a13cad980415492d9eea1a58707 100644 (file)
@@ -1352,6 +1352,9 @@ void VG_(redir_initialise) ( void )
       the start, otherwise ld.so makes a lot of noise. */
    if (0==VG_(strcmp)("Memcheck", VG_(details).name)) {
 
+      add_hardwired_spec(
+         "ld-linux-x86-64.so.2", "index",
+         (Addr)&VG_(amd64_linux_REDIR_FOR_index), NULL);
       add_hardwired_spec(
          "ld-linux-x86-64.so.2", "strlen",
          (Addr)&VG_(amd64_linux_REDIR_FOR_strlen),
index cac22889962b5a45b009a1fef6ca719cdf516957..176ea6693c88ae47fdffa0c833e23e4e29cfa9d2 100644 (file)
@@ -220,6 +220,30 @@ VG_(amd64_linux_REDIR_FOR_strlen):
 .LfnE5:
 .size VG_(amd64_linux_REDIR_FOR_strlen), .-VG_(amd64_linux_REDIR_FOR_strlen)
 
+.global VG_(amd64_linux_REDIR_FOR_index)
+.type   VG_(amd64_linux_REDIR_FOR_index), @function
+VG_(amd64_linux_REDIR_FOR_index):
+        movzbl  (%rdi), %eax
+        movl    %esi, %edx
+        cmpb    %sil, %al
+        jne     .L4
+        jmp     .L5
+.L10:
+        addq    $1, %rdi
+        movzbl  (%rdi), %eax
+        cmpb    %dl, %al
+        je      .L5
+.L4:
+        testb   %al, %al
+        jne     .L10
+        xorl    %eax, %eax
+        ret
+.L5:
+        movq    %rdi, %rax
+        ret
+.size VG_(amd64_linux_REDIR_FOR_index), .-VG_(amd64_linux_REDIR_FOR_index)
+
+
 
 /* A CIE for the above four functions, followed by their FDEs */
        .section .eh_frame,"a",@progbits
index eda5ec65eac95a454726233202edd2731dbca665..1396519e891b80a3ec1e025da3f0d77ae1c19bdd 100644 (file)
@@ -71,6 +71,7 @@ extern Addr VG_(amd64_linux_REDIR_FOR_vgettimeofday);
 extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
 extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
 extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
+extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
 #endif
 
 #if defined(VGP_ppc32_linux)
index 005b6795a1839aef7dd2b313e3d54bc34c96f27c..8de085a57bcec79f0b90f25f66c37dd193f61ab8 100644 (file)
@@ -247,7 +247,7 @@ static inline void my_exit ( int x )
  STRCHR(VG_Z_LIBC_SONAME,          __strchr_sse2)
  STRCHR(VG_Z_LIBC_SONAME,          __strchr_sse2_no_bsf)
  STRCHR(VG_Z_LIBC_SONAME,          index)
-# if !defined(VGP_x86_linux)
+# if !defined(VGP_x86_linux) && !defined(VGP_amd64_linux)
   STRCHR(VG_Z_LD_LINUX_SO_2,        strchr)
   STRCHR(VG_Z_LD_LINUX_SO_2,        index)
   STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr)