]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
add_hardwired_spec for ld-linux-x86-64.so.2 strcmp
authorFlorian Weimer <fweimer@redhat.com>
Sun, 14 Apr 2024 19:56:03 +0000 (21:56 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 14 Apr 2024 20:07:17 +0000 (22:07 +0200)
glibc built with -march=x86-64-v3 does not work due to ld.so strcmp

https://bugs.kde.org/show_bug.cgi?id=485487

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

diff --git a/NEWS b/NEWS
index 8f5ac0c9c80d181cb0f47534c1da4001e0a58687..665e03f5fd9465c9046ad8eb0309f92c98b1d95b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -91,6 +91,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
         uninitialised value" errors for aarch64 signal handlers
 485148  vfmadd213ss instruction is instrumented incorrectly (the remaining
         part of the register is cleared instead of kept unmodified)
+485487  glibc built with -march=x86-64-v3 does not work due to ld.so strcmp
 n-i-bz  Add redirect for memccpy
 
 To see details of a given bug, visit
index cef241b4f85aad235b336a5a0a9c96bd32bf470d..ce6073a62190a639e1651834730e77c5893cf0bb 100644 (file)
@@ -1410,6 +1410,15 @@ void VG_(redir_initialise) ( void )
          complain_about_stripped_glibc_ldso
 #        endif
       );   
+      add_hardwired_spec(
+         "ld-linux-x86-64.so.2", "strcmp",
+         (Addr)&VG_(amd64_linux_REDIR_FOR_strcmp),
+#        ifndef GLIBC_MANDATORY_STRLEN_REDIRECT
+         NULL
+#        else
+         complain_about_stripped_glibc_ldso
+#        endif
+      );
    }
 
 #  elif defined(VGP_ppc32_linux)
index da96972323824bdbc9d3a91799428127c557a274..716afb2121b84b5786cebcbf838cf5ac865e4fef 100644 (file)
@@ -218,6 +218,29 @@ VG_(amd64_linux_REDIR_FOR_strlen):
 .LfnE5:
 .size VG_(amd64_linux_REDIR_FOR_strlen), .-VG_(amd64_linux_REDIR_FOR_strlen)
 
+/* There's no particular reason that this needs to be handwritten
+   assembly, but since that's what this file contains, here's a
+   simple strcmp.)
+*/
+.global VG_(amd64_linux_REDIR_FOR_strcmp)
+.type   VG_(amd64_linux_REDIR_FOR_strcmp), @function
+VG_(amd64_linux_REDIR_FOR_strcmp):
+       xorl    %ecx, %ecx
+1:
+       movzbl  (%rdi, %rcx), %eax
+       movzbl  (%rsi, %rcx), %edx
+       testb   %al, %al
+       jne     2f
+       movl    %edx, %eax
+       negl    %eax
+       ret
+2:
+       incq    %rcx
+       subl    %edx, %eax
+       je      1b
+       ret
+.size VG_(amd64_linux_REDIR_FOR_strcmp), .-VG_(amd64_linux_REDIR_FOR_strcmp)
+
 .global VG_(amd64_linux_REDIR_FOR_index)
 .type   VG_(amd64_linux_REDIR_FOR_index), @function
 VG_(amd64_linux_REDIR_FOR_index):
index 54c575a7233a9451aca8acc03f370ceeb29182fc..dd660131c582427bc4b4034421091b65ee678b70 100644 (file)
@@ -77,6 +77,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 Int VG_(amd64_linux_REDIR_FOR_strcmp)( void*, void* );
 extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
 #endif