|
From: <sv...@va...> - 2009-07-02 13:13:20
|
Author: tom
Date: 2009-07-02 14:02:12 +0100 (Thu, 02 Jul 2009)
New Revision: 10402
Log:
Replace strlen on amd64-linux with a simple version that doesn't
generate false positives.
Patch from Jakub Jelinek <ja...@re...>. Fixes #190429.
Modified:
trunk/coregrind/m_redir.c
trunk/coregrind/m_trampoline.S
trunk/coregrind/pub_core_trampoline.h
Modified: trunk/coregrind/m_redir.c
===================================================================
--- trunk/coregrind/m_redir.c 2009-07-02 12:36:53 UTC (rev 10401)
+++ trunk/coregrind/m_redir.c 2009-07-02 13:02:12 UTC (rev 10402)
@@ -879,6 +879,20 @@
(Addr)&VG_(amd64_linux_REDIR_FOR_vtime)
);
+ /* If we're using memcheck, use these intercepts right from
+ the start, otherwise ld.so makes a lot of noise. */
+ if (0==VG_(strcmp)("Memcheck", VG_(details).name)) {
+
+ static const HChar croakage[]
+ = "Possible fix: install glibc's debuginfo package on this machine.";
+
+ /* this is mandatory - can't sanely continue without it */
+ add_hardwired_spec(
+ "ld-linux-x86-64.so.2", "strlen",
+ (Addr)&VG_(amd64_linux_REDIR_FOR_strlen),
+ croakage
+ );
+ }
# elif defined(VGP_ppc32_linux)
{
static const HChar croakage[]
Modified: trunk/coregrind/m_trampoline.S
===================================================================
--- trunk/coregrind/m_trampoline.S 2009-07-02 12:36:53 UTC (rev 10401)
+++ trunk/coregrind/m_trampoline.S 2009-07-02 13:02:12 UTC (rev 10402)
@@ -168,7 +168,29 @@
.LfnE3:
.size VG_(amd64_linux_REDIR_FOR_vtime), .-.LfnB3
-/* A CIE for the above two functions, followed by their FDEs */
+/* There's no particular reason that this needs to be handwritten
+ assembly, but since that's what this file contains, here's a
+ simple strlen implementation (written in C and compiled by gcc.)
+*/
+.global VG_(amd64_linux_REDIR_FOR_strlen)
+.type VG_(amd64_linux_REDIR_FOR_strlen), @function
+VG_(amd64_linux_REDIR_FOR_strlen):
+.LfnB4:
+ xorl %eax, %eax
+ cmpb $0, (%rdi)
+ movq %rdi, %rdx
+ je .L41
+.L40: addq $1, %rdx
+ cmpb $0, (%rdx)
+ jne .L40
+ movq %rdx, %rax
+ subq %rdi, %rax
+.L41: ret
+.LfnE4:
+.size VG_(amd64_linux_REDIR_FOR_strlen), .-VG_(amd64_linux_REDIR_FOR_strlen)
+
+
+/* A CIE for the above three functions, followed by their FDEs */
.section .eh_frame,"a",@progbits
.Lframe1:
.long .LEcie1-.LScie1
@@ -206,6 +228,15 @@
.uleb128 0x0
.align 8
.LEfde3:
+.LSfde4:
+ .long .LEfde4-.LASfde4
+.LASfde4:
+ .long .LASfde4-.Lframe1
+ .long .LfnB4
+ .long .LfnE4-.LfnB4
+ .uleb128 0x0
+ .align 8
+.LEfde4:
.previous
.global VG_(trampoline_stuff_end)
Modified: trunk/coregrind/pub_core_trampoline.h
===================================================================
--- trunk/coregrind/pub_core_trampoline.h 2009-07-02 12:36:53 UTC (rev 10401)
+++ trunk/coregrind/pub_core_trampoline.h 2009-07-02 13:02:12 UTC (rev 10402)
@@ -66,6 +66,7 @@
extern void VG_(amd64_linux_SUBST_FOR_rt_sigreturn);
extern void VG_(amd64_linux_REDIR_FOR_vgettimeofday);
extern void VG_(amd64_linux_REDIR_FOR_vtime);
+extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
#endif
#if defined(VGP_ppc32_linux)
|
|
From: Julian S. <js...@ac...> - 2009-07-02 16:40:50
|
On Thursday 02 July 2009, sv...@va... wrote: > Author: tom > Date: 2009-07-02 14:02:12 +0100 (Thu, 02 Jul 2009) > New Revision: 10402 > > Log: > Replace strlen on amd64-linux with a simple version that doesn't > generate false positives. > > Patch from Jakub Jelinek <ja...@re...>. Fixes #190429. Unfortunately causes memcheck to be completely unusable on openSUSE 11.0, since there's no such symbol. I'll investigate. [I suspected that this patch would have that effect, which is why I didn't merge it. But I should have said so on the bug report, true.] J |