Resolves: #RHEL-82799 valgrind: ld.so memcmp interceptor required on x86_64 - 0015-ppc-test_dfp2-build-fix-for-GCC-15.patch - 0016-syswrap-generic-Emit-pp_ExeContext-after-the-file-de.patch - 0017-add_hardwired_spec-for-ld-linux-x86-64.so.2-memcmp.patch - 0018-gdbserver_tests-filter-out-new-Missing-rpms-message.patch
102 lines
3.3 KiB
Diff
102 lines
3.3 KiB
Diff
From 2c17a8a3e865816ee48e7f78148bbc7240c2a38c Mon Sep 17 00:00:00 2001
|
|
From: Mark Wielaard <mark@klomp.org>
|
|
Date: Wed, 12 Mar 2025 13:57:19 +0100
|
|
Subject: [PATCH 17/18] add_hardwired_spec for ld-linux-x86-64.so.2 memcmp
|
|
|
|
With RPATH processing ld.so compiled for x86-64-v3 uses an optimized
|
|
avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads
|
|
of size 32 warnings.
|
|
|
|
Fix this my adding a hardwire spec with a simpler memcmp for
|
|
ld-linux-x86-64.so.2.
|
|
|
|
https://bugs.kde.org/show_bug.cgi?id=501348
|
|
|
|
Authored-by: Florian Weimer <fweimer@redhat.com>
|
|
|
|
(cherry picked from commit 9ffdeb4927b8505cc5a9ea54f608f4972166bb0e)
|
|
---
|
|
NEWS | 1 +
|
|
coregrind/m_redir.c | 9 +++++++++
|
|
coregrind/m_trampoline.S | 19 +++++++++++++++++++
|
|
coregrind/pub_core_trampoline.h | 1 +
|
|
4 files changed, 30 insertions(+)
|
|
|
|
diff --git a/NEWS b/NEWS
|
|
index 7f9e005c59f4..fe225c666c77 100644
|
|
--- a/NEWS
|
|
+++ b/NEWS
|
|
@@ -11,6 +11,7 @@ The following bugs have been fixed or resolved on this branch.
|
|
498317 FdBadUse is not a valid CoreError type in a suppression
|
|
even though it's generated by --gen-suppressions=yes
|
|
498143 False positive on EVIOCGRAB ioctl
|
|
+501348 glibc built with -march=x86-64-v3 does not work due to ld.so memcmp
|
|
|
|
To see details of a given bug, visit
|
|
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
|
|
diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c
|
|
index f9e8d8801a19..64ebea3b6304 100644
|
|
--- a/coregrind/m_redir.c
|
|
+++ b/coregrind/m_redir.c
|
|
@@ -1425,6 +1425,15 @@ void VG_(redir_initialise) ( void )
|
|
NULL
|
|
# else
|
|
complain_about_stripped_glibc_ldso
|
|
+# endif
|
|
+ );
|
|
+ add_hardwired_spec(
|
|
+ "ld-linux-x86-64.so.2", "memcmp",
|
|
+ (Addr)&VG_(amd64_linux_REDIR_FOR_memcmp),
|
|
+# ifndef GLIBC_MANDATORY_STRLEN_REDIRECT
|
|
+ NULL
|
|
+# else
|
|
+ complain_about_stripped_glibc_ldso
|
|
# endif
|
|
);
|
|
}
|
|
diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S
|
|
index e897963be21a..27f1b35d2b08 100644
|
|
--- a/coregrind/m_trampoline.S
|
|
+++ b/coregrind/m_trampoline.S
|
|
@@ -241,6 +241,25 @@ VG_(amd64_linux_REDIR_FOR_strcmp):
|
|
ret
|
|
.size VG_(amd64_linux_REDIR_FOR_strcmp), .-VG_(amd64_linux_REDIR_FOR_strcmp)
|
|
|
|
+.global VG_(amd64_linux_REDIR_FOR_memcmp)
|
|
+.type VG_(amd64_linux_REDIR_FOR_memcmp), @function
|
|
+VG_(amd64_linux_REDIR_FOR_memcmp):
|
|
+ xorl %ecx, %ecx
|
|
+ jmp 2f
|
|
+1:
|
|
+ movzbl (%rdi, %rcx), %eax
|
|
+ movzbl (%rsi, %rcx), %r8d
|
|
+ addq $1, %rcx
|
|
+ subl %r8d, %eax
|
|
+ jne 3f
|
|
+2:
|
|
+ cmpq %rcx, %rdx
|
|
+ jne 1b
|
|
+ xorl %eax, %eax
|
|
+3:
|
|
+ ret
|
|
+.size VG_(amd64_linux_REDIR_FOR_memcmp), .-VG_(amd64_linux_REDIR_FOR_memcmp)
|
|
+
|
|
.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 d0bd6b859742..3d2f7e9f32b7 100644
|
|
--- a/coregrind/pub_core_trampoline.h
|
|
+++ b/coregrind/pub_core_trampoline.h
|
|
@@ -82,6 +82,7 @@ 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 Int VG_(amd64_linux_REDIR_FOR_memcmp)( void*, void*, SizeT );
|
|
extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
|
|
#endif
|
|
|
|
--
|
|
2.48.1
|
|
|