3.11.0-15 - Add valgrind-3.11.0-amd64-ld-index.patch

This commit is contained in:
Mark Wielaard 2016-02-24 12:15:29 +01:00
parent a4376859c5
commit 51122acc43
2 changed files with 99 additions and 2 deletions

View File

@ -0,0 +1,92 @@
commit b39a5966a9e64d343b65d7678e4759aed6860bec
Author: mjw <mjw@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Date: Wed Feb 24 11:12:01 2016 +0000
Bug 359733 amd64 implement ld.so strchr/index override like x86
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c
index dcf1fb4..dae47f1 100644
--- a/coregrind/m_redir.c
+++ b/coregrind/m_redir.c
@@ -1353,6 +1353,9 @@ void VG_(redir_initialise) ( void )
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),
# ifndef GLIBC_MANDATORY_STRLEN_REDIRECT
diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S
index cac2288..176ea66 100644
--- a/coregrind/m_trampoline.S
+++ b/coregrind/m_trampoline.S
@@ -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
diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h
index eda5ec6..1396519 100644
--- a/coregrind/pub_core_trampoline.h
+++ b/coregrind/pub_core_trampoline.h
@@ -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)
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index 005b679..8de085a 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -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)

View File

@ -3,7 +3,7 @@
Summary: Tool for finding memory management bugs in programs Summary: Tool for finding memory management bugs in programs
Name: %{?scl_prefix}valgrind Name: %{?scl_prefix}valgrind
Version: 3.11.0 Version: 3.11.0
Release: 14%{?dist} Release: 15%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
URL: http://www.valgrind.org/ URL: http://www.valgrind.org/
@ -111,6 +111,9 @@ Patch20: valgrind-3.11.0-s390x-popcnt.patch
# KDE#359703 s390: wire up separate socketcalls system calls # KDE#359703 s390: wire up separate socketcalls system calls
Patch21: valgrind-3.11.0-s390-separate-socketcalls.patch Patch21: valgrind-3.11.0-s390-separate-socketcalls.patch
# KDE#359733 amd64 implement ld.so strchr/index override like x86
Patch22: valgrind-3.11.0-amd64-ld-index.patch
%if %{build_multilib} %if %{build_multilib}
# Ensure glibc{,-devel} is installed for both multilib arches # Ensure glibc{,-devel} is installed for both multilib arches
BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so
@ -236,6 +239,7 @@ Valgrind User Manual for details.
%patch19 -p1 %patch19 -p1
%patch20 -p1 %patch20 -p1
%patch21 -p1 %patch21 -p1
%patch22 -p1
%build %build
# We need to use the software collection compiler and binutils if available. # We need to use the software collection compiler and binutils if available.
@ -428,8 +432,9 @@ echo ===============END TESTING===============
%endif %endif
%changelog %changelog
* Tue Feb 23 2016 Mark Wielaard <mjw@redhat.com> * Wed Feb 24 2016 Mark Wielaard <mjw@redhat.com> - 3.11.0-15
- Add valgrind-3.11.0-s390-separate-socketcalls.patch - Add valgrind-3.11.0-s390-separate-socketcalls.patch
- Add valgrind-3.11.0-amd64-ld-index.patch
* Thu Feb 18 2016 Mark Wielaard <mjw@redhat.com> - 3.11.0-14 * Thu Feb 18 2016 Mark Wielaard <mjw@redhat.com> - 3.11.0-14
- Update valgrind-3.11.0-futex.patch (fix helgrind/drd regression). - Update valgrind-3.11.0-futex.patch (fix helgrind/drd regression).