From dad279b80c1da4fb2c842cca9783ad0e49339ddc Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sun, 14 Apr 2024 21:56:03 +0200 Subject: [PATCH] add_hardwired_spec for ld-linux-x86-64.so.2 strcmp 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 | 1 + coregrind/m_redir.c | 9 +++++++++ coregrind/m_trampoline.S | 23 +++++++++++++++++++++++ coregrind/pub_core_trampoline.h | 1 + 4 files changed, 34 insertions(+) diff --git a/NEWS b/NEWS index 8f5ac0c9c..665e03f5f 100644 --- 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 diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c index cef241b4f..ce6073a62 100644 --- a/coregrind/m_redir.c +++ b/coregrind/m_redir.c @@ -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) diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index da9697232..716afb212 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -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): diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h index 54c575a72..dd660131c 100644 --- a/coregrind/pub_core_trampoline.h +++ b/coregrind/pub_core_trampoline.h @@ -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 -- 2.11.4.GIT