From c26fba590e460951d4bc21fd4dcc4bed54f39d92 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 23 Jul 2022 11:40:25 +0000 Subject: [PATCH 01/86] Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- valgrind.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index 9f65414..f69b91c 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.19.0 -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -459,6 +459,9 @@ fi %endif %changelog +* Sat Jul 23 2022 Fedora Release Engineering - 1:3.19.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Wed May 25 2022 Mark Wielaard - 3.19.0-3 - Add valgrind-3.19.0-s390x-memmem.patch From abb597e9d87a8f703daab782e297eff0aad8d5be Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 24 Oct 2022 22:43:27 +0200 Subject: [PATCH 02/86] 3.20.0-1 - Upgrade to valgrind 3.20.0. Drop old patches. --- .gitignore | 1 + sources | 2 +- valgrind-3.19.0-ld-so-strncmp.patch | 25 --- valgrind-3.19.0-s390x-memmem.patch | 231 ---------------------------- valgrind.spec | 18 +-- 5 files changed, 7 insertions(+), 270 deletions(-) delete mode 100644 valgrind-3.19.0-ld-so-strncmp.patch delete mode 100644 valgrind-3.19.0-s390x-memmem.patch diff --git a/.gitignore b/.gitignore index cbec41e..b20bb48 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ /valgrind-3.18.0.RC1.tar.bz2 /valgrind-3.18.1.tar.bz2 /valgrind-3.19.0.tar.bz2 +/valgrind-3.20.0.tar.bz2 diff --git a/sources b/sources index e93a40c..0ba4c2a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.19.0.tar.bz2) = f720a89dc4c4989cc5714bff9efe97529f71990bcfad7a92b889ce099c4326d6da07fa4d5fbab2e9125e20f352354f6178471e49e419b613a3c82c2a1c667ab2 +SHA512 (valgrind-3.20.0.tar.bz2) = d6bfb9284d0410134ee7e2a5975b13c01508dd5587b562947d8197b3c113b76fdfac88c4072948be68bbf0dbeb17b4d1acb1412ce898adaa83c30ae2c6a1c12b diff --git a/valgrind-3.19.0-ld-so-strncmp.patch b/valgrind-3.19.0-ld-so-strncmp.patch deleted file mode 100644 index 91007ef..0000000 --- a/valgrind-3.19.0-ld-so-strncmp.patch +++ /dev/null @@ -1,25 +0,0 @@ -commit 947388eb043ea1c44b37df94046e1eee790ad776 -Author: Mike Crowe -Date: Mon Sep 9 14:16:16 2019 +0100 - - Intercept strncmp for glibc ld.so v2.28+ - - In glibc 5aad5f617892e75d91d4c8fb7594ff35b610c042 (first released in - v2.28) a call to strncmp was added to dl-load.c:is_dst. This causes - valgrind to complain about glibc's highly-optimised strncmp performing - sixteen-byte reads on short strings in ld.so. Let's intercept strncmp in - ld.so too so we use valgrind's simple version to avoid this problem. - -diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c -index 3b42b3a87..5396e83be 100644 ---- a/shared/vg_replace_strmem.c -+++ b/shared/vg_replace_strmem.c -@@ -710,6 +710,8 @@ static inline void my_exit ( int x ) - STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp) - STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse2) - STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse42) -+ STRNCMP(VG_Z_LD_LINUX_SO_2, strncmp) -+ STRNCMP(VG_Z_LD_LINUX_X86_64_SO_2, strncmp) - - #elif defined(VGO_freebsd) - STRNCMP(VG_Z_LIBC_SONAME, strncmp) diff --git a/valgrind-3.19.0-s390x-memmem.patch b/valgrind-3.19.0-s390x-memmem.patch deleted file mode 100644 index 669b78e..0000000 --- a/valgrind-3.19.0-s390x-memmem.patch +++ /dev/null @@ -1,231 +0,0 @@ -From 42ca1c480a5bca408a54c6a24d2be2c081d121ac Mon Sep 17 00:00:00 2001 -From: Andreas Arnez -Date: Thu, 19 May 2022 13:54:06 +0200 -Subject: [PATCH] Bug 454040 - Add intercept for memmem on s390x - -Since memcheck may report false positives in an optimized version of memmem on -s390x, add an intercept for memmem on s390x platforms. ---- - shared/vg_replace_strmem.c | 36 ++++++++++++++++++++++++++++++++++++ - 1 file changed, 36 insertions(+) - -diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c -index 5396e83be..d28e74206 100644 ---- a/shared/vg_replace_strmem.c -+++ b/shared/vg_replace_strmem.c -@@ -103,6 +103,7 @@ - 20430 WMEMCHR - 20440 WCSNLEN - 20450 WSTRNCMP -+ 20460 MEMMEM - */ - - #if defined(VGO_solaris) -@@ -1785,6 +1786,41 @@ static inline void my_exit ( int x ) - - #endif - -+/*---------------------- memmem ----------------------*/ -+ -+#define MEMMEM(soname, fnname) \ -+ void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \ -+ (const void* haystack, SizeT hlen, const void* needle, SizeT nlen); \ -+ void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \ -+ (const void* haystack, SizeT hlen, const void* needle, SizeT nlen) \ -+ { \ -+ const HChar* h = haystack; \ -+ const HChar* n = needle; \ -+ \ -+ /* If the needle is the empty string, match immediately. */ \ -+ if (nlen == 0) return CONST_CAST(void *,h); \ -+ \ -+ HChar n0 = n[0]; \ -+ \ -+ for (; hlen >= nlen; hlen--, h++) { \ -+ if (h[0] != n0) continue; \ -+ \ -+ UWord i; \ -+ for (i = 1; i < nlen; i++) { \ -+ if (n[i] != h[i]) \ -+ break; \ -+ } \ -+ if (i == nlen) \ -+ return CONST_CAST(HChar *,h); \ -+ \ -+ } \ -+ return NULL; \ -+ } -+ -+#if defined(VGP_s390x_linux) -+ MEMMEM(VG_Z_LIBC_SONAME, memmem) -+#endif -+ - - /*---------------------- strpbrk ----------------------*/ - --- -2.31.1 - -From 4d675f309bcd2d4e9e2b9e6f4aba30f85116bb9b Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Thu, 19 May 2022 18:08:40 -0400 -Subject: [PATCH] Add memmem memcheck tests - ---- - memcheck/tests/Makefile.am | 3 ++ - memcheck/tests/filter_memmem | 5 ++ - memcheck/tests/memmem.c | 81 ++++++++++++++++++++++++++++++++ - memcheck/tests/memmem.stderr.exp | 2 + - memcheck/tests/memmem.vgtest | 3 ++ - 5 files changed, 94 insertions(+) - create mode 100755 memcheck/tests/filter_memmem - create mode 100644 memcheck/tests/memmem.c - create mode 100644 memcheck/tests/memmem.stderr.exp - create mode 100644 memcheck/tests/memmem.vgtest - -diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am -index eb9487272..4d181c1ac 100644 ---- a/memcheck/tests/Makefile.am -+++ b/memcheck/tests/Makefile.am -@@ -79,6 +79,7 @@ dist_noinst_SCRIPTS = \ - filter_strchr \ - filter_varinfo3 \ - filter_memcheck \ -+ filter_memmem \ - filter_overlaperror \ - filter_malloc_free \ - filter_sized_delete -@@ -220,6 +221,7 @@ EXTRA_DIST = \ - memalign2.stderr.exp memalign2.vgtest \ - memcmptest.stderr.exp memcmptest.stderr.exp2 \ - memcmptest.stdout.exp memcmptest.vgtest \ -+ memmem.stderr.exp memmem.vgtest \ - mempool.stderr.exp mempool.vgtest \ - mempool2.stderr.exp mempool2.vgtest \ - metadata.stderr.exp metadata.stdout.exp metadata.vgtest \ -@@ -417,6 +419,7 @@ check_PROGRAMS = \ - malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \ - match-overrun \ - memalign_test memalign2 memcmptest mempool mempool2 mmaptest \ -+ memmem \ - mismatches new_override metadata \ - nanoleak_supp nanoleak2 new_nothrow \ - noisy_child \ -diff --git a/memcheck/tests/filter_memmem b/memcheck/tests/filter_memmem -new file mode 100755 -index 000000000..f4a40b2d1 ---- /dev/null -+++ b/memcheck/tests/filter_memmem -@@ -0,0 +1,5 @@ -+#! /bin/sh -+ -+# Too many memmem implementations and overrides. -+# So just keep the main file lines. -+./filter_stderr "$@" | grep " main (memmem.c:" -diff --git a/memcheck/tests/memmem.c b/memcheck/tests/memmem.c -new file mode 100644 -index 000000000..d627076e3 ---- /dev/null -+++ b/memcheck/tests/memmem.c -@@ -0,0 +1,81 @@ -+#define _GNU_SOURCE -+#include -+#include -+#include -+ -+/* mallocs an mem block and fills it with A. A needs to be a zero -+ terminated string. The A string chars, minus the terminating zero -+ are copied into the returned mem block. */ -+static void * -+create_mem (const char *a) -+{ -+ size_t len = strlen (a); -+ void *mem = malloc (len); -+ memcpy (mem, a, len); -+ return mem; -+} -+ -+int -+main () -+{ -+ char *haystack; -+ char *needle; -+ -+ haystack = create_mem ("a"); -+ needle = create_mem ("a"); -+ assert (memmem (haystack, 0, needle, 0) == haystack); -+ assert (memmem (haystack, 1, needle, 0) == haystack); -+ assert (memmem (haystack, 0, needle, 1) == NULL); -+ assert (memmem (haystack, 1, needle, 1) == haystack); -+ free (haystack); -+ free (needle); -+ -+ haystack = create_mem ("abc"); -+ needle = create_mem ("bc"); -+ assert (memmem (haystack, 3, needle, 0) == haystack); -+ assert (memmem (haystack, 3, needle, 2) == haystack + 1); -+ assert (memmem (haystack + 1, 2, needle, 2) == haystack + 1); -+ assert (memmem (haystack + 2, 1, needle, 2) == NULL); -+ free (haystack); -+ free (needle); -+ -+ haystack = create_mem ("abcabcabc"); -+ needle = create_mem ("bca"); -+ assert (memmem (haystack, 9, needle, 3) == haystack + 1); -+ free (haystack); -+ free (needle); -+ -+ haystack = create_mem ("abcabcabc"); -+ needle = create_mem ("bcad"); -+ assert (memmem (haystack, 9, needle, 4) == NULL); -+ free (haystack); -+ free (needle); -+ -+ haystack = create_mem ("xxxxxxxxxxxxxxxxxABC"); -+ needle = create_mem ("ABCD"); -+ assert (memmem (haystack, 20, needle, 2) == haystack + 17); -+ assert (memmem (haystack + 3, 17, needle, 2) == haystack + 17); -+ assert (memmem (haystack + 15, 5, needle, 2) == haystack + 17); -+ assert (memmem (haystack, 20, needle, 3) == haystack + 17); -+ assert (memmem (haystack + 3, 17, needle, 3) == haystack + 17); -+ assert (memmem (haystack + 15, 5, needle, 3) == haystack + 17); -+ assert (memmem (haystack, 20, needle, 4) == NULL); -+ assert (memmem (haystack + 3, 5, needle, 4) == NULL); -+ assert (memmem (haystack + 15, 5, needle, 4) == NULL); -+ free (haystack); -+ free (needle); -+ -+ haystack = malloc (1); -+ needle = create_mem ("a"); -+ assert (memmem (haystack, 1, needle, 1) == NULL); -+ free (haystack); -+ free (needle); -+ -+ haystack = create_mem ("A"); -+ needle = malloc (1); -+ assert (memmem (haystack, 1, needle, 1) == NULL); -+ free (haystack); -+ free (needle); -+ -+ return 0; -+} -diff --git a/memcheck/tests/memmem.stderr.exp b/memcheck/tests/memmem.stderr.exp -new file mode 100644 -index 000000000..b4612fbd4 ---- /dev/null -+++ b/memcheck/tests/memmem.stderr.exp -@@ -0,0 +1,2 @@ -+ by 0x........: main (memmem.c:70) -+ by 0x........: main (memmem.c:76) -diff --git a/memcheck/tests/memmem.vgtest b/memcheck/tests/memmem.vgtest -new file mode 100644 -index 000000000..6d12895df ---- /dev/null -+++ b/memcheck/tests/memmem.vgtest -@@ -0,0 +1,3 @@ -+prog: memmem -+vgopts: -q -+stderr_filter: filter_memmem --- -2.18.4 - diff --git a/valgrind.spec b/valgrind.spec index f69b91c..7a4f63b 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -2,14 +2,12 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind -Version: 3.19.0 -Release: 4%{?dist} +Version: 3.20.0 +Release: 1%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ -# Only necessary for RHEL, will be ignored on Fedora - # Are we building for a Software Collection? %{?scl:%global is_scl 1} %{!?scl:%global is_scl 0} @@ -85,12 +83,6 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch -# KDE#434764 # iconv_open causes ld.so v2.28+ to execute optimised strncmp -Patch5: valgrind-3.19.0-ld-so-strncmp.patch - -# KDE#454040 s390x: False-positive memcheck:cond in memmem on arch13 systems -Patch6: valgrind-3.19.0-s390x-memmem.patch - BuildRequires: make BuildRequires: glibc-devel @@ -228,9 +220,6 @@ Valgrind User Manual for details. %patch4 -p1 %endif -%patch5 -p1 -%patch6 -p1 - %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -459,6 +448,9 @@ fi %endif %changelog +* Mon Oct 24 2022 Mark Wielaard - 3.20.0-1 +- Upgrade to valgrind 3.20.0. Drop old patches. + * Sat Jul 23 2022 Fedora Release Engineering - 1:3.19.0-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild From d38884287b673917c51d2e9f84a3aa725894f6eb Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 18 Nov 2022 19:55:54 +0100 Subject: [PATCH 03/86] Avoid using implicit int C89 feature Related to: --- valgrind-faultstatus-implicit-int.patch | 17 +++++++++++++++++ valgrind.spec | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 valgrind-faultstatus-implicit-int.patch diff --git a/valgrind-faultstatus-implicit-int.patch b/valgrind-faultstatus-implicit-int.patch new file mode 100644 index 0000000..d91a69b --- /dev/null +++ b/valgrind-faultstatus-implicit-int.patch @@ -0,0 +1,17 @@ +Add the missing int, to avoid a compilation failure in strict C99 mode. + +Submitted upstream: + +diff --git a/none/tests/faultstatus.c b/none/tests/faultstatus.c +index 458ea8264593af4e..92a8350ab2285092 100644 +--- a/none/tests/faultstatus.c ++++ b/none/tests/faultstatus.c +@@ -190,7 +190,7 @@ int main() + return 0; + } + +-static volatile s_zero; ++static volatile int s_zero; + + static int zero() + { diff --git a/valgrind.spec b/valgrind.spec index 7a4f63b..bbaab71 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.20.0 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -83,6 +83,8 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch +Patch5: valgrind-faultstatus-implicit-int.patch + BuildRequires: make BuildRequires: glibc-devel @@ -218,6 +220,7 @@ Valgrind User Manual for details. %if 0%{?fedora} || 0%{?rhel} >= 7 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %endif %build @@ -448,6 +451,9 @@ fi %endif %changelog +* Fri Nov 18 2022 Florian Weimer - 1:3.20.0-2 +- Avoid using implicit int C89 feature + * Mon Oct 24 2022 Mark Wielaard - 3.20.0-1 - Upgrade to valgrind 3.20.0. Drop old patches. From 068f90a1103e523bf4513b9ea53f9d1c27f90eb7 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 21 Jan 2023 06:05:56 +0000 Subject: [PATCH 04/86] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- valgrind.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index bbaab71..753134d 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.20.0 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -451,6 +451,9 @@ fi %endif %changelog +* Sat Jan 21 2023 Fedora Release Engineering - 1:3.20.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + * Fri Nov 18 2022 Florian Weimer - 1:3.20.0-2 - Avoid using implicit int C89 feature From a1bab0364cbca03ddbb9eba67334f88c6445bd8b Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 21 Apr 2023 16:07:39 +0200 Subject: [PATCH 05/86] 3.21.0-0.1.RC1 --- .gitignore | 1 + sources | 2 +- valgrind-3.16.0-some-Wl-z-now.patch | 13 ------------- valgrind-3.16.0-some-stack-protector.patch | 13 ------------- valgrind-faultstatus-implicit-int.patch | 17 ----------------- valgrind.spec | 18 +++++++++--------- 6 files changed, 11 insertions(+), 53 deletions(-) delete mode 100644 valgrind-faultstatus-implicit-int.patch diff --git a/.gitignore b/.gitignore index b20bb48..2b388f1 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ /valgrind-3.18.1.tar.bz2 /valgrind-3.19.0.tar.bz2 /valgrind-3.20.0.tar.bz2 +/valgrind-3.21.0.RC1.tar.bz2 diff --git a/sources b/sources index 0ba4c2a..3e00af5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.20.0.tar.bz2) = d6bfb9284d0410134ee7e2a5975b13c01508dd5587b562947d8197b3c113b76fdfac88c4072948be68bbf0dbeb17b4d1acb1412ce898adaa83c30ae2c6a1c12b +SHA512 (valgrind-3.21.0.RC1.tar.bz2) = 7c2a3ea34969a94ce221043007f14c7e5d40387dc2e44e28bdede59188a2d4b171e5ea4ce7c761007348bffe4e99265817dedd8cc932e8b94f5055786b418b58 diff --git a/valgrind-3.16.0-some-Wl-z-now.patch b/valgrind-3.16.0-some-Wl-z-now.patch index 79c3662..6231733 100644 --- a/valgrind-3.16.0-some-Wl-z-now.patch +++ b/valgrind-3.16.0-some-Wl-z-now.patch @@ -35,19 +35,6 @@ index 1b7842b..e211eec 100644 if HAVE_DLINFO_RTLD_DI_TLS_MODID getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = $(LDADD) -ldl endif -diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am -index f572741..1c07e50 100644 ---- a/cachegrind/Makefile.am -+++ b/cachegrind/Makefile.am -@@ -27,7 +27,7 @@ cg_merge_SOURCES = cg_merge.c - cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI) - cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong - cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI) --cg_merge_LDFLAGS = $(AM_CFLAGS_PRI) -+cg_merge_LDFLAGS = $(AM_CFLAGS_PRI) -Wl,-z,now - # If there is no secondary platform, and the platforms include x86-darwin, - # then the primary platform must be x86-darwin. Hence: - if ! VGCONF_HAVE_PLATFORM_SEC diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 3c73210..fb6b7bb 100644 --- a/coregrind/Makefile.am diff --git a/valgrind-3.16.0-some-stack-protector.patch b/valgrind-3.16.0-some-stack-protector.patch index 324c7d3..b53c465 100644 --- a/valgrind-3.16.0-some-stack-protector.patch +++ b/valgrind-3.16.0-some-stack-protector.patch @@ -35,19 +35,6 @@ index 56cc5ef..1b7842b 100644 getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CCASFLAGS = $(AM_CCASFLAGS_PRI) getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ if HAVE_DLINFO_RTLD_DI_TLS_MODID -diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am -index f8447a1..f572741 100644 ---- a/cachegrind/Makefile.am -+++ b/cachegrind/Makefile.am -@@ -25,7 +25,7 @@ bin_PROGRAMS = cg_merge - - cg_merge_SOURCES = cg_merge.c - cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI) --cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -+cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong - cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI) - cg_merge_LDFLAGS = $(AM_CFLAGS_PRI) - # If there is no secondary platform, and the platforms include x86-darwin, diff --git a/configure.ac b/configure.ac index f8c798b..ccc8f52 100755 --- a/configure.ac diff --git a/valgrind-faultstatus-implicit-int.patch b/valgrind-faultstatus-implicit-int.patch deleted file mode 100644 index d91a69b..0000000 --- a/valgrind-faultstatus-implicit-int.patch +++ /dev/null @@ -1,17 +0,0 @@ -Add the missing int, to avoid a compilation failure in strict C99 mode. - -Submitted upstream: - -diff --git a/none/tests/faultstatus.c b/none/tests/faultstatus.c -index 458ea8264593af4e..92a8350ab2285092 100644 ---- a/none/tests/faultstatus.c -+++ b/none/tests/faultstatus.c -@@ -190,7 +190,7 @@ int main() - return 0; - } - --static volatile s_zero; -+static volatile int s_zero; - - static int zero() - { diff --git a/valgrind.spec b/valgrind.spec index 753134d..6fbbe76 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -2,8 +2,8 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind -Version: 3.20.0 -Release: 3%{?dist} +Version: 3.21.0 +Release: 0.1.RC1%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -69,7 +69,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -83,8 +83,6 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch -Patch5: valgrind-faultstatus-implicit-int.patch - BuildRequires: make BuildRequires: glibc-devel @@ -211,7 +209,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 %patch1 -p1 %patch2 -p1 @@ -220,7 +218,6 @@ Valgrind User Manual for details. %if 0%{?fedora} || 0%{?rhel} >= 7 %patch3 -p1 %patch4 -p1 -%patch5 -p1 %endif %build @@ -451,8 +448,11 @@ fi %endif %changelog -* Sat Jan 21 2023 Fedora Release Engineering - 1:3.20.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild +* Fri Apr 21 2022 Mark Wielaard - 3.21.0-0.1.RC1 +- Upstream 3.21.0-RC1 +- Remove upstreamed valgrind-faultstatus-implicit-int.patch +- Adjust valgrind-3.16.0-some-{Wl-z-now,stack-protector}.patch + cg_merge is now a pything script. * Fri Nov 18 2022 Florian Weimer - 1:3.20.0-2 - Avoid using implicit int C89 feature From d8356c1fd874dd7b62336961c60013e12718874e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 21 Apr 2023 16:20:40 +0200 Subject: [PATCH 06/86] Fix changelog date --- valgrind.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index 6fbbe76..d906ebc 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -448,7 +448,7 @@ fi %endif %changelog -* Fri Apr 21 2022 Mark Wielaard - 3.21.0-0.1.RC1 +* Fri Apr 21 2023 Mark Wielaard - 3.21.0-0.1.RC1 - Upstream 3.21.0-RC1 - Remove upstreamed valgrind-faultstatus-implicit-int.patch - Adjust valgrind-3.16.0-some-{Wl-z-now,stack-protector}.patch From 3ae60e7ef775157031abc548fa4210fb5e8e88eb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 22 Apr 2023 20:03:04 +0200 Subject: [PATCH 07/86] Upstream 3.21.0-RC2 --- .gitignore | 1 + sources | 2 +- valgrind.spec | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2b388f1..710e60d 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ /valgrind-3.19.0.tar.bz2 /valgrind-3.20.0.tar.bz2 /valgrind-3.21.0.RC1.tar.bz2 +/valgrind-3.21.0.RC2.tar.bz2 diff --git a/sources b/sources index 3e00af5..5ff7d52 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.21.0.RC1.tar.bz2) = 7c2a3ea34969a94ce221043007f14c7e5d40387dc2e44e28bdede59188a2d4b171e5ea4ce7c761007348bffe4e99265817dedd8cc932e8b94f5055786b418b58 +SHA512 (valgrind-3.21.0.RC2.tar.bz2) = 950f6fafdf49585cade5d7676343158e8fa22d246c657236c8adc33335c1d6bd1b4906099b5969a3484a8261eac1b8dda3183fb98edfc10afd7c07cd3ad493fb diff --git a/valgrind.spec b/valgrind.spec index d906ebc..9ccd89c 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 0.1.RC1%{?dist} +Release: 0.1.RC2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -69,7 +69,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -209,7 +209,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 %patch1 -p1 %patch2 -p1 @@ -448,6 +448,9 @@ fi %endif %changelog +* Sat Apr 22 2023 Mark Wielaard - 3.21.0-0.1.RC2 +- Upstream 3.21.0-RC2 + * Fri Apr 21 2023 Mark Wielaard - 3.21.0-0.1.RC1 - Upstream 3.21.0-RC1 - Remove upstreamed valgrind-faultstatus-implicit-int.patch From e25ecae115d50d6e904d45e0bd247176e87cde06 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 24 Apr 2023 16:06:05 +0200 Subject: [PATCH 08/86] rpminspect.yaml: Ignore vgpreload libs for debuginfo inspection --- rpminspect.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpminspect.yaml b/rpminspect.yaml index e2816ea..0ebee4b 100644 --- a/rpminspect.yaml +++ b/rpminspect.yaml @@ -36,6 +36,14 @@ annocheck: # for the same reason as the standard tools (see above). - /usr/lib*/valgrind/*-*linux.a +debuginfo: + ignore: + # We add the debuginfo to vgpreload libraries because we want to show the + # user exactly where the issue is, which we cannot without always having + # the symtab around. The vgpreload libraries are really tiny, so it doesn't + # have a big impact on the package size. + - /usr/libexec/valgrind/vgpreload*.so + runpath: allowed_paths: # As described above, libmpiwrap is a wrapper against openmpi From a69d34e2871740c08038143007c0d1c2641f30ed Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 28 Apr 2023 18:14:52 +0200 Subject: [PATCH 09/86] Upstream 3.21.0 final --- .gitignore | 1 + sources | 2 +- valgrind.spec | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 710e60d..85a4432 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ /valgrind-3.20.0.tar.bz2 /valgrind-3.21.0.RC1.tar.bz2 /valgrind-3.21.0.RC2.tar.bz2 +/valgrind-3.21.0.tar.bz2 diff --git a/sources b/sources index 5ff7d52..efed6a2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.21.0.RC2.tar.bz2) = 950f6fafdf49585cade5d7676343158e8fa22d246c657236c8adc33335c1d6bd1b4906099b5969a3484a8261eac1b8dda3183fb98edfc10afd7c07cd3ad493fb +SHA512 (valgrind-3.21.0.tar.bz2) = 3e86cda2f2d6cd30807fac7933ba2c46a97a2b4a868db989e6b0cceeadf029af7ee34ba900466a346948289aacb30f4399799bb83b97cc49a4d2d810441e5cfd diff --git a/valgrind.spec b/valgrind.spec index 9ccd89c..ddc7025 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 0.1.RC2%{?dist} +Release: 1%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -69,7 +69,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -209,7 +209,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} %patch1 -p1 %patch2 -p1 @@ -448,6 +448,9 @@ fi %endif %changelog +* Fri Apr 28 2023 Mark Wielaard - 3.21.0-1 +- Upstream 3.21.0 final + * Sat Apr 22 2023 Mark Wielaard - 3.21.0-0.1.RC2 - Upstream 3.21.0-RC2 From 32d01947a3edab15402a35a712f66d9bad637921 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 5 May 2023 17:41:30 +0200 Subject: [PATCH 10/86] 3.21.0-2 - Add valgrind-3.21.0-no-memcpy-replace-check.patch --- valgrind-3.21.0-no-memcpy-replace-check.patch | 13 +++++++++++++ valgrind.spec | 11 ++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.21.0-no-memcpy-replace-check.patch diff --git a/valgrind-3.21.0-no-memcpy-replace-check.patch b/valgrind-3.21.0-no-memcpy-replace-check.patch new file mode 100644 index 0000000..cdb0c0a --- /dev/null +++ b/valgrind-3.21.0-no-memcpy-replace-check.patch @@ -0,0 +1,13 @@ +diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c +index b32f13f76..aa7f88ca2 100644 +--- a/shared/vg_replace_strmem.c ++++ b/shared/vg_replace_strmem.c +@@ -1128,7 +1128,7 @@ static inline void my_exit ( int x ) + MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0) + + #define MEMCPY(soname, fnname) \ +- MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) ++ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) /* See KDE bug #402833 */ + + #if defined(VGO_linux) + /* For older memcpy we have to use memmove-like semantics and skip diff --git a/valgrind.spec b/valgrind.spec index ddc7025..1b2a9ed 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -83,6 +83,10 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch +# Workaround https://bugs.kde.org/show_bug.cgi?id=402833 +# by disabling overlap checking for memcpy +Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch + BuildRequires: make BuildRequires: glibc-devel @@ -220,6 +224,8 @@ Valgrind User Manual for details. %patch4 -p1 %endif +%patch5 -p1 + %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -448,6 +454,9 @@ fi %endif %changelog +* Fri May 5 2023 Mark Wielaard - 3.21.0-2 +- Add valgrind-3.21.0-no-memcpy-replace-check.patch + * Fri Apr 28 2023 Mark Wielaard - 3.21.0-1 - Upstream 3.21.0 final From 7c6f24f04bbf75f029c35e2be2d72046c29a406e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= Date: Tue, 16 May 2023 12:54:04 +0200 Subject: [PATCH 11/86] 3.21.0-3 - Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch --- valgrind-3.21.0-Add-with-gdbscripts-dir.patch | 123 ++++++++++++++++++ valgrind.spec | 19 ++- 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.21.0-Add-with-gdbscripts-dir.patch diff --git a/valgrind-3.21.0-Add-with-gdbscripts-dir.patch b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch new file mode 100644 index 0000000..5f8b4f9 --- /dev/null +++ b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch @@ -0,0 +1,123 @@ +From e97f7a6cf2315908fb0a9b900f1de87a155c9df1 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sun, 14 May 2023 23:34:05 +0200 +Subject: [PATCH] Add --with-gdbscripts-dir=PATH configure option + +Currently the gdb valgrind scripts are installed under VG_LIBDIR +which is normally pkglibexecdir which is likely not in the default +gdb safe-path (a list of directories from which it is safe to +auto-load files). So users will have to add the directory to their +.gdbinit file. + +This patch adds a --with-gdbscripts-dir=PATH configure option that +sets VG_GDBSCRIPTS_DIR to the given PATH (${libexecdir}/valgrind if +not given). + +Use VG_GDBSCRIPTS_DIR as gdbscriptsdir to install the valgrind-monitor +python files and pass it with CPPFLAGS when building vg_preloaded.c +and vgdb.c to use instead of VG_LIBDIR. +--- + configure.ac | 11 +++++++++++ + coregrind/Makefile.am | 15 ++++++++++----- + coregrind/vg_preloaded.c | 2 +- + coregrind/vgdb.c | 2 +- + 4 files changed, 23 insertions(+), 7 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 15fbf5ea2..223ab4529 100755 +--- a/configure.ac ++++ b/configure.ac +@@ -1198,6 +1198,17 @@ AC_MSG_RESULT([$xcodedir]) + AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory]) + AC_SUBST(XCODE_DIR, [$xcodedir])]) + ++#---------------------------------------------------------------------------- ++# Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir) ++#---------------------------------------------------------------------------- ++AC_MSG_CHECKING([where gdb scripts are installed]) ++AC_ARG_WITH(gdbscripts-dir, ++ [ --with-gdbscripts-dir=PATH Specify path to install gdb scripts], ++ [gdbscriptsdir=${withval}], ++ [gdbscriptsdir=${libexecdir}/valgrind]) ++AC_MSG_RESULT([$gdbscriptsdir]) ++AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir]) ++ + #---------------------------------------------------------------------------- + # Libc and suppressions + #---------------------------------------------------------------------------- +diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am +index 553211782..64d593b08 100644 +--- a/coregrind/Makefile.am ++++ b/coregrind/Makefile.am +@@ -101,7 +101,8 @@ + vgdb_SOURCES += vgdb-invoker-freebsd.c + endif + +-vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) ++vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong + vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI) + vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ -Wl,-z,now +@@ -626,7 +627,8 @@ + + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = \ +- $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) ++ $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS = \ + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@) + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \ +@@ -634,7 +636,8 @@ + if VGCONF_HAVE_PLATFORM_SEC + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = \ +- $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) ++ $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS = \ + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@) + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \ +@@ -766,8 +769,10 @@ + # so as to make sure these get copied into the install tree + vglibdir = $(pkglibexecdir) + vglib_DATA = $(GDBSERVER_XML_FILES) +-vglib_DATA += m_gdbserver/valgrind-monitor.py +-vglib_DATA += m_gdbserver/valgrind-monitor-def.py ++ ++gdbscriptsdir = @VG_GDBSCRIPTS_DIR@ ++gdbscripts_DATA = m_gdbserver/valgrind-monitor.py ++gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py + + # so as to make sure these get copied into the tarball + EXTRA_DIST += $(GDBSERVER_XML_FILES) +diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c +index d6e05898c..bff76b81b 100644 +--- a/coregrind/vg_preloaded.c ++++ b/coregrind/vg_preloaded.c +@@ -61,7 +61,7 @@ + .popsection \n\ + "); + +-DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py") ++DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py") + #endif + + #if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) +diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c +index 8ec424077..a449b86e0 100644 +--- a/coregrind/vgdb.c ++++ b/coregrind/vgdb.c +@@ -1984,7 +1984,7 @@ void usage(void) + " -h --help shows this message\n" + " The GDB python code defining GDB front end valgrind commands is:\n %s\n" + " To get help from the Valgrind gdbserver, use vgdb help\n" +-"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py" ++"\n", vgdb_prefix_default(), VG_GDBSCRIPTS_DIR "/valgrind-monitor.py" + ); + invoker_restrictions_msg(); + } +-- +2.40.0 + diff --git a/valgrind.spec b/valgrind.spec index 1b2a9ed..09b30ff 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -87,6 +87,13 @@ Patch4: valgrind-3.16.0-some-Wl-z-now.patch # by disabling overlap checking for memcpy Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch +# Add --with-gdbscripts-dir=PATH configure option +# https://bugs.kde.org/show_bug.cgi?id=469768 + %patch6 -p1 + + +Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch + BuildRequires: make BuildRequires: glibc-devel @@ -226,6 +233,8 @@ Valgrind User Manual for details. %patch5 -p1 +%patch6 -p1 + %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -294,7 +303,8 @@ export LDFLAGS %configure \ --with-mpicc=%{mpiccpath} \ %{only_arch} \ - GDB=%{_bindir}/gdb + GDB=%{_bindir}/gdb \ + --with-gdbscripts-dir=%{_datadir}/gdb/auto-load %make_build @@ -412,6 +422,8 @@ echo ===============END TESTING=============== # Was disabled in %%install to prevent debuginfo stripping. %attr(0755,root,root) %{_libexecdir}/valgrind/vgpreload*-%{valarch}-*so %{_mandir}/man1/* +%{_datadir}/gdb/auto-load/valgrind-monitor.py +%{_datadir}/gdb/auto-load/valgrind-monitor-def.py %files devel %dir %{_includedir}/valgrind @@ -454,6 +466,9 @@ fi %endif %changelog +* Tue May 16 2023 Alexandra Hájková - 3.21.0-3 +- Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch + * Fri May 5 2023 Mark Wielaard - 3.21.0-2 - Add valgrind-3.21.0-no-memcpy-replace-check.patch From 7baa4ed285bff1b996247d00adb51c7a4a6dd5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= Date: Tue, 16 May 2023 19:15:11 +0200 Subject: [PATCH 12/86] Fix typo in a spec --- valgrind.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index 09b30ff..cc01b92 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -89,9 +89,6 @@ Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch # Add --with-gdbscripts-dir=PATH configure option # https://bugs.kde.org/show_bug.cgi?id=469768 - %patch6 -p1 - - Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch BuildRequires: make From 32e1d63ec37d102390d77c51d7c9cd0989ce7ba0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 17 May 2023 13:27:11 +0200 Subject: [PATCH 13/86] Add valgrind-3.21.0-epoll_pwait2.patch --- valgrind-3.21.0-epoll_pwait2.patch | 217 +++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 valgrind-3.21.0-epoll_pwait2.patch diff --git a/valgrind-3.21.0-epoll_pwait2.patch b/valgrind-3.21.0-epoll_pwait2.patch new file mode 100644 index 0000000..0a5dd67 --- /dev/null +++ b/valgrind-3.21.0-epoll_pwait2.patch @@ -0,0 +1,217 @@ +From 17f56ab4c4fce7b4778251e1fab2bc50e5c6dbda Mon Sep 17 00:00:00 2001 +From: Olli Vanhoja +Date: Mon, 10 Oct 2022 11:44:22 +0200 +Subject: [PATCH] Add epoll_pwait2 + +The only difference between epoll_pwait and epoll_pwait2 is the +timeout argument. For epoll_pwait2 this is a timespec (which is +always 64bit). + +https://bugs.kde.org/show_bug.cgi?id=460192 +--- + NEWS | 1 + + coregrind/m_syswrap/priv_syswrap-linux.h | 1 + + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-linux.c | 23 ++++++++++++++++++++ + coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + + coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + + coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ + include/vki/vki-scnums-shared-linux.h | 2 ++ + 14 files changed, 45 insertions(+) + +diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h +index a73b6247e..7c9decf5a 100644 +--- a/coregrind/m_syswrap/priv_syswrap-linux.h ++++ b/coregrind/m_syswrap/priv_syswrap-linux.h +@@ -105,6 +105,7 @@ DECL_TEMPLATE(linux, sys_epoll_create1); + DECL_TEMPLATE(linux, sys_epoll_ctl); + DECL_TEMPLATE(linux, sys_epoll_wait); + DECL_TEMPLATE(linux, sys_epoll_pwait); ++DECL_TEMPLATE(linux, sys_epoll_pwait2); + DECL_TEMPLATE(linux, sys_eventfd); + DECL_TEMPLATE(linux, sys_eventfd2); + +diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c +index 1aeebd274..008600798 100644 +--- a/coregrind/m_syswrap/syswrap-amd64-linux.c ++++ b/coregrind/m_syswrap/syswrap-amd64-linux.c +@@ -883,6 +883,8 @@ static SyscallTableEntry syscall_table[] = { + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 + }; + +diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c +index bca509589..9a7a1e0d2 100644 +--- a/coregrind/m_syswrap/syswrap-arm-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm-linux.c +@@ -1057,6 +1057,8 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY(__NR_close_range, sys_close_range), // 436 + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 ++ ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + }; + + +diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c +index 953236000..6af7bab83 100644 +--- a/coregrind/m_syswrap/syswrap-arm64-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm64-linux.c +@@ -837,6 +837,8 @@ static SyscallTableEntry syscall_main_table[] = { + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 + }; + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 26f1fbee3..f8621f8f0 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -2165,6 +2165,29 @@ POST(sys_epoll_pwait) + epoll_post_helper (tid, arrghs, status); + } + ++PRE(sys_epoll_pwait2) ++{ ++ *flags |= SfMayBlock; ++ PRINT("sys_epoll_pwait2 ( %ld, %#" FMT_REGWORD "x, %ld, %#" ++ FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ++ SARG1, ARG2, SARG3, ARG4, ARG5, ARG6); ++ PRE_REG_READ6(long, "epoll_pwait2", ++ int, epfd, struct vki_epoll_event *, events, ++ int, maxevents, const struct timespec64 *, timeout, ++ vki_sigset_t *, sigmask, vki_size_t, sigsetsize); ++ /* Assume all (maxevents) events records should be (fully) writable. */ ++ PRE_MEM_WRITE( "epoll_pwait2(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3); ++ /* epoll_pwait2 only supports 64bit timespec. */ ++ if (ARG4) ++ pre_read_timespec64(tid, "epoll_pwait2(timeout)", ARG4); ++ if (ARG5) ++ PRE_MEM_READ( "epoll_pwait2(sigmask)", ARG5, sizeof(vki_sigset_t) ); ++} ++POST(sys_epoll_pwait2) ++{ ++ epoll_post_helper (tid, arrghs, status); ++} ++ + PRE(sys_eventfd) + { + PRINT("sys_eventfd ( %" FMT_REGWORD "u )", ARG1); +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index de27998b3..6268a00dd 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1141,6 +1141,8 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY(__NR_close_range, sys_close_range), // 436 + + LINX_ (__NR_faccessat2, sys_faccessat2), // 439 ++ ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) +diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c +index 67e7c2c2f..6cdf25893 100644 +--- a/coregrind/m_syswrap/syswrap-mips64-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips64-linux.c +@@ -819,6 +819,7 @@ static SyscallTableEntry syscall_main_table[] = { + GENX_ (__NR_clone3, sys_ni_syscall), + LINXY (__NR_close_range, sys_close_range), + LINX_ (__NR_faccessat2, sys_faccessat2), ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), + }; + + SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c +index 9c535c68e..d724cde74 100644 +--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c ++++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c +@@ -828,6 +828,7 @@ static SyscallTableEntry syscall_main_table[] = { + GENX_ (__NR_clone3, sys_ni_syscall), + LINXY (__NR_close_range, sys_close_range), + LINX_ (__NR_faccessat2, sys_faccessat2), ++ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) +diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c +index 12c073027..c0cfef235 100644 +--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c +@@ -1061,6 +1061,8 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_close_range, sys_close_range), // 436 + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 ++ ++ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c +index 3c33d1267..f5976f30c 100644 +--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c +@@ -1030,6 +1030,8 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_close_range, sys_close_range), // 436 + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 ++ ++ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c +index a377cb731..afba154e7 100644 +--- a/coregrind/m_syswrap/syswrap-s390x-linux.c ++++ b/coregrind/m_syswrap/syswrap-s390x-linux.c +@@ -871,6 +871,8 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_close_range, sys_close_range), // 436 + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 ++ ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c +index a9ba15dfe..da4fd8fa2 100644 +--- a/coregrind/m_syswrap/syswrap-x86-linux.c ++++ b/coregrind/m_syswrap/syswrap-x86-linux.c +@@ -1655,6 +1655,8 @@ static SyscallTableEntry syscall_table[] = { + + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + ++ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 + }; + +diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h +index d90cdd312..542382b53 100644 +--- a/include/vki/vki-scnums-shared-linux.h ++++ b/include/vki/vki-scnums-shared-linux.h +@@ -46,6 +46,8 @@ + + #define __NR_faccessat2 439 + ++#define __NR_epoll_pwait2 441 ++ + #define __NR_memfd_secret 447 + + #endif +-- +2.40.1 + From 6f8aeb0d15cc4a6f78ab0ec38b7728245be0102d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 17 May 2023 13:30:49 +0200 Subject: [PATCH 14/86] 3.21.0-4 - Add valgrind-3.21.0-epoll_pwait2.patch --- valgrind.spec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index cc01b92..49652d8 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -91,6 +91,10 @@ Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch # https://bugs.kde.org/show_bug.cgi?id=469768 Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch +# Add epoll_pwait2 +# https://bugs.kde.org/show_bug.cgi?id=460192 +Patch7: valgrind-3.21.0-epoll_pwait2.patch + BuildRequires: make BuildRequires: glibc-devel @@ -229,8 +233,9 @@ Valgrind User Manual for details. %endif %patch5 -p1 - %patch6 -p1 +%patch7 -p1 + %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -463,6 +468,9 @@ fi %endif %changelog +* Wed May 17 2023 Mark Wielaard - 3.21.0-4 +- Add valgrind-3.21.0-epoll_pwait2.patch + * Tue May 16 2023 Alexandra Hájková - 3.21.0-3 - Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch From 0bfc408a6bee5f0e281f5238508d473df0609fae Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 30 May 2023 18:19:52 +0200 Subject: [PATCH 15/86] 3.21.0-5 - Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk) --- valgrind-3.21.0-no-memcpy-replace-check.patch | 11 ++++++++++- valgrind.spec | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/valgrind-3.21.0-no-memcpy-replace-check.patch b/valgrind-3.21.0-no-memcpy-replace-check.patch index cdb0c0a..6e26e04 100644 --- a/valgrind-3.21.0-no-memcpy-replace-check.patch +++ b/valgrind-3.21.0-no-memcpy-replace-check.patch @@ -1,5 +1,5 @@ diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c -index b32f13f76..aa7f88ca2 100644 +index b32f13f76..464e8d4ca 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -1128,7 +1128,7 @@ static inline void my_exit ( int x ) @@ -11,3 +11,12 @@ index b32f13f76..aa7f88ca2 100644 #if defined(VGO_linux) /* For older memcpy we have to use memmove-like semantics and skip +@@ -1714,8 +1714,6 @@ static inline void my_exit ( int x ) + RECORD_COPY(len); \ + if (len == 0) \ + return dst; \ +- if (is_overlap(dst, src, len, len)) \ +- RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ + if ( dst > src ) { \ + d = (HChar *)dst + len - 1; \ + s = (const HChar *)src + len - 1; \ diff --git a/valgrind.spec b/valgrind.spec index 49652d8..72e590c 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 4%{?dist} +Release: 5%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -468,6 +468,9 @@ fi %endif %changelog +* Tue May 30 2023 Mark Wielaard - 3.21.0-5 +- Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk) + * Wed May 17 2023 Mark Wielaard - 3.21.0-4 - Add valgrind-3.21.0-epoll_pwait2.patch From f579fefc7548e1c8b538307faff9907c20e90b3d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 1 Jun 2023 18:23:51 +0200 Subject: [PATCH 16/86] Add valgrind-3.21.0-callgrind_control-no-strict.patch --- valgrind-3.21.0-callgrind_control-no-strict.patch | 12 ++++++++++++ valgrind.spec | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 valgrind-3.21.0-callgrind_control-no-strict.patch diff --git a/valgrind-3.21.0-callgrind_control-no-strict.patch b/valgrind-3.21.0-callgrind_control-no-strict.patch new file mode 100644 index 0000000..2aaecd4 --- /dev/null +++ b/valgrind-3.21.0-callgrind_control-no-strict.patch @@ -0,0 +1,12 @@ +diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in +index 083ffa29f..eb50c16ad 100644 +--- a/callgrind/callgrind_control.in ++++ b/callgrind/callgrind_control.in +@@ -22,7 +22,6 @@ + # You should have received a copy of the GNU General Public License + # along with this program; if not, see . + +-use strict; + use warnings; + + use File::Basename; diff --git a/valgrind.spec b/valgrind.spec index 72e590c..83c2e69 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -95,6 +95,10 @@ Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch # https://bugs.kde.org/show_bug.cgi?id=460192 Patch7: valgrind-3.21.0-epoll_pwait2.patch +# Can't run callgrind_control with valgrind 3.21.0 because of perl errors +# https://bugs.kde.org/show_bug.cgi?id=470121 +Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch + BuildRequires: make BuildRequires: glibc-devel @@ -235,6 +239,7 @@ Valgrind User Manual for details. %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 %build @@ -468,6 +473,9 @@ fi %endif %changelog +* Thu Jun 1 2023 Mark Wielaard +- Add valgrind-3.21.0-callgrind_control-no-strict.patch + * Tue May 30 2023 Mark Wielaard - 3.21.0-5 - Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk) From 446a440b296325ea21dcd72b9909e27dca0138e3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 1 Jun 2023 18:26:07 +0200 Subject: [PATCH 17/86] 3.21.0-6 - Add valgrind-3.21.0-realloc-again.patch --- valgrind-3.21.0-realloc-again.patch | 167 ++++++++++++++++++++++++++++ valgrind.spec | 10 +- 2 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.21.0-realloc-again.patch diff --git a/valgrind-3.21.0-realloc-again.patch b/valgrind-3.21.0-realloc-again.patch new file mode 100644 index 0000000..7501cd2 --- /dev/null +++ b/valgrind-3.21.0-realloc-again.patch @@ -0,0 +1,167 @@ +From b904112d7084227f8d6fab322bc360a8a6240a51 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Thu, 1 Jun 2023 16:10:56 +0200 +Subject: [PATCH] memcheck: Handle Err_ReallocSizeZero in MC_(eq_Error) + +When an realloc size zero error is emitted MC_(eq_Error) is called to +see if the errors can be deduplicated. This crashed since +Err_ReallocSizeZero wasn't handled. Handle it like Err_Free. + +Also add a testcase for this case and test with both +--realloc-zero-bytes-frees=yes and +--realloc-zero-bytes-frees=no. +Which will report a different number of errors. + +https://bugs.kde.org/show_bug.cgi?id=470520 +--- + memcheck/mc_errors.c | 1 + + memcheck/tests/Makefile.am | 7 +++++++ + memcheck/tests/realloc_size_zero_again.c | 15 +++++++++++++++ + .../realloc_size_zero_again_no.stderr.exp | 18 ++++++++++++++++++ + .../realloc_size_zero_again_no.stdout.exp | 0 + .../tests/realloc_size_zero_again_no.vgtest | 2 ++ + .../realloc_size_zero_again_yes.stderr.exp | 18 ++++++++++++++++++ + .../realloc_size_zero_again_yes.stdout.exp | 0 + .../tests/realloc_size_zero_again_yes.vgtest | 2 ++ + 9 files changed, 63 insertions(+) + create mode 100644 memcheck/tests/realloc_size_zero_again.c + create mode 100644 memcheck/tests/realloc_size_zero_again_no.stderr.exp + create mode 100644 memcheck/tests/realloc_size_zero_again_no.stdout.exp + create mode 100644 memcheck/tests/realloc_size_zero_again_no.vgtest + create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stderr.exp + create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stdout.exp + create mode 100644 memcheck/tests/realloc_size_zero_again_yes.vgtest + +diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c +index 00d6ec301..65210a220 100644 +--- a/memcheck/mc_errors.c ++++ b/memcheck/mc_errors.c +@@ -1041,6 +1041,7 @@ Bool MC_(eq_Error) ( VgRes res, const Error* e1, const Error* e2 ) + case Err_IllegalMempool: + case Err_Overlap: + case Err_Cond: ++ case Err_ReallocSizeZero: + return True; + + case Err_FishyValue: +diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am +index 71c38acba..5a17fd35d 100644 +--- a/memcheck/tests/Makefile.am ++++ b/memcheck/tests/Makefile.am +@@ -291,8 +291,14 @@ EXTRA_DIST = \ + realloc_size_zero.vgtest \ + realloc_size_zero_yes.stderr.exp realloc_size_zero_yes.stdout.exp \ + realloc_size_zero_yes.vgtest \ ++ realloc_size_zero_again_yes.stderr.exp \ ++ realloc_size_zero_again_yes.stdout.exp \ ++ realloc_size_zero_again_yes.vgtest \ + realloc_size_zero_no.stderr.exp realloc_size_zero_no.stdout.exp \ + realloc_size_zero_no.vgtest \ ++ realloc_size_zero_again_no.stderr.exp \ ++ realloc_size_zero_again_no.stdout.exp \ ++ realloc_size_zero_again_no.vgtest \ + realloc_size_zero_off.stderr.exp realloc_size_zero_off.stdout.exp \ + realloc_size_zero_off.vgtest \ + realloc_size_zero_mismatch.stderr.exp \ +@@ -459,6 +465,7 @@ check_PROGRAMS = \ + posix_memalign \ + post-syscall \ + realloc_size_zero realloc_size_zero_mismatch \ ++ realloc_size_zero_again \ + realloc1 realloc2 realloc3 \ + recursive-merge \ + resvn_stack \ +diff --git a/memcheck/tests/realloc_size_zero_again.c b/memcheck/tests/realloc_size_zero_again.c +new file mode 100644 +index 000000000..782d4bde5 +--- /dev/null ++++ b/memcheck/tests/realloc_size_zero_again.c +@@ -0,0 +1,15 @@ ++#include ++ ++int ++main () ++{ ++ char *p = malloc (1024); ++ for (int i = 3; i >= 0; i--) ++ for (int j = 0; j <= 3; j++) ++ { ++ char *q = realloc (p, i * j * 512); ++ p = q; ++ } ++ ++ free (p); ++} +diff --git a/memcheck/tests/realloc_size_zero_again_no.stderr.exp b/memcheck/tests/realloc_size_zero_again_no.stderr.exp +new file mode 100644 +index 000000000..b9c061d1a +--- /dev/null ++++ b/memcheck/tests/realloc_size_zero_again_no.stderr.exp +@@ -0,0 +1,18 @@ ++realloc() with size 0 ++ at 0x........: realloc (vg_replace_malloc.c:...) ++ ... ++ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd ++ at 0x........: malloc (vg_replace_malloc.c:...) ++ ... ++ ++ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0) ++ ++7 errors in context 1 of 1: ++realloc() with size 0 ++ at 0x........: realloc (vg_replace_malloc.c:...) ++ ... ++ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd ++ at 0x........: malloc (vg_replace_malloc.c:...) ++ ... ++ ++ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0) +diff --git a/memcheck/tests/realloc_size_zero_again_no.stdout.exp b/memcheck/tests/realloc_size_zero_again_no.stdout.exp +new file mode 100644 +index 000000000..e69de29bb +diff --git a/memcheck/tests/realloc_size_zero_again_no.vgtest b/memcheck/tests/realloc_size_zero_again_no.vgtest +new file mode 100644 +index 000000000..f1757b6c1 +--- /dev/null ++++ b/memcheck/tests/realloc_size_zero_again_no.vgtest +@@ -0,0 +1,2 @@ ++prog: realloc_size_zero_again ++vgopts: -q -s --realloc-zero-bytes-frees=no +diff --git a/memcheck/tests/realloc_size_zero_again_yes.stderr.exp b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp +new file mode 100644 +index 000000000..d40aa2455 +--- /dev/null ++++ b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp +@@ -0,0 +1,18 @@ ++realloc() with size 0 ++ at 0x........: realloc (vg_replace_malloc.c:...) ++ ... ++ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd ++ at 0x........: malloc (vg_replace_malloc.c:...) ++ ... ++ ++ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0) ++ ++5 errors in context 1 of 1: ++realloc() with size 0 ++ at 0x........: realloc (vg_replace_malloc.c:...) ++ ... ++ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd ++ at 0x........: malloc (vg_replace_malloc.c:...) ++ ... ++ ++ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0) +diff --git a/memcheck/tests/realloc_size_zero_again_yes.stdout.exp b/memcheck/tests/realloc_size_zero_again_yes.stdout.exp +new file mode 100644 +index 000000000..e69de29bb +diff --git a/memcheck/tests/realloc_size_zero_again_yes.vgtest b/memcheck/tests/realloc_size_zero_again_yes.vgtest +new file mode 100644 +index 000000000..215392ed6 +--- /dev/null ++++ b/memcheck/tests/realloc_size_zero_again_yes.vgtest +@@ -0,0 +1,2 @@ ++prog: realloc_size_zero_again ++vgopts: -q -s --realloc-zero-bytes-frees=yes +-- +2.40.1 + diff --git a/valgrind.spec b/valgrind.spec index 83c2e69..1d247d8 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 5%{?dist} +Release: 6%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -99,6 +99,10 @@ Patch7: valgrind-3.21.0-epoll_pwait2.patch # https://bugs.kde.org/show_bug.cgi?id=470121 Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch +# Multiple realloc zero errors crash in MC_(eq_Error) +# https://bugs.kde.org/show_bug.cgi?id=470520 +Patch9: valgrind-3.21.0-realloc-again.patch + BuildRequires: make BuildRequires: glibc-devel @@ -240,6 +244,7 @@ Valgrind User Manual for details. %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 %build @@ -473,8 +478,9 @@ fi %endif %changelog -* Thu Jun 1 2023 Mark Wielaard +* Thu Jun 1 2023 Mark Wielaard - 3.21.0-6 - Add valgrind-3.21.0-callgrind_control-no-strict.patch +- Add valgrind-3.21.0-realloc-again.patch * Tue May 30 2023 Mark Wielaard - 3.21.0-5 - Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk) From f4018eb5a636428100cf472c0d570abc101f81c2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 22 Jun 2023 18:47:52 +0200 Subject: [PATCH 18/86] Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch --- valgrind-3.21.0-vgm-tests.patch | 105 ++++++++++++++++++++++++++++++++ valgrind-3.21.0-vgm.patch | 99 ++++++++++++++++++++++++++++++ valgrind.spec | 10 +++ 3 files changed, 214 insertions(+) create mode 100644 valgrind-3.21.0-vgm-tests.patch create mode 100644 valgrind-3.21.0-vgm.patch diff --git a/valgrind-3.21.0-vgm-tests.patch b/valgrind-3.21.0-vgm-tests.patch new file mode 100644 index 0000000..8fa7712 --- /dev/null +++ b/valgrind-3.21.0-vgm-tests.patch @@ -0,0 +1,105 @@ +From 21f7a2af2805a02a144c81f12895c134f4a171a3 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Mon, 22 May 2023 19:49:08 +0200 +Subject: [PATCH 2/2] Bug 470132 - s390x: Increase test coverage for VGM + +Add more tests for the VGM instruction, to verify the fix for the VGM +wrap-around case. Also test setting unused bits in the I2 and I3 fields, +to check that Valgrind ignores them as it should. +--- + none/tests/s390x/vec2.c | 44 ++++++++++++++++++++++++++++++++ + none/tests/s390x/vec2.stdout.exp | 20 +++++++++++++++ + 2 files changed, 64 insertions(+) + +diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c +index 73b04dee4..c473a2a9a 100644 +--- a/none/tests/s390x/vec2.c ++++ b/none/tests/s390x/vec2.c +@@ -301,6 +301,49 @@ static void test_all_fp_int_conversions() + #undef TEST_EXEC + #undef TEST_GENERATE + ++/* -- Vector generate mask -- */ ++ ++#define TEST_GENERATE(insn, i2, i3, m4) \ ++ static void test_vgm_##i2##_##i3##_##m4(void) \ ++ { \ ++ ulong_v out = vec_ini; \ ++ __asm__("vgm %[out]," #i2 "," #i3 "," #m4 : [out] "+v"(out) : :); \ ++ printf("\t%016lx %016lx\n", out[0], out[1]); \ ++ } ++ ++#define TEST_EXEC(insn, i2, i3, m4) \ ++ do { \ ++ puts(#insn " " #i2 "," #i3 "," #m4); \ ++ test_vgm_##i2##_##i3##_##m4(); \ ++ } while (0) ++ ++#define INSNS \ ++ XTEST(vgmb, 2, 1, 0); \ ++ XTEST(vgmb, 0xf7, 0x30, 0); \ ++ XTEST(vgmb, 0, 0, 0); \ ++ XTEST(vgmh, 3, 2, 1); \ ++ XTEST(vgmh, 15, 15, 1); \ ++ XTEST(vgmf, 4, 3, 2); \ ++ XTEST(vgmf, 16, 17, 2); \ ++ XTEST(vgmg, 55, 63, 3); \ ++ XTEST(vgmg, 43, 55, 3); \ ++ XTEST(vgmg, 63, 2, 3); ++ ++#define XTEST TEST_GENERATE ++INSNS ++#undef XTEST ++ ++static void test_all_generate_mask() ++{ ++#define XTEST TEST_EXEC ++ INSNS ++#undef XTEST ++} ++ ++#undef INSNS ++#undef TEST_EXEC ++#undef TEST_GENERATE ++ + + int main() + { +@@ -310,5 +353,6 @@ int main() + test_all_double_bitshifts(); + test_all_int_fp_conversions(); + test_all_fp_int_conversions(); ++ test_all_generate_mask(); + return 0; + } +diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp +index b32cbe1bc..2c9ac21c1 100644 +--- a/none/tests/s390x/vec2.stdout.exp ++++ b/none/tests/s390x/vec2.stdout.exp +@@ -166,3 +166,23 @@ vcsfp 0 + vcsfp 8 + 00ffffff - - - + 00000004 - - - ++vgmb 2,1,0 ++ ffffffffffffffff ffffffffffffffff ++vgmb 0xf7,0x30,0 ++ 8181818181818181 8181818181818181 ++vgmb 0,0,0 ++ 8080808080808080 8080808080808080 ++vgmh 3,2,1 ++ ffffffffffffffff ffffffffffffffff ++vgmh 15,15,1 ++ 0001000100010001 0001000100010001 ++vgmf 4,3,2 ++ ffffffffffffffff ffffffffffffffff ++vgmf 16,17,2 ++ 0000c0000000c000 0000c0000000c000 ++vgmg 55,63,3 ++ 00000000000001ff 00000000000001ff ++vgmg 43,55,3 ++ 00000000001fff00 00000000001fff00 ++vgmg 63,2,3 ++ e000000000000001 e000000000000001 +-- +2.40.1 + diff --git a/valgrind-3.21.0-vgm.patch b/valgrind-3.21.0-vgm.patch new file mode 100644 index 0000000..422035f --- /dev/null +++ b/valgrind-3.21.0-vgm.patch @@ -0,0 +1,99 @@ +From 70ef4417837b690755feede0088331a28b102c65 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Mon, 22 May 2023 18:57:35 +0200 +Subject: [PATCH 1/2] Bug 470132 - s390x: Fix the wrap-around case in VGM + +Valgrind's implementation of VGM is incomplete: + +* It doesn't support generating a wrap-around bit mask. Such a mask + should result when the ending bit position is smaller than the starting + bit position. Valgrind runs into an assertion failure instead. + +* It doesn't ignore unused bits in the I2 and I3 fields of the + instruction, as it should. + +Fix this by re-implementing the main logic in s390_irgen_VGM(). +--- + VEX/priv/guest_s390_toIR.c | 57 +++++++++++++++----------------------- + 1 file changed, 22 insertions(+), 35 deletions(-) + +diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c +index 11dda41ef..d9d746c38 100644 +--- a/VEX/priv/guest_s390_toIR.c ++++ b/VEX/priv/guest_s390_toIR.c +@@ -16388,50 +16388,37 @@ s390_irgen_VGBM(UChar v1, UShort i2, UChar m3 __attribute__((unused))) + static const HChar * + s390_irgen_VGM(UChar v1, UShort i2, UChar m3) + { +- UChar from = (i2 & 0xff00) >> 8; +- UChar to = (i2 & 0x00ff); +- ULong value = 0UL; +- IRType type = s390_vr_get_type(m3); +- vassert(from <= to); +- +- UChar maxIndex = 0; +- switch (type) { +- case Ity_I8: +- maxIndex = 7; +- break; +- case Ity_I16: +- maxIndex = 15; +- break; +- case Ity_I32: +- maxIndex = 31; +- break; +- case Ity_I64: +- maxIndex = 63; +- break; +- default: +- vpanic("s390_irgen_VGM: unknown type"); +- } +- +- for(UChar index = from; index <= to; index++) { +- value |= (1ULL << (maxIndex - index)); +- } +- +- IRExpr *fillValue; +- switch (type) { +- case Ity_I8: ++ s390_insn_assert("vgm", m3 <= 3); ++ ++ UChar max_idx = (8 << m3) - 1; ++ UChar from = max_idx & (i2 >> 8); ++ UChar to = max_idx & i2; ++ ULong all_one = (1ULL << max_idx << 1) - 1; ++ ULong value = (all_one >> from) ^ (all_one >> to >> 1); ++ ++ /* In case of wrap-around we now have a value that needs inverting: ++ to from ++ V V ++ 00000111111111110000000000000000 */ ++ if (to < from) ++ value ^= all_one; ++ ++ IRExpr* fillValue; ++ switch (m3) { ++ case 0: + fillValue = mkU8(value); + break; +- case Ity_I16: ++ case 1: + fillValue = mkU16(value); + break; +- case Ity_I32: ++ case 2: + fillValue = mkU32(value); + break; +- case Ity_I64: ++ case 3: + fillValue = mkU64(value); + break; + default: +- vpanic("s390_irgen_VGM: unknown type"); ++ vpanic("s390_irgen_VGM: unknown element size"); + } + + s390_vr_fill(v1, fillValue); +-- +2.40.1 + diff --git a/valgrind.spec b/valgrind.spec index 1d247d8..4db5319 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -103,6 +103,11 @@ Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch # https://bugs.kde.org/show_bug.cgi?id=470520 Patch9: valgrind-3.21.0-realloc-again.patch +# s390x: Assertion failure on VGM instruction +# https://bugs.kde.org/show_bug.cgi?id=470132 +Patch10: valgrind-3.21.0-vgm.patch +Patch11: valgrind-3.21.0-vgm-tests.patch + BuildRequires: make BuildRequires: glibc-devel @@ -245,6 +250,8 @@ Valgrind User Manual for details. %patch7 -p1 %patch8 -p1 %patch9 -p1 +%patch10 -p1 +%patch11 -p1 %build @@ -478,6 +485,9 @@ fi %endif %changelog +* Thu Jun 22 2023 Mark Wielaard +- Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch + * Thu Jun 1 2023 Mark Wielaard - 3.21.0-6 - Add valgrind-3.21.0-callgrind_control-no-strict.patch - Add valgrind-3.21.0-realloc-again.patch From ff531b85fd73bb3177c6a36f1e1b654913ebf641 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 22 Jun 2023 18:53:12 +0200 Subject: [PATCH 19/86] 3.21.0-7 - Add valgrind-3.21.0-pgste.patch --- valgrind-3.21.0-pgste.patch | 73 +++++++++++++++++++++++++++++++++++++ valgrind.spec | 10 ++++- 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.21.0-pgste.patch diff --git a/valgrind-3.21.0-pgste.patch b/valgrind-3.21.0-pgste.patch new file mode 100644 index 0000000..4646aa2 --- /dev/null +++ b/valgrind-3.21.0-pgste.patch @@ -0,0 +1,73 @@ +From 56f1bd12c92806fd18337ba4cd3c0a8d714d0e94 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Thu, 15 Jun 2023 17:24:53 +0200 +Subject: [PATCH] Bug 470978 - s390x: Link the tools with -Wl,--s390-pgste + +Programs that require the PGSTE mode to be enabled may currently fail +under Valgrind. In particular this affects qemu-kvm. + +While it is also possible to enable the PGSTE mode globally with + + sysctl vm.allocate_psgte=1 + +the problem can more easily be prevented by linking the Valgrind tools +with -Wl,--s390-pgste. Add a configure check if the linker supports this, +and activate the flag if it does. + +To verify the intended result, the following shell command can be used to +list the executables having this flag set: + + find . -type f -perm -u+x -execdir \ + /bin/sh -c 'readelf -lW $0 2>/dev/null | grep PGSTE' {} \; -print +--- + Makefile.tool.am | 2 +- + configure.ac | 20 ++++++++++++++++++++ + 2 files changed, 21 insertions(+), 1 deletion(-) + +diff --git a/Makefile.tool.am b/Makefile.tool.am +index df9502913..4ce6d5ab0 100644 +--- a/Makefile.tool.am ++++ b/Makefile.tool.am +@@ -78,7 +78,7 @@ TOOL_LDFLAGS_ARM64_LINUX = \ + $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ + + TOOL_LDFLAGS_S390X_LINUX = \ +- $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ ++ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ @FLAG_S390_PGSTE@ + + TOOL_LDFLAGS_X86_DARWIN = \ + $(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386 +diff --git a/configure.ac b/configure.ac +index 0cf84a1c0..1d4164a7d 100755 +--- a/configure.ac ++++ b/configure.ac +@@ -3096,6 +3096,26 @@ AC_SUBST([FLAG_NO_BUILD_ID], [""]) + fi + CFLAGS=$safe_CFLAGS + ++# On s390x, if the linker supports -Wl,--s390-pgste, then we build the ++# tools with that flag. This enables running programs that need it, such ++# as qemu-kvm. ++if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then ++AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste]) ++safe_CFLAGS=$CFLAGS ++CFLAGS="-Wl,--s390-pgste" ++ ++AC_LINK_IFELSE( ++[AC_LANG_PROGRAM([ ], [return 0;])], ++[ ++ AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"]) ++ AC_MSG_RESULT([yes]) ++], [ ++ AC_SUBST([FLAG_S390_PGSTE], [""]) ++ AC_MSG_RESULT([no]) ++]) ++CFLAGS=$safe_CFLAGS ++fi ++ + # does the ppc assembler support "mtocrf" et al? + AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf]) + +-- +2.40.1 + diff --git a/valgrind.spec b/valgrind.spec index 4db5319..8b7cce4 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 6%{?dist} +Release: 7%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -108,6 +108,10 @@ Patch9: valgrind-3.21.0-realloc-again.patch Patch10: valgrind-3.21.0-vgm.patch Patch11: valgrind-3.21.0-vgm-tests.patch +# s390x: Valgrind cannot start qemu-kvm when "sysctl vm.allocate_pgste=0" +# https://bugs.kde.org/show_bug.cgi?id=470978 +Patch12: valgrind-3.21.0-pgste.patch + BuildRequires: make BuildRequires: glibc-devel @@ -252,6 +256,7 @@ Valgrind User Manual for details. %patch9 -p1 %patch10 -p1 %patch11 -p1 +%patch12 -p1 %build @@ -485,8 +490,9 @@ fi %endif %changelog -* Thu Jun 22 2023 Mark Wielaard +* Thu Jun 22 2023 Mark Wielaard - 3.21.0-7 - Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch +- Add valgrind-3.21.0-pgste.patch * Thu Jun 1 2023 Mark Wielaard - 3.21.0-6 - Add valgrind-3.21.0-callgrind_control-no-strict.patch From 2cb3825159a26b1a0290fefa0a48abee2a18de1e Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 22 Jul 2023 17:24:46 +0000 Subject: [PATCH 20/86] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- valgrind.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index 8b7cce4..9a4afcc 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 7%{?dist} +Release: 8%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -490,6 +490,9 @@ fi %endif %changelog +* Sat Jul 22 2023 Fedora Release Engineering - 1:3.21.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + * Thu Jun 22 2023 Mark Wielaard - 3.21.0-7 - Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch - Add valgrind-3.21.0-pgste.patch From d80baf58dc4b79afc1adbab9d132057b849c2a4d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 17 Aug 2023 16:17:56 +0200 Subject: [PATCH 21/86] Add valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch --- ...ti-mode-stdout-redirecting-to-stderr.patch | 85 +++++++++++++++++++ valgrind.spec | 8 ++ 2 files changed, 93 insertions(+) create mode 100644 valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch diff --git a/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch b/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch new file mode 100644 index 0000000..92d97d0 --- /dev/null +++ b/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch @@ -0,0 +1,85 @@ +From 449dd82becae6533a8e658e76f30f65434f6417f Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Thu, 17 Aug 2023 15:40:30 +0200 +Subject: [PATCH] gdb --multi mode stdout redirecting to stderr + +When in stdio mode (talking to gdb through stdin/stdout, not +through a socket), redirect stdout to stderr and close stdin +for the inferior. That way at least some output can be seen, +but there will be no input. + +This is workaround till we have real terminal handling. + + * coregrind/vgdb.c (main): Pass in_port to do_multi_mode. + (do_multi_mode): Pass in_port to fork_and_exec_valgrind. + (fork_and_exec_valgrind): Close stdin, redirect stdout to + stderr if in_port <= 0. + +https://bugs.kde.org/show_bug.cgi?id=471311 +--- + NEWS | 1 + + coregrind/vgdb.c | 20 +++++++++++++++++--- + 2 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c +index 56a969de7..c024ffca6 100644 +--- a/coregrind/vgdb.c ++++ b/coregrind/vgdb.c +@@ -1159,7 +1159,7 @@ static void gdb_relay(int pid, int send_noack_mode, char *q_buf); + or the errno from the child on failure. */ + static + int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, +- pid_t *pid) ++ int in_port, pid_t *pid) + { + int err = 0; + // We will use a pipe to track what the child does, +@@ -1243,6 +1243,19 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, + } + } + ++ /* When in stdio mode (talking to gdb through stdin/stdout, not ++ through a socket), redirect stdout to stderr and close stdin ++ for the inferior. That way at least some output can be seen, ++ but there will be no input. */ ++ if (in_port <= 0) { ++ /* close stdin */ ++ close (0); ++ /* open /dev/null as new stdin */ ++ open ("/dev/null", O_RDONLY); ++ /* redirect stdout as stderr */ ++ dup2 (2, 1); ++ } ++ + /* Try to launch valgrind. Add --vgdb-error=0 to stop immediately so we + can attach and --launched-with-multi to let valgrind know it doesn't + need to show a banner how to connect to gdb, we will do that +@@ -1309,7 +1322,7 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, + + /* Do multi stuff. */ + static +-void do_multi_mode(int check_trials) ++void do_multi_mode(int check_trials, int in_port) + { + char *buf = vmalloc(PBUFSIZ+1); + char *q_buf = vmalloc(PBUFSIZ+1); //save the qSupported packet sent by gdb +@@ -1459,6 +1472,7 @@ void do_multi_mode(int check_trials) + int res = fork_and_exec_valgrind (count, + decoded_string, + working_dir, ++ in_port, + &valgrind_pid); + + if (res == 0) { +@@ -2427,7 +2441,7 @@ int main(int argc, char** argv) + if (multi_mode) { + /* check_trails is the --wait argument in seconds, defaulting to 1 + * if not given. */ +- do_multi_mode (check_trials); ++ do_multi_mode (check_trials, in_port); + } else if (last_command >= 0) { + standalone_send_commands(pid, last_command, commands); + } else { +-- +2.41.0 + diff --git a/valgrind.spec b/valgrind.spec index 9a4afcc..51546bc 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -112,6 +112,10 @@ Patch11: valgrind-3.21.0-vgm-tests.patch # https://bugs.kde.org/show_bug.cgi?id=470978 Patch12: valgrind-3.21.0-pgste.patch +# gdb --multi mode stdout redirecting to stderr +# https://bugs.kde.org/show_bug.cgi?id=471311 +Patch13: valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch + BuildRequires: make BuildRequires: glibc-devel @@ -257,6 +261,7 @@ Valgrind User Manual for details. %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 %build @@ -490,6 +495,9 @@ fi %endif %changelog +* Thu Aug 17 2023 Mark Wielaard +- Add valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch + * Sat Jul 22 2023 Fedora Release Engineering - 1:3.21.0-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild From d20757b5fd28e3ce84e64522c6e3a042e8a98bbc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 17 Aug 2023 16:24:09 +0200 Subject: [PATCH 22/86] 3.21.0-9 - Use %%patch -Pn instead of deprecated %%patchn --- valgrind.spec | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index 51546bc..c9b719f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 8%{?dist} +Release: 9%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -244,24 +244,24 @@ Valgrind User Manual for details. %prep %setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} -%patch1 -p1 -%patch2 -p1 +%patch -P1 -p1 +%patch -P2 -p1 # Old rhel gcc doesn't have -fstack-protector-strong. %if 0%{?fedora} || 0%{?rhel} >= 7 -%patch3 -p1 -%patch4 -p1 +%patch -P3 -p1 +%patch -P4 -p1 %endif -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -p1 +%patch -P5 -p1 +%patch -P6 -p1 +%patch -P7 -p1 +%patch -P8 -p1 +%patch -P9 -p1 +%patch -P10 -p1 +%patch -P11 -p1 +%patch -P12 -p1 +%patch -P13 -p1 %build @@ -495,8 +495,9 @@ fi %endif %changelog -* Thu Aug 17 2023 Mark Wielaard +* Thu Aug 17 2023 Mark Wielaard - 3.21.0-9 - Add valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch +- Use %%patch -Pn instead of deprecated %%patchn * Sat Jul 22 2023 Fedora Release Engineering - 1:3.21.0-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild From 35cf45d805b3c8e220f20c0b366c68e6cdb92bf0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 21 Aug 2023 14:19:00 +0200 Subject: [PATCH 23/86] 3.21.0-10 lazy debuginfo loading - Add valgrind-3.21.0-lazy-debuginfo.patch - Add valgrind-3.21.0-cleanup-read_elf_object.patch --- valgrind-3.21.0-cleanup-read_elf_object.patch | 58 ++ valgrind-3.21.0-lazy-debuginfo.patch | 850 ++++++++++++++++++ valgrind.spec | 14 +- 3 files changed, 921 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.21.0-cleanup-read_elf_object.patch create mode 100644 valgrind-3.21.0-lazy-debuginfo.patch diff --git a/valgrind-3.21.0-cleanup-read_elf_object.patch b/valgrind-3.21.0-cleanup-read_elf_object.patch new file mode 100644 index 0000000..c81ca94 --- /dev/null +++ b/valgrind-3.21.0-cleanup-read_elf_object.patch @@ -0,0 +1,58 @@ +From a0d555a0dfe078ef04ea49d991a8090ab14bd4a5 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sat, 19 Aug 2023 21:37:33 +0200 +Subject: [PATCH] Always cleanup on exit from ML_(read_elf_object) + +I'm still a but baffled as to why this wasn't seen earlier. +A FreeBSD testcase started failing with kernel 13.2 patch 2, +which is quite a minor change. The testcase gets an fd from +pdfork and the parent does a printf with the fd then zaps the +process with pdkill. Standalone the fd is 3, and that's what +the expected contains. However, when it started failing I saw +with lsof that fds 3 and 4 were associated with the guest exe +and ld-elf.so.1. +--- + coregrind/m_debuginfo/readelf.c | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index f99d3dfd2..ac72f98fb 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -1916,6 +1916,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) + Word i, j; + Bool dynbss_present = False; + Bool sdynbss_present = False; ++ Bool retval = False; + + /* Image for the main ELF file we're working with. */ + DiImage* mimg = NULL; +@@ -2944,19 +2945,16 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) + } + } + +- return True; ++ retval = True; + +- out: +- { +- /* Last, but not least, detach from the image. */ +- if (mimg) ML_(img_done)(mimg); ++ out: + +- if (svma_ranges) VG_(deleteXA)(svma_ranges); ++ /* Last, but not least, detach from the image. */ ++ if (mimg) ML_(img_done)(mimg); + +- return False; +- } /* out: */ ++ if (svma_ranges) VG_(deleteXA)(svma_ranges); + +- /* NOTREACHED */ ++ return retval; + } + + Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) +-- +2.41.0 + diff --git a/valgrind-3.21.0-lazy-debuginfo.patch b/valgrind-3.21.0-lazy-debuginfo.patch new file mode 100644 index 0000000..6500abc --- /dev/null +++ b/valgrind-3.21.0-lazy-debuginfo.patch @@ -0,0 +1,850 @@ +From 60f7e89ba32b54d73b9e36d49e28d0f559ade0b9 Mon Sep 17 00:00:00 2001 +From: Aaron Merey +Date: Fri, 30 Jun 2023 18:31:42 -0400 +Subject: [PATCH] Support lazy reading and downloading of DWARF debuginfo + +Currently valgrind attempts to read DWARF .debug_* sections as well +as separate debuginfo files for ELF binaries as soon as a shared library +is loaded. This might also result in the downloading of separate debuginfo +files via debuginfod. + +This is inefficient when some of this debuginfo never ends up being used +by valgrind while running the client process. + +This patch adds support for lazy reading and downloading of DWARF +debuginfo. When an ELF shared library is loaded, the reading of .debug_* +sections as well as separate or alternate debuginfo is deferred until +valgrind handles an instruction pointer corresponding to a text segment +of the shared library. At this point the deferred sections and separate +debug files are loaded. + +This feature is only supported on ELF platforms. + +https://bugs.kde.org/show_bug.cgi?id=471807 + +ChangeLog + * debuginfo.c (di_notify_ACHIEVE_ACCEPT_STATE): Replace + read_elf_debug_info with read_elf_object. + (addr_load_di): New function. Attempts to load deferred debuginfo + associated with a given address. + (load_di): New function. Attempts to load a given deferred + debuginfo associated with a given address. + (describe_IP): Add calls to load_di and addr_load_di. + (find_DiCfSI): Add call to load_di. + + * priv_readelf.h (read_elf_object): New declaration. + (read_elf_debug): Ditto. + + * priv_storage.h (struct _DebugInfo): New field 'bool deferred'. + + * readelf.c (read_elf_debug_info): Split into read_elf_object and + read_elf_debug. + (read_elf_object): Read non .debug_* section from an ELF binary. + (read_elf_debug): Read .debug_* sections from an ELF binary as + as well any separate/alternate debuginfo files. + + * storage.c (canonicaliseSymtab): Remove assert in order to support + canonicalization of deferred _DebugInfo. + (finish_CFSI_arrays): Add early return if _DebugInfo is + deferred in order to avoid freeing memory that will be needed + when reading debuginfo at a later time. + (canonicaliseTables): Ditto. + + * pub_core_debuginfo.h (addr_load_di): New declaration. + (load_di): New declaration. +--- + NEWS | 1 + + coregrind/m_debuginfo/debuginfo.c | 57 +++- + coregrind/m_debuginfo/priv_readelf.h | 24 +- + coregrind/m_debuginfo/priv_storage.h | 7 + + coregrind/m_debuginfo/readelf.c | 437 ++++++++++++++++++--------- + coregrind/m_debuginfo/storage.c | 13 +- + coregrind/pub_core_debuginfo.h | 4 + + 7 files changed, 379 insertions(+), 164 deletions(-) + +diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c +index 22b41def2..8d1fdc696 100644 +--- a/coregrind/m_debuginfo/debuginfo.c ++++ b/coregrind/m_debuginfo/debuginfo.c +@@ -959,14 +959,16 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di ) + discard_DebugInfos_which_overlap_with( di ); + + /* The DebugInfoMappings that now exist in the FSM may involve +- overlaps. This confuses ML_(read_elf_debug_info), and may cause ++ overlaps. This confuses ML_(read_elf_*), and may cause + it to compute wrong biases. So de-overlap them now. + See http://bugzilla.mozilla.org/show_bug.cgi?id=788974 */ + truncate_DebugInfoMapping_overlaps( di, di->fsm.maps ); + + /* And acquire new info. */ + # if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) +- ok = ML_(read_elf_debug_info)( di ); ++ ok = ML_(read_elf_object)( di ); ++ if (ok) ++ di->deferred = True; + # elif defined(VGO_darwin) + ok = ML_(read_macho_debug_info)( di ); + # else +@@ -1443,6 +1445,50 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) + } + } + ++/* Load DI if it has a text segment containing A and DI hasn't already ++ been loaded. */ ++ ++void VG_(load_di)( DebugInfo *di, Addr a) ++{ ++ if (!di->deferred ++ || !di->text_present ++ || di->text_size <= 0 ++ || di->text_avma > a ++ || a >= di->text_avma + di->text_size) ++ return; ++ ++ di->deferred = False; ++ ML_(read_elf_debug) (di); ++ ML_(canonicaliseTables)( di ); ++ ++ /* Check invariants listed in ++ Comment_on_IMPORTANT_REPRESENTATIONAL_INVARIANTS in ++ priv_storage.h. */ ++ check_CFSI_related_invariants(di); ++ ML_(finish_CFSI_arrays)(di); ++} ++ ++/* Attempt to load DebugInfo with a text segment containing A, ++ if such a debuginfo hasn't already been loaded. */ ++ ++void VG_(addr_load_di)( Addr a ) ++{ ++ DebugInfo *di; ++ ++ di = VG_(find_DebugInfo)(VG_(current_DiEpoch)(), a); ++ if (di != NULL) ++ if (di->deferred) { ++ di->deferred = False; ++ ML_(read_elf_debug) (di); ++ ML_(canonicaliseTables)( di ); ++ ++ /* Check invariants listed in ++ Comment_on_IMPORTANT_REPRESENTATIONAL_INVARIANTS in ++ priv_storage.h. */ ++ check_CFSI_related_invariants(di); ++ ML_(finish_CFSI_arrays)(di); ++ } ++} + + /* Unmap is simpler - throw away any SegInfos intersecting + [a, a+len). */ +@@ -2746,6 +2792,11 @@ const HChar* VG_(describe_IP)(DiEpoch ep, Addr eip, const InlIPCursor *iipc) + Bool know_objname; + Bool know_srcloc; + ++ if (iipc && iipc->di) ++ VG_(load_di) (iipc->di, eip); ++ else ++ VG_(addr_load_di) (eip); ++ + if (is_bottom(iipc)) { + // At the bottom (towards main), we describe the fn at eip. + know_fnname = VG_(clo_sym_offsets) +@@ -3090,6 +3141,8 @@ static void find_DiCfSI ( /*OUT*/DebugInfo** diP, + if (!is_DI_valid_for_epoch(di, curr_epoch)) + continue; + ++ VG_(load_di)(di, ip); ++ + /* Use the per-DebugInfo summary address ranges to skip + inapplicable DebugInfos quickly. */ + if (di->cfsi_used == 0) +diff --git a/coregrind/m_debuginfo/priv_readelf.h b/coregrind/m_debuginfo/priv_readelf.h +index 57aa0cc3f..7e0fa17c9 100644 +--- a/coregrind/m_debuginfo/priv_readelf.h ++++ b/coregrind/m_debuginfo/priv_readelf.h +@@ -44,13 +44,23 @@ + extern Bool ML_(is_elf_object_file)( const void* image, SizeT n_image, + Bool rel_ok ); + +-/* The central function for reading ELF debug info. For the +- object/exe specified by the SegInfo, find ELF sections, then read +- the symbols, line number info, file name info, CFA (stack-unwind +- info) and anything else we want, into the tables within the +- supplied SegInfo. +-*/ +-extern Bool ML_(read_elf_debug_info) ( DebugInfo* di ); ++/* Read the ELF binary specified by DI. For the object/exe specified ++ by the SegInfo, find ELF sections, then read the symbols, line number ++ info, file name info, CFA (stack-unwind info) and anything else we ++ want, into the tables within the supplied SegInfo. ++ ++ .debug_* sections as well as any separate debuginfo files are not ++ loaded by this function but instead by ML_(read_elf_debug). This ++ separation facilitates lazy loading of debuginfo. */ ++extern Bool ML_(read_elf_object) ( DebugInfo* di ); ++ ++/* Read .debug_* sections from the ELF binary specified by DI. Also ++ attempt to load any separate debuginfo files associated with the ++ object. ++ ++ ML_(read_elf_object) should be called on DI before calling this ++ function. */ ++extern Bool ML_(read_elf_debug) ( DebugInfo* di ); + + extern Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, Int * rw_load_count ); + +diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h +index a4b90d36b..b959873ab 100644 +--- a/coregrind/m_debuginfo/priv_storage.h ++++ b/coregrind/m_debuginfo/priv_storage.h +@@ -678,6 +678,13 @@ struct _DebugInfo { + invalid and should not be consulted. */ + Bool have_dinfo; /* initially False */ + ++ /* If true then the reading of .debug_* section has been deferred ++ until it this information is required (such as when printing ++ a stacktrace). Additionally, if true then the reading of any ++ separate debuginfo files associated with this object has also ++ been deferred. */ ++ Bool deferred; ++ + /* All the rest of the fields in this structure are filled in once + we have committed to reading the symbols and debug info (that + is, at the point where .have_dinfo is set to True). */ +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index ce7b7998d..f99d3dfd2 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -1836,6 +1836,44 @@ static HChar* readlink_path (const HChar *path) + return buf; + } + ++#define FINDX_MIMG(_sec_name, _sec_escn, _post_fx) \ ++ do { \ ++ ElfXX_Shdr a_shdr; \ ++ ML_(img_get)(&a_shdr, mimg, \ ++ INDEX_BIS(shdr_mioff, i, shdr_ment_szB), \ ++ sizeof(a_shdr)); \ ++ if (0 == ML_(img_strcmp_c)(mimg, shdr_strtab_mioff \ ++ + a_shdr.sh_name, _sec_name)) { \ ++ Bool nobits; \ ++ _sec_escn.img = mimg; \ ++ _sec_escn.ioff = (DiOffT)a_shdr.sh_offset; \ ++ _sec_escn.szB = a_shdr.sh_size; \ ++ if (!check_compression(&a_shdr, &_sec_escn)) { \ ++ ML_(symerr)(di, True, " Compression type is unsupported"); \ ++ goto out; \ ++ } \ ++ nobits = a_shdr.sh_type == SHT_NOBITS; \ ++ vg_assert(_sec_escn.img != NULL); \ ++ vg_assert(_sec_escn.ioff != DiOffT_INVALID); \ ++ TRACE_SYMTAB( "%-18s: ioff %llu .. %llu\n", \ ++ _sec_name, (ULong)a_shdr.sh_offset, \ ++ ((ULong)a_shdr.sh_offset) + a_shdr.sh_size - 1); \ ++ /* SHT_NOBITS sections have zero size in the file. */ \ ++ if (!nobits && \ ++ a_shdr.sh_offset + \ ++ a_shdr.sh_size > ML_(img_real_size)(mimg)) { \ ++ ML_(symerr)(di, True, \ ++ " section beyond image end?!"); \ ++ goto out; \ ++ } \ ++ _post_fx; \ ++ } \ ++ } while (0); ++ ++/* Version with no post-effects */ ++#define FIND_MIMG(_sec_name, _sec_escn) \ ++ FINDX_MIMG(_sec_name, _sec_escn, /**/) ++ + /* The central function for reading ELF debug info. For the + object/exe specified by the DebugInfo, find ELF sections, then read + the symbols, line number info, file name info, CFA (stack-unwind +@@ -1843,7 +1881,7 @@ static HChar* readlink_path (const HChar *path) + supplied DebugInfo. + */ + +-Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) ++Bool ML_(read_elf_object) ( struct _DebugInfo* di ) + { + /* This function is long and complex. That, and the presence of + nested scopes, means it's not always easy to see which parts are +@@ -1874,7 +1912,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + + + /* TOPLEVEL */ +- Bool res, ok; ++ Bool ok; + Word i, j; + Bool dynbss_present = False; + Bool sdynbss_present = False; +@@ -1882,12 +1920,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + /* Image for the main ELF file we're working with. */ + DiImage* mimg = NULL; + +- /* Ditto for any ELF debuginfo file that we might happen to load. */ +- DiImage* dimg = NULL; +- +- /* Ditto for alternate ELF debuginfo file that we might happen to load. */ +- DiImage* aimg = NULL; +- + /* ELF header offset for the main file. Should be zero since the + ELF header is at start of file. */ + DiOffT ehdr_mioff = 0; +@@ -1970,8 +2002,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + got, plt, and toc. + ---------------------------------------------------------- */ + +- res = False; +- + if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir)) + VG_(message)(Vg_DebugMsg, "Reading syms from %s\n", + di->fsm.filename ); +@@ -2056,7 +2086,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + shdr_strtab_mioff + = ehdr_mioff /* isn't this always zero? */ + a_shdr.sh_offset; + +- if (!ML_(img_valid)(mimg, shdr_strtab_mioff, ++ if (!ML_(img_valid)(mimg, shdr_strtab_mioff, + 1/*bogus, but we don't know the real size*/ )) { + ML_(symerr)(di, True, "Invalid ELF Section Header String Table"); + goto out; +@@ -2798,10 +2828,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + di->text_avma - di->text_bias, + di->text_avma ); + +- TRACE_SYMTAB("\n"); +- TRACE_SYMTAB("------ Finding image addresses " +- "for debug-info sections ------\n"); +- + /* TOPLEVEL */ + /* Find interesting sections, read the symbol table(s), read any + debug information. Each section is located either in the main, +@@ -2821,27 +2847,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + # if defined(VGO_solaris) + DiSlice ldynsym_escn = DiSlice_INVALID; // .SUNW_ldynsym + # endif +- DiSlice debuglink_escn = DiSlice_INVALID; // .gnu_debuglink +- DiSlice debugaltlink_escn = DiSlice_INVALID; // .gnu_debugaltlink +- DiSlice debug_line_escn = DiSlice_INVALID; // .debug_line (dwarf2) +- DiSlice debug_info_escn = DiSlice_INVALID; // .debug_info (dwarf2) +- DiSlice debug_types_escn = DiSlice_INVALID; // .debug_types (dwarf4) +- DiSlice debug_abbv_escn = DiSlice_INVALID; // .debug_abbrev (dwarf2) +- DiSlice debug_str_escn = DiSlice_INVALID; // .debug_str (dwarf2) +- DiSlice debug_line_str_escn = DiSlice_INVALID; // .debug_line_str(dwarf5) +- DiSlice debug_ranges_escn = DiSlice_INVALID; // .debug_ranges (dwarf2) +- DiSlice debug_rnglists_escn = DiSlice_INVALID; // .debug_rnglists(dwarf5) +- DiSlice debug_loclists_escn = DiSlice_INVALID; // .debug_loclists(dwarf5) +- DiSlice debug_addr_escn = DiSlice_INVALID; // .debug_addr (dwarf5) +- DiSlice debug_str_offsets_escn = DiSlice_INVALID; // .debug_str_offsets (dwarf5) +- DiSlice debug_loc_escn = DiSlice_INVALID; // .debug_loc (dwarf2) +- DiSlice debug_frame_escn = DiSlice_INVALID; // .debug_frame (dwarf2) +- DiSlice debug_line_alt_escn = DiSlice_INVALID; // .debug_line (alt) +- DiSlice debug_info_alt_escn = DiSlice_INVALID; // .debug_info (alt) +- DiSlice debug_abbv_alt_escn = DiSlice_INVALID; // .debug_abbrev (alt) +- DiSlice debug_str_alt_escn = DiSlice_INVALID; // .debug_str (alt) +- DiSlice dwarf1d_escn = DiSlice_INVALID; // .debug (dwarf1) +- DiSlice dwarf1l_escn = DiSlice_INVALID; // .line (dwarf1) + DiSlice opd_escn = DiSlice_INVALID; // .opd (dwarf2, + // ppc64be-linux) + DiSlice ehframe_escn[N_EHFRAME_SECTS]; // .eh_frame (dwarf2) +@@ -2868,118 +2873,282 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + /* TOPLEVEL */ + /* Iterate over section headers (again) */ + for (i = 0; i < ehdr_m.e_shnum; i++) { ++ /* NAME ElfSec */ ++ FIND_MIMG( ".dynsym", dynsym_escn) ++ FIND_MIMG( ".dynstr", dynstr_escn) ++ FIND_MIMG( ".symtab", symtab_escn) ++ FIND_MIMG( ".strtab", strtab_escn) ++# if defined(VGO_solaris) ++ FIND_MIMG( ".SUNW_ldynsym", ldynsym_escn) ++# endif + +-# define FINDX(_sec_name, _sec_escn, _post_fx) \ +- do { \ +- ElfXX_Shdr a_shdr; \ +- ML_(img_get)(&a_shdr, mimg, \ +- INDEX_BIS(shdr_mioff, i, shdr_ment_szB), \ +- sizeof(a_shdr)); \ +- if (0 == ML_(img_strcmp_c)(mimg, shdr_strtab_mioff \ +- + a_shdr.sh_name, _sec_name)) { \ +- Bool nobits; \ +- _sec_escn.img = mimg; \ +- _sec_escn.ioff = (DiOffT)a_shdr.sh_offset; \ +- _sec_escn.szB = a_shdr.sh_size; \ +- if (!check_compression(&a_shdr, &_sec_escn)) { \ +- ML_(symerr)(di, True, " Compression type is unsupported"); \ +- goto out; \ +- } \ +- nobits = a_shdr.sh_type == SHT_NOBITS; \ +- vg_assert(_sec_escn.img != NULL); \ +- vg_assert(_sec_escn.ioff != DiOffT_INVALID); \ +- TRACE_SYMTAB( "%-18s: ioff %llu .. %llu\n", \ +- _sec_name, (ULong)a_shdr.sh_offset, \ +- ((ULong)a_shdr.sh_offset) + a_shdr.sh_size - 1); \ +- /* SHT_NOBITS sections have zero size in the file. */ \ +- if (!nobits && \ +- a_shdr.sh_offset + \ +- a_shdr.sh_size > ML_(img_real_size)(mimg)) { \ +- ML_(symerr)(di, True, \ +- " section beyond image end?!"); \ +- goto out; \ +- } \ +- _post_fx; \ +- } \ +- } while (0); ++ FINDX_MIMG( ".eh_frame", ehframe_escn[ehframe_mix], ++ do { ehframe_mix++; vg_assert(ehframe_mix <= N_EHFRAME_SECTS); ++ } while (0) ++ ) ++ /* Comment_on_EH_FRAME_MULTIPLE_INSTANCES: w.r.t. .eh_frame ++ multi-instance kludgery, how are we assured that the order ++ in which we fill in ehframe_escn[] is consistent with the ++ order in which we previously filled in di->ehframe_avma[] ++ and di->ehframe_size[] ? By the fact that in both cases, ++ these arrays were filled in by iterating over the section ++ headers top-to-bottom. So both loops (this one and the ++ previous one) encounter the .eh_frame entries in the same ++ order and so fill in these arrays in a consistent order. ++ */ ++ } /* Iterate over section headers (again) */ + +- /* Version with no post-effects */ +-# define FIND(_sec_name, _sec_escn) \ +- FINDX(_sec_name, _sec_escn, /**/) ++ /* Check some sizes */ ++ vg_assert((dynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); ++ vg_assert((symtab_escn.szB % sizeof(ElfXX_Sym)) == 0); ++# if defined(VGO_solaris) ++ vg_assert((ldynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); ++# endif + +- /* NAME ElfSec */ +- FIND( ".dynsym", dynsym_escn) +- FIND( ".dynstr", dynstr_escn) +- FIND( ".symtab", symtab_escn) +- FIND( ".strtab", strtab_escn) ++ /* Read symbols */ ++ { ++ void (*read_elf_symtab)(struct _DebugInfo*, const HChar*, ++ DiSlice*, DiSlice*, DiSlice*, Bool); ++# if defined(VGP_ppc64be_linux) ++ read_elf_symtab = read_elf_symtab__ppc64be_linux; ++# else ++ read_elf_symtab = read_elf_symtab__normal; ++# endif ++ if (symtab_escn.img != NULL) ++ read_elf_symtab(di, "symbol table", ++ &symtab_escn, &strtab_escn, &opd_escn, ++ False); ++ read_elf_symtab(di, "dynamic symbol table", ++ &dynsym_escn, &dynstr_escn, &opd_escn, ++ False); + # if defined(VGO_solaris) +- FIND( ".SUNW_ldynsym", ldynsym_escn) ++ read_elf_symtab(di, "local dynamic symbol table", ++ &ldynsym_escn, &dynstr_escn, &opd_escn, ++ False); + # endif ++ } + +- FIND( ".gnu_debuglink", debuglink_escn) +- FIND( ".gnu_debugaltlink", debugaltlink_escn) ++ /* TOPLEVEL */ ++ /* Read .eh_frame and .debug_frame (call-frame-info) if any. Do ++ the .eh_frame section(s) first. */ ++ vg_assert(di->n_ehframe >= 0 && di->n_ehframe <= N_EHFRAME_SECTS); ++ for (i = 0; i < di->n_ehframe; i++) { ++ /* see Comment_on_EH_FRAME_MULTIPLE_INSTANCES above for why ++ this next assertion should hold. */ ++ vg_assert(ML_(sli_is_valid)(ehframe_escn[i])); ++ vg_assert(ehframe_escn[i].szB == di->ehframe_size[i]); ++ ML_(read_callframe_info_dwarf3)( di, ++ ehframe_escn[i], ++ di->ehframe_avma[i], ++ True/*is_ehframe*/ ); ++ } ++ } ++ ++ return True; ++ ++ out: ++ { ++ /* Last, but not least, detach from the image. */ ++ if (mimg) ML_(img_done)(mimg); ++ ++ if (svma_ranges) VG_(deleteXA)(svma_ranges); + +- FIND( ".debug_line", debug_line_escn) ++ return False; ++ } /* out: */ ++ ++ /* NOTREACHED */ ++} ++ ++Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) ++{ ++ Word i, j; ++ Bool res = True; ++ Bool ok; ++ ++ /* Image for the main ELF file we're working with. */ ++ DiImage* mimg = NULL; ++ ++ /* Ditto for any ELF debuginfo file that we might happen to load. */ ++ DiImage* dimg = NULL; ++ ++ /* Ditto for alternate ELF debuginfo file that we might happen to load. */ ++ DiImage* aimg = NULL; ++ ++ /* Section header image addr, # entries, entry size. Also the ++ associated string table. */ ++ DiOffT shdr_mioff = 0; ++ UWord shdr_mnent = 0; ++ UWord shdr_ment_szB = 0; ++ DiOffT shdr_strtab_mioff = 0; ++ ++ DiOffT ehdr_mioff = 0; ++ ++ /* Connect to the primary object image, so that we can read symbols ++ and line number info out of it. It will be disconnected ++ immediately thereafter; it is only connected transiently. */ ++ mimg = ML_(img_from_local_file)(di->fsm.filename); ++ if (mimg == NULL) { ++ VG_(message)(Vg_UserMsg, "warning: connection to image %s failed\n", ++ di->fsm.filename ); ++ VG_(message)(Vg_UserMsg, " no debug info loaded\n" ); ++ return False; ++ } ++ ++ /* Ok, the object image is available. Now verify that it is a ++ valid ELF .so or executable image. */ ++ ok = is_elf_object_file_by_DiImage(mimg, False); ++ if (!ok) { ++ ML_(symerr)(di, True, "Invalid ELF Header"); ++ goto out; ++ } ++ ++ /* Find where the program and section header tables are, and give ++ up if either is missing or outside the image (bogus). */ ++ ElfXX_Ehdr ehdr_m; ++ vg_assert(ehdr_mioff == 0); // ensured by its initialisation ++ ok = ML_(img_valid)(mimg, ehdr_mioff, sizeof(ehdr_m)); ++ vg_assert(ok); // ML_(is_elf_object_file) should ensure this ++ ML_(img_get)(&ehdr_m, mimg, ehdr_mioff, sizeof(ehdr_m)); ++ ++ shdr_mioff = ehdr_mioff + ehdr_m.e_shoff; ++ shdr_mnent = ehdr_m.e_shnum; ++ shdr_ment_szB = ehdr_m.e_shentsize; ++ ++ if (shdr_mnent == 0 ++ || !ML_(img_valid)(mimg, shdr_mioff, shdr_mnent * shdr_ment_szB)) { ++ ML_(symerr)(di, True, "Missing or invalid ELF Section Header Table"); ++ goto out; ++ } ++ ++ /* Also find the section header's string table, and validate. */ ++ /* checked previously by is_elf_object_file: */ ++ vg_assert(ehdr_m.e_shstrndx != SHN_UNDEF); ++ ++ // shdr_mioff is the offset of the section header table ++ // and we need the ehdr_m.e_shstrndx'th entry ++ { ElfXX_Shdr a_shdr; ++ ML_(img_get)(&a_shdr, mimg, ++ INDEX_BIS(shdr_mioff, ehdr_m.e_shstrndx, shdr_ment_szB), ++ sizeof(a_shdr)); ++ shdr_strtab_mioff ++ = ehdr_mioff /* isn't this always zero? */ + a_shdr.sh_offset; ++ ++ if (!ML_(img_valid)(mimg, shdr_strtab_mioff, ++ 1/*bogus, but we don't know the real size*/ )) { ++ ML_(symerr)(di, True, "Invalid ELF Section Header String Table"); ++ goto out; ++ } ++ } ++ ++ TRACE_SYMTAB("\n"); ++ TRACE_SYMTAB("------ Finding image addresses " ++ "for debug-info sections ------\n"); ++ /* TOPLEVEL */ ++ /* Find interesting sections, read the symbol table(s), read any ++ debug information. Each section is located either in the main, ++ debug or alt-debug files, but only in one. For each section, ++ |section_escn| records which of |mimg|, |dimg| or |aimg| we ++ found it in, along with the section's image offset and its size. ++ The triples (section_img, section_ioff, section_szB) are ++ consistent, in that they are always either (NULL, ++ DiOffT_INVALID, 0), or refer to the same image, and are all ++ assigned together. */ ++ ++ { ++ /* TOPLEVEL */ ++ DiSlice strtab_escn = DiSlice_INVALID; // .strtab ++ DiSlice symtab_escn = DiSlice_INVALID; // .symtab ++ DiSlice debuglink_escn = DiSlice_INVALID; // .gnu_debuglink ++ DiSlice debugaltlink_escn = DiSlice_INVALID; // .gnu_debugaltlink ++ DiSlice debug_line_escn = DiSlice_INVALID; // .debug_line (dwarf2) ++ DiSlice debug_info_escn = DiSlice_INVALID; // .debug_info (dwarf2) ++ DiSlice debug_types_escn = DiSlice_INVALID; // .debug_types (dwarf4) ++ DiSlice debug_abbv_escn = DiSlice_INVALID; // .debug_abbrev (dwarf2) ++ DiSlice debug_str_escn = DiSlice_INVALID; // .debug_str (dwarf2) ++ DiSlice debug_line_str_escn = DiSlice_INVALID; // .debug_line_str(dwarf5) ++ DiSlice debug_ranges_escn = DiSlice_INVALID; // .debug_ranges (dwarf2) ++ DiSlice debug_rnglists_escn = DiSlice_INVALID; // .debug_rnglists(dwarf5) ++ DiSlice debug_loclists_escn = DiSlice_INVALID; // .debug_loclists(dwarf5) ++ DiSlice debug_addr_escn = DiSlice_INVALID; // .debug_addr (dwarf5) ++ DiSlice debug_str_offsets_escn = DiSlice_INVALID; // .debug_str_offsets (dwarf5) ++ DiSlice debug_loc_escn = DiSlice_INVALID; // .debug_loc (dwarf2) ++ DiSlice debug_frame_escn = DiSlice_INVALID; // .debug_frame (dwarf2) ++ DiSlice debug_line_alt_escn = DiSlice_INVALID; // .debug_line (alt) ++ DiSlice debug_info_alt_escn = DiSlice_INVALID; // .debug_info (alt) ++ DiSlice debug_abbv_alt_escn = DiSlice_INVALID; // .debug_abbrev (alt) ++ DiSlice debug_str_alt_escn = DiSlice_INVALID; // .debug_str (alt) ++ DiSlice dwarf1d_escn = DiSlice_INVALID; // .debug (dwarf1) ++ DiSlice dwarf1l_escn = DiSlice_INVALID; // .line (dwarf1) ++ DiSlice opd_escn = DiSlice_INVALID; // .opd (dwarf2, ++ // ppc64be-linux) ++ ++ /* TOPLEVEL */ ++ /* Iterate over section headers (again) */ ++ for (i = 0; i < ehdr_m.e_shnum; i++) { ++ ++ /* NAME ElfSec */ ++ FIND_MIMG( ".symtab", symtab_escn) ++ FIND_MIMG( ".strtab", strtab_escn) ++ FIND_MIMG( ".gnu_debuglink", debuglink_escn) ++ FIND_MIMG( ".gnu_debugaltlink", debugaltlink_escn) ++ ++ FIND_MIMG( ".debug_line", debug_line_escn) + if (!ML_(sli_is_valid)(debug_line_escn)) +- FIND(".zdebug_line", debug_line_escn) ++ FIND_MIMG(".zdebug_line", debug_line_escn) + +- FIND( ".debug_info", debug_info_escn) ++ FIND_MIMG( ".debug_info", debug_info_escn) + if (!ML_(sli_is_valid)(debug_info_escn)) +- FIND(".zdebug_info", debug_info_escn) ++ FIND_MIMG(".zdebug_info", debug_info_escn) + +- FIND( ".debug_types", debug_types_escn) ++ FIND_MIMG( ".debug_types", debug_types_escn) + if (!ML_(sli_is_valid)(debug_types_escn)) +- FIND(".zdebug_types", debug_types_escn) ++ FIND_MIMG(".zdebug_types", debug_types_escn) + +- FIND( ".debug_abbrev", debug_abbv_escn) ++ FIND_MIMG( ".debug_abbrev", debug_abbv_escn) + if (!ML_(sli_is_valid)(debug_abbv_escn)) +- FIND(".zdebug_abbrev", debug_abbv_escn) ++ FIND_MIMG(".zdebug_abbrev", debug_abbv_escn) + +- FIND( ".debug_str", debug_str_escn) ++ FIND_MIMG( ".debug_str", debug_str_escn) + if (!ML_(sli_is_valid)(debug_str_escn)) +- FIND(".zdebug_str", debug_str_escn) ++ FIND_MIMG(".zdebug_str", debug_str_escn) + +- FIND( ".debug_line_str", debug_line_str_escn) ++ FIND_MIMG( ".debug_line_str", debug_line_str_escn) + if (!ML_(sli_is_valid)(debug_line_str_escn)) +- FIND(".zdebug_str", debug_line_str_escn) ++ FIND_MIMG(".zdebug_str", debug_line_str_escn) + +- FIND( ".debug_ranges", debug_ranges_escn) ++ FIND_MIMG( ".debug_ranges", debug_ranges_escn) + if (!ML_(sli_is_valid)(debug_ranges_escn)) +- FIND(".zdebug_ranges", debug_ranges_escn) ++ FIND_MIMG(".zdebug_ranges", debug_ranges_escn) + +- FIND( ".debug_rnglists", debug_rnglists_escn) ++ FIND_MIMG( ".debug_rnglists", debug_rnglists_escn) + if (!ML_(sli_is_valid)(debug_rnglists_escn)) +- FIND(".zdebug_rnglists", debug_rnglists_escn) ++ FIND_MIMG(".zdebug_rnglists", debug_rnglists_escn) + +- FIND( ".debug_loclists", debug_loclists_escn) ++ FIND_MIMG( ".debug_loclists", debug_loclists_escn) + if (!ML_(sli_is_valid)(debug_loclists_escn)) +- FIND(".zdebug_loclists", debug_loclists_escn) ++ FIND_MIMG(".zdebug_loclists", debug_loclists_escn) + +- FIND( ".debug_loc", debug_loc_escn) ++ FIND_MIMG( ".debug_loc", debug_loc_escn) + if (!ML_(sli_is_valid)(debug_loc_escn)) +- FIND(".zdebug_loc", debug_loc_escn) ++ FIND_MIMG(".zdebug_loc", debug_loc_escn) + +- FIND( ".debug_frame", debug_frame_escn) ++ FIND_MIMG( ".debug_frame", debug_frame_escn) + if (!ML_(sli_is_valid)(debug_frame_escn)) +- FIND(".zdebug_frame", debug_frame_escn) ++ FIND_MIMG(".zdebug_frame", debug_frame_escn) + +- FIND( ".debug_addr", debug_addr_escn) ++ FIND_MIMG( ".debug_addr", debug_addr_escn) + if (!ML_(sli_is_valid)(debug_addr_escn)) +- FIND(".zdebug_addr", debug_addr_escn) ++ FIND_MIMG(".zdebug_addr", debug_addr_escn) + +- FIND( ".debug_str_offsets", debug_str_offsets_escn) ++ FIND_MIMG( ".debug_str_offsets", debug_str_offsets_escn) + if (!ML_(sli_is_valid)(debug_str_offsets_escn)) +- FIND(".zdebug_str_offsets", debug_str_offsets_escn) ++ FIND_MIMG(".zdebug_str_offsets", debug_str_offsets_escn) + +- FIND( ".debug", dwarf1d_escn) +- FIND( ".line", dwarf1l_escn) ++ FIND_MIMG( ".debug", dwarf1d_escn) ++ FIND_MIMG( ".line", dwarf1l_escn) + +- FIND( ".opd", opd_escn) ++ FIND_MIMG( ".opd", opd_escn) + +- FINDX( ".eh_frame", ehframe_escn[ehframe_mix], +- do { ehframe_mix++; vg_assert(ehframe_mix <= N_EHFRAME_SECTS); +- } while (0) +- ) + /* Comment_on_EH_FRAME_MULTIPLE_INSTANCES: w.r.t. .eh_frame + multi-instance kludgery, how are we assured that the order + in which we fill in ehframe_escn[] is consistent with the +@@ -2991,8 +3160,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + order and so fill in these arrays in a consistent order. + */ + +-# undef FINDX +-# undef FIND + } /* Iterate over section headers (again) */ + + /* TOPLEVEL */ +@@ -3465,53 +3632,23 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + } /* Find all interesting sections */ + } /* do we have a debug image? */ + +- + /* TOPLEVEL */ +- /* Check some sizes */ +- vg_assert((dynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); + vg_assert((symtab_escn.szB % sizeof(ElfXX_Sym)) == 0); +-# if defined(VGO_solaris) +- vg_assert((ldynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); +-# endif + + /* TOPLEVEL */ + /* Read symbols */ + { + void (*read_elf_symtab)(struct _DebugInfo*, const HChar*, + DiSlice*, DiSlice*, DiSlice*, Bool); +- Bool symtab_in_debug; + # if defined(VGP_ppc64be_linux) + read_elf_symtab = read_elf_symtab__ppc64be_linux; + # else + read_elf_symtab = read_elf_symtab__normal; + # endif +- symtab_in_debug = symtab_escn.img == dimg; +- read_elf_symtab(di, "symbol table", +- &symtab_escn, &strtab_escn, &opd_escn, +- symtab_in_debug); +- read_elf_symtab(di, "dynamic symbol table", +- &dynsym_escn, &dynstr_escn, &opd_escn, +- False); +-# if defined(VGO_solaris) +- read_elf_symtab(di, "local dynamic symbol table", +- &ldynsym_escn, &dynstr_escn, &opd_escn, +- False); +-# endif +- } +- +- /* TOPLEVEL */ +- /* Read .eh_frame and .debug_frame (call-frame-info) if any. Do +- the .eh_frame section(s) first. */ +- vg_assert(di->n_ehframe >= 0 && di->n_ehframe <= N_EHFRAME_SECTS); +- for (i = 0; i < di->n_ehframe; i++) { +- /* see Comment_on_EH_FRAME_MULTIPLE_INSTANCES above for why +- this next assertion should hold. */ +- vg_assert(ML_(sli_is_valid)(ehframe_escn[i])); +- vg_assert(ehframe_escn[i].szB == di->ehframe_size[i]); +- ML_(read_callframe_info_dwarf3)( di, +- ehframe_escn[i], +- di->ehframe_avma[i], +- True/*is_ehframe*/ ); ++ if (symtab_escn.img != NULL) ++ read_elf_symtab(di, "symbol table", ++ &symtab_escn, &strtab_escn, &opd_escn, ++ True); + } + if (ML_(sli_is_valid)(debug_frame_escn)) { + ML_(read_callframe_info_dwarf3)( di, +@@ -3643,8 +3780,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + if (dimg) ML_(img_done)(dimg); + if (aimg) ML_(img_done)(aimg); + +- if (svma_ranges) VG_(deleteXA)(svma_ranges); +- + return res; + } /* out: */ + +diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c +index c3fa62e96..3ad114607 100644 +--- a/coregrind/m_debuginfo/storage.c ++++ b/coregrind/m_debuginfo/storage.c +@@ -1297,8 +1297,7 @@ void ML_(addVar)( struct _DebugInfo* di, + that those extra sections have the same bias as .text, but that + seems a reasonable assumption to me. */ + /* This is assured us by top level steering logic in debuginfo.c, +- and it is re-checked at the start of +- ML_(read_elf_debug_info). */ ++ and it is re-checked at the start of ML_(read_elf_object). */ + vg_assert(di->fsm.have_rx_map && di->fsm.rw_map_count); + if (level > 0 && ML_(find_rx_mapping)(di, aMin, aMax) == NULL) { + if (VG_(clo_verbosity) > 1) { +@@ -1725,7 +1724,6 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) + for (i = 0; i < di->symtab_used; i++) { + DiSym* sym = &di->symtab[i]; + vg_assert(sym->pri_name); +- vg_assert(!sym->sec_names); + } + + /* Sort by address. */ +@@ -2383,6 +2381,9 @@ void ML_(finish_CFSI_arrays) ( struct _DebugInfo* di ) + vg_assert (f_holes == n_holes); + vg_assert (pos == new_used); + ++ if (di->deferred) ++ return; ++ + di->cfsi_used = new_used; + di->cfsi_size = new_used; + ML_(dinfo_free) (di->cfsi_rd); +@@ -2398,9 +2399,13 @@ void ML_(canonicaliseTables) ( struct _DebugInfo* di ) + canonicaliseLoctab ( di ); + canonicaliseInltab ( di ); + ML_(canonicaliseCFI) ( di ); ++ canonicaliseVarInfo ( di ); ++ ++ if (di->deferred) ++ return; ++ + if (di->cfsi_m_pool) + VG_(freezeDedupPA) (di->cfsi_m_pool, ML_(dinfo_shrink_block)); +- canonicaliseVarInfo ( di ); + if (di->strpool) + VG_(freezeDedupPA) (di->strpool, ML_(dinfo_shrink_block)); + if (di->fndnpool) +diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h +index 938ed00cc..ce7246217 100644 +--- a/coregrind/pub_core_debuginfo.h ++++ b/coregrind/pub_core_debuginfo.h +@@ -76,6 +76,10 @@ extern void VG_(di_notify_pdb_debuginfo)( Int fd, Addr avma, + extern void VG_(di_notify_vm_protect)( Addr a, SizeT len, UInt prot ); + #endif + ++extern void VG_(addr_load_di)( Addr a ); ++ ++extern void VG_(load_di)( DebugInfo *di, Addr a ); ++ + extern void VG_(di_discard_ALL_debuginfo)( void ); + + /* Like VG_(get_fnname), but it does not do C++ demangling nor Z-demangling +-- +2.41.0 + diff --git a/valgrind.spec b/valgrind.spec index c9b719f..d630003 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 9%{?dist} +Release: 10%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -116,6 +116,12 @@ Patch12: valgrind-3.21.0-pgste.patch # https://bugs.kde.org/show_bug.cgi?id=471311 Patch13: valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch +# Add support for lazy reading and downloading of DWARF debuginfo +# https://bugs.kde.org/show_bug.cgi?id=471807 +# Plus fixup commit a0d555a0dfe078ef04ea49d991a8090ab14bd4a5 +Patch14: valgrind-3.21.0-lazy-debuginfo.patch +Patch15: valgrind-3.21.0-cleanup-read_elf_object.patch + BuildRequires: make BuildRequires: glibc-devel @@ -262,6 +268,8 @@ Valgrind User Manual for details. %patch -P11 -p1 %patch -P12 -p1 %patch -P13 -p1 +%patch -P14 -p1 +%patch -P15 -p1 %build @@ -495,6 +503,10 @@ fi %endif %changelog +* Mon Aug 21 2023 Mark Wielaard - 3.21.0-10 +- Add valgrind-3.21.0-lazy-debuginfo.patch +- Add valgrind-3.21.0-cleanup-read_elf_object.patch + * Thu Aug 17 2023 Mark Wielaard - 3.21.0-9 - Add valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch - Use %%patch -Pn instead of deprecated %%patchn From e5b933a45435757357f5afde7f00469cae54e102 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 18 Oct 2023 01:44:53 +0200 Subject: [PATCH 24/86] 3.22.0-0.1.RC1 - Upstream 3.22.0-RC1 - Remove all upstreamed patches - Adjust valgrind-3.16.0-some-stack-protector.patch - Adjust valgrind-3.16.0-some-Wl-z-now.patch - Add cachegrind.h to valgrind-devel package --- .gitignore | 1 + sources | 2 +- valgrind-3.16.0-some-Wl-z-now.patch | 4 +- valgrind-3.16.0-some-stack-protector.patch | 4 +- valgrind-3.21.0-Add-with-gdbscripts-dir.patch | 123 --- ...d-3.21.0-callgrind_control-no-strict.patch | 12 - valgrind-3.21.0-cleanup-read_elf_object.patch | 58 -- valgrind-3.21.0-epoll_pwait2.patch | 217 ----- ...ti-mode-stdout-redirecting-to-stderr.patch | 85 -- valgrind-3.21.0-lazy-debuginfo.patch | 850 ------------------ valgrind-3.21.0-pgste.patch | 73 -- valgrind-3.21.0-realloc-again.patch | 167 ---- valgrind-3.21.0-vgm-tests.patch | 105 --- valgrind-3.21.0-vgm.patch | 99 -- valgrind.spec | 62 +- 15 files changed, 18 insertions(+), 1844 deletions(-) delete mode 100644 valgrind-3.21.0-Add-with-gdbscripts-dir.patch delete mode 100644 valgrind-3.21.0-callgrind_control-no-strict.patch delete mode 100644 valgrind-3.21.0-cleanup-read_elf_object.patch delete mode 100644 valgrind-3.21.0-epoll_pwait2.patch delete mode 100644 valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch delete mode 100644 valgrind-3.21.0-lazy-debuginfo.patch delete mode 100644 valgrind-3.21.0-pgste.patch delete mode 100644 valgrind-3.21.0-realloc-again.patch delete mode 100644 valgrind-3.21.0-vgm-tests.patch delete mode 100644 valgrind-3.21.0-vgm.patch diff --git a/.gitignore b/.gitignore index 85a4432..3f735f2 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ /valgrind-3.21.0.RC1.tar.bz2 /valgrind-3.21.0.RC2.tar.bz2 /valgrind-3.21.0.tar.bz2 +/valgrind-3.22.0.RC1.tar.bz2 diff --git a/sources b/sources index efed6a2..e2e8ed5 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.21.0.tar.bz2) = 3e86cda2f2d6cd30807fac7933ba2c46a97a2b4a868db989e6b0cceeadf029af7ee34ba900466a346948289aacb30f4399799bb83b97cc49a4d2d810441e5cfd +SHA512 (valgrind-3.22.0.RC1.tar.bz2) = 0aa9e98a959808d20cce53575433f81973ef3de3acc313ef2700f58cf9b2b7ee951b5bc701ef8508f5c136cb14239bbe7d81ae4208679ba55150b3edfd6078f0 diff --git a/valgrind-3.16.0-some-Wl-z-now.patch b/valgrind-3.16.0-some-Wl-z-now.patch index 6231733..f6001d2 100644 --- a/valgrind-3.16.0-some-Wl-z-now.patch +++ b/valgrind-3.16.0-some-Wl-z-now.patch @@ -48,8 +48,8 @@ index 3c73210..fb6b7bb 100644 # If there is no secondary platform, and the platforms include x86-darwin, # then the primary platform must be x86-darwin. Hence: if ! VGCONF_HAVE_PLATFORM_SEC -@@ -96,7 +96,7 @@ endif - vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) +@@ -104,7 +104,7 @@ + vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) $(GDB_SCRIPTS_DIR) vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI) -vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ diff --git a/valgrind-3.16.0-some-stack-protector.patch b/valgrind-3.16.0-some-stack-protector.patch index b53c465..751cf39 100644 --- a/valgrind-3.16.0-some-stack-protector.patch +++ b/valgrind-3.16.0-some-stack-protector.patch @@ -94,10 +94,10 @@ index 94030fd..3c73210 100644 valgrind_CCASFLAGS = $(AM_CCASFLAGS_PRI) valgrind_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ # If there is no secondary platform, and the platforms include x86-darwin, -@@ -94,7 +94,7 @@ vgdb_SOURCES += vgdb-invoker-solaris.c +@@ -102,7 +102,7 @@ endif - vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) + vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) $(GDB_SCRIPTS_DIR) -vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) +vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI) diff --git a/valgrind-3.21.0-Add-with-gdbscripts-dir.patch b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch deleted file mode 100644 index 5f8b4f9..0000000 --- a/valgrind-3.21.0-Add-with-gdbscripts-dir.patch +++ /dev/null @@ -1,123 +0,0 @@ -From e97f7a6cf2315908fb0a9b900f1de87a155c9df1 Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Sun, 14 May 2023 23:34:05 +0200 -Subject: [PATCH] Add --with-gdbscripts-dir=PATH configure option - -Currently the gdb valgrind scripts are installed under VG_LIBDIR -which is normally pkglibexecdir which is likely not in the default -gdb safe-path (a list of directories from which it is safe to -auto-load files). So users will have to add the directory to their -.gdbinit file. - -This patch adds a --with-gdbscripts-dir=PATH configure option that -sets VG_GDBSCRIPTS_DIR to the given PATH (${libexecdir}/valgrind if -not given). - -Use VG_GDBSCRIPTS_DIR as gdbscriptsdir to install the valgrind-monitor -python files and pass it with CPPFLAGS when building vg_preloaded.c -and vgdb.c to use instead of VG_LIBDIR. ---- - configure.ac | 11 +++++++++++ - coregrind/Makefile.am | 15 ++++++++++----- - coregrind/vg_preloaded.c | 2 +- - coregrind/vgdb.c | 2 +- - 4 files changed, 23 insertions(+), 7 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 15fbf5ea2..223ab4529 100755 ---- a/configure.ac -+++ b/configure.ac -@@ -1198,6 +1198,17 @@ AC_MSG_RESULT([$xcodedir]) - AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory]) - AC_SUBST(XCODE_DIR, [$xcodedir])]) - -+#---------------------------------------------------------------------------- -+# Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir) -+#---------------------------------------------------------------------------- -+AC_MSG_CHECKING([where gdb scripts are installed]) -+AC_ARG_WITH(gdbscripts-dir, -+ [ --with-gdbscripts-dir=PATH Specify path to install gdb scripts], -+ [gdbscriptsdir=${withval}], -+ [gdbscriptsdir=${libexecdir}/valgrind]) -+AC_MSG_RESULT([$gdbscriptsdir]) -+AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir]) -+ - #---------------------------------------------------------------------------- - # Libc and suppressions - #---------------------------------------------------------------------------- -diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am -index 553211782..64d593b08 100644 ---- a/coregrind/Makefile.am -+++ b/coregrind/Makefile.am -@@ -101,7 +101,8 @@ - vgdb_SOURCES += vgdb-invoker-freebsd.c - endif - --vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) -+vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) \ -+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" - vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong - vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI) - vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ -Wl,-z,now -@@ -626,7 +627,8 @@ - - vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c - vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = \ -- $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) -+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) \ -+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" - vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS = \ - $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@) - vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \ -@@ -634,7 +636,8 @@ - if VGCONF_HAVE_PLATFORM_SEC - vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c - vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = \ -- $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) -+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) \ -+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" - vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS = \ - $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@) - vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \ -@@ -766,8 +769,10 @@ - # so as to make sure these get copied into the install tree - vglibdir = $(pkglibexecdir) - vglib_DATA = $(GDBSERVER_XML_FILES) --vglib_DATA += m_gdbserver/valgrind-monitor.py --vglib_DATA += m_gdbserver/valgrind-monitor-def.py -+ -+gdbscriptsdir = @VG_GDBSCRIPTS_DIR@ -+gdbscripts_DATA = m_gdbserver/valgrind-monitor.py -+gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py - - # so as to make sure these get copied into the tarball - EXTRA_DIST += $(GDBSERVER_XML_FILES) -diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c -index d6e05898c..bff76b81b 100644 ---- a/coregrind/vg_preloaded.c -+++ b/coregrind/vg_preloaded.c -@@ -61,7 +61,7 @@ - .popsection \n\ - "); - --DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py") -+DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py") - #endif - - #if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) -diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c -index 8ec424077..a449b86e0 100644 ---- a/coregrind/vgdb.c -+++ b/coregrind/vgdb.c -@@ -1984,7 +1984,7 @@ void usage(void) - " -h --help shows this message\n" - " The GDB python code defining GDB front end valgrind commands is:\n %s\n" - " To get help from the Valgrind gdbserver, use vgdb help\n" --"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py" -+"\n", vgdb_prefix_default(), VG_GDBSCRIPTS_DIR "/valgrind-monitor.py" - ); - invoker_restrictions_msg(); - } --- -2.40.0 - diff --git a/valgrind-3.21.0-callgrind_control-no-strict.patch b/valgrind-3.21.0-callgrind_control-no-strict.patch deleted file mode 100644 index 2aaecd4..0000000 --- a/valgrind-3.21.0-callgrind_control-no-strict.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in -index 083ffa29f..eb50c16ad 100644 ---- a/callgrind/callgrind_control.in -+++ b/callgrind/callgrind_control.in -@@ -22,7 +22,6 @@ - # You should have received a copy of the GNU General Public License - # along with this program; if not, see . - --use strict; - use warnings; - - use File::Basename; diff --git a/valgrind-3.21.0-cleanup-read_elf_object.patch b/valgrind-3.21.0-cleanup-read_elf_object.patch deleted file mode 100644 index c81ca94..0000000 --- a/valgrind-3.21.0-cleanup-read_elf_object.patch +++ /dev/null @@ -1,58 +0,0 @@ -From a0d555a0dfe078ef04ea49d991a8090ab14bd4a5 Mon Sep 17 00:00:00 2001 -From: Paul Floyd -Date: Sat, 19 Aug 2023 21:37:33 +0200 -Subject: [PATCH] Always cleanup on exit from ML_(read_elf_object) - -I'm still a but baffled as to why this wasn't seen earlier. -A FreeBSD testcase started failing with kernel 13.2 patch 2, -which is quite a minor change. The testcase gets an fd from -pdfork and the parent does a printf with the fd then zaps the -process with pdkill. Standalone the fd is 3, and that's what -the expected contains. However, when it started failing I saw -with lsof that fds 3 and 4 were associated with the guest exe -and ld-elf.so.1. ---- - coregrind/m_debuginfo/readelf.c | 16 +++++++--------- - 1 file changed, 7 insertions(+), 9 deletions(-) - -diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c -index f99d3dfd2..ac72f98fb 100644 ---- a/coregrind/m_debuginfo/readelf.c -+++ b/coregrind/m_debuginfo/readelf.c -@@ -1916,6 +1916,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) - Word i, j; - Bool dynbss_present = False; - Bool sdynbss_present = False; -+ Bool retval = False; - - /* Image for the main ELF file we're working with. */ - DiImage* mimg = NULL; -@@ -2944,19 +2945,16 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) - } - } - -- return True; -+ retval = True; - -- out: -- { -- /* Last, but not least, detach from the image. */ -- if (mimg) ML_(img_done)(mimg); -+ out: - -- if (svma_ranges) VG_(deleteXA)(svma_ranges); -+ /* Last, but not least, detach from the image. */ -+ if (mimg) ML_(img_done)(mimg); - -- return False; -- } /* out: */ -+ if (svma_ranges) VG_(deleteXA)(svma_ranges); - -- /* NOTREACHED */ -+ return retval; - } - - Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) --- -2.41.0 - diff --git a/valgrind-3.21.0-epoll_pwait2.patch b/valgrind-3.21.0-epoll_pwait2.patch deleted file mode 100644 index 0a5dd67..0000000 --- a/valgrind-3.21.0-epoll_pwait2.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 17f56ab4c4fce7b4778251e1fab2bc50e5c6dbda Mon Sep 17 00:00:00 2001 -From: Olli Vanhoja -Date: Mon, 10 Oct 2022 11:44:22 +0200 -Subject: [PATCH] Add epoll_pwait2 - -The only difference between epoll_pwait and epoll_pwait2 is the -timeout argument. For epoll_pwait2 this is a timespec (which is -always 64bit). - -https://bugs.kde.org/show_bug.cgi?id=460192 ---- - NEWS | 1 + - coregrind/m_syswrap/priv_syswrap-linux.h | 1 + - coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-linux.c | 23 ++++++++++++++++++++ - coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + - coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + - coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ - include/vki/vki-scnums-shared-linux.h | 2 ++ - 14 files changed, 45 insertions(+) - -diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h -index a73b6247e..7c9decf5a 100644 ---- a/coregrind/m_syswrap/priv_syswrap-linux.h -+++ b/coregrind/m_syswrap/priv_syswrap-linux.h -@@ -105,6 +105,7 @@ DECL_TEMPLATE(linux, sys_epoll_create1); - DECL_TEMPLATE(linux, sys_epoll_ctl); - DECL_TEMPLATE(linux, sys_epoll_wait); - DECL_TEMPLATE(linux, sys_epoll_pwait); -+DECL_TEMPLATE(linux, sys_epoll_pwait2); - DECL_TEMPLATE(linux, sys_eventfd); - DECL_TEMPLATE(linux, sys_eventfd2); - -diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c -index 1aeebd274..008600798 100644 ---- a/coregrind/m_syswrap/syswrap-amd64-linux.c -+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c -@@ -883,6 +883,8 @@ static SyscallTableEntry syscall_table[] = { - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 - }; - -diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c -index bca509589..9a7a1e0d2 100644 ---- a/coregrind/m_syswrap/syswrap-arm-linux.c -+++ b/coregrind/m_syswrap/syswrap-arm-linux.c -@@ -1057,6 +1057,8 @@ static SyscallTableEntry syscall_main_table[] = { - LINXY(__NR_close_range, sys_close_range), // 436 - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 -+ -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - }; - - -diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c -index 953236000..6af7bab83 100644 ---- a/coregrind/m_syswrap/syswrap-arm64-linux.c -+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c -@@ -837,6 +837,8 @@ static SyscallTableEntry syscall_main_table[] = { - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 - }; - -diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c -index 26f1fbee3..f8621f8f0 100644 ---- a/coregrind/m_syswrap/syswrap-linux.c -+++ b/coregrind/m_syswrap/syswrap-linux.c -@@ -2165,6 +2165,29 @@ POST(sys_epoll_pwait) - epoll_post_helper (tid, arrghs, status); - } - -+PRE(sys_epoll_pwait2) -+{ -+ *flags |= SfMayBlock; -+ PRINT("sys_epoll_pwait2 ( %ld, %#" FMT_REGWORD "x, %ld, %#" -+ FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", -+ SARG1, ARG2, SARG3, ARG4, ARG5, ARG6); -+ PRE_REG_READ6(long, "epoll_pwait2", -+ int, epfd, struct vki_epoll_event *, events, -+ int, maxevents, const struct timespec64 *, timeout, -+ vki_sigset_t *, sigmask, vki_size_t, sigsetsize); -+ /* Assume all (maxevents) events records should be (fully) writable. */ -+ PRE_MEM_WRITE( "epoll_pwait2(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3); -+ /* epoll_pwait2 only supports 64bit timespec. */ -+ if (ARG4) -+ pre_read_timespec64(tid, "epoll_pwait2(timeout)", ARG4); -+ if (ARG5) -+ PRE_MEM_READ( "epoll_pwait2(sigmask)", ARG5, sizeof(vki_sigset_t) ); -+} -+POST(sys_epoll_pwait2) -+{ -+ epoll_post_helper (tid, arrghs, status); -+} -+ - PRE(sys_eventfd) - { - PRINT("sys_eventfd ( %" FMT_REGWORD "u )", ARG1); -diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c -index de27998b3..6268a00dd 100644 ---- a/coregrind/m_syswrap/syswrap-mips32-linux.c -+++ b/coregrind/m_syswrap/syswrap-mips32-linux.c -@@ -1141,6 +1141,8 @@ static SyscallTableEntry syscall_main_table[] = { - LINXY(__NR_close_range, sys_close_range), // 436 - - LINX_ (__NR_faccessat2, sys_faccessat2), // 439 -+ -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) -diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c -index 67e7c2c2f..6cdf25893 100644 ---- a/coregrind/m_syswrap/syswrap-mips64-linux.c -+++ b/coregrind/m_syswrap/syswrap-mips64-linux.c -@@ -819,6 +819,7 @@ static SyscallTableEntry syscall_main_table[] = { - GENX_ (__NR_clone3, sys_ni_syscall), - LINXY (__NR_close_range, sys_close_range), - LINX_ (__NR_faccessat2, sys_faccessat2), -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), - }; - - SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c -index 9c535c68e..d724cde74 100644 ---- a/coregrind/m_syswrap/syswrap-nanomips-linux.c -+++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c -@@ -828,6 +828,7 @@ static SyscallTableEntry syscall_main_table[] = { - GENX_ (__NR_clone3, sys_ni_syscall), - LINXY (__NR_close_range, sys_close_range), - LINX_ (__NR_faccessat2, sys_faccessat2), -+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) -diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c -index 12c073027..c0cfef235 100644 ---- a/coregrind/m_syswrap/syswrap-ppc32-linux.c -+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c -@@ -1061,6 +1061,8 @@ static SyscallTableEntry syscall_table[] = { - LINXY(__NR_close_range, sys_close_range), // 436 - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 -+ -+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c -index 3c33d1267..f5976f30c 100644 ---- a/coregrind/m_syswrap/syswrap-ppc64-linux.c -+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c -@@ -1030,6 +1030,8 @@ static SyscallTableEntry syscall_table[] = { - LINXY(__NR_close_range, sys_close_range), // 436 - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 -+ -+ LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c -index a377cb731..afba154e7 100644 ---- a/coregrind/m_syswrap/syswrap-s390x-linux.c -+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c -@@ -871,6 +871,8 @@ static SyscallTableEntry syscall_table[] = { - LINXY(__NR_close_range, sys_close_range), // 436 - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 -+ -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c -index a9ba15dfe..da4fd8fa2 100644 ---- a/coregrind/m_syswrap/syswrap-x86-linux.c -+++ b/coregrind/m_syswrap/syswrap-x86-linux.c -@@ -1655,6 +1655,8 @@ static SyscallTableEntry syscall_table[] = { - - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - -+ LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 - }; - -diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h -index d90cdd312..542382b53 100644 ---- a/include/vki/vki-scnums-shared-linux.h -+++ b/include/vki/vki-scnums-shared-linux.h -@@ -46,6 +46,8 @@ - - #define __NR_faccessat2 439 - -+#define __NR_epoll_pwait2 441 -+ - #define __NR_memfd_secret 447 - - #endif --- -2.40.1 - diff --git a/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch b/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch deleted file mode 100644 index 92d97d0..0000000 --- a/valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 449dd82becae6533a8e658e76f30f65434f6417f Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Thu, 17 Aug 2023 15:40:30 +0200 -Subject: [PATCH] gdb --multi mode stdout redirecting to stderr - -When in stdio mode (talking to gdb through stdin/stdout, not -through a socket), redirect stdout to stderr and close stdin -for the inferior. That way at least some output can be seen, -but there will be no input. - -This is workaround till we have real terminal handling. - - * coregrind/vgdb.c (main): Pass in_port to do_multi_mode. - (do_multi_mode): Pass in_port to fork_and_exec_valgrind. - (fork_and_exec_valgrind): Close stdin, redirect stdout to - stderr if in_port <= 0. - -https://bugs.kde.org/show_bug.cgi?id=471311 ---- - NEWS | 1 + - coregrind/vgdb.c | 20 +++++++++++++++++--- - 2 files changed, 18 insertions(+), 3 deletions(-) - -diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c -index 56a969de7..c024ffca6 100644 ---- a/coregrind/vgdb.c -+++ b/coregrind/vgdb.c -@@ -1159,7 +1159,7 @@ static void gdb_relay(int pid, int send_noack_mode, char *q_buf); - or the errno from the child on failure. */ - static - int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, -- pid_t *pid) -+ int in_port, pid_t *pid) - { - int err = 0; - // We will use a pipe to track what the child does, -@@ -1243,6 +1243,19 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, - } - } - -+ /* When in stdio mode (talking to gdb through stdin/stdout, not -+ through a socket), redirect stdout to stderr and close stdin -+ for the inferior. That way at least some output can be seen, -+ but there will be no input. */ -+ if (in_port <= 0) { -+ /* close stdin */ -+ close (0); -+ /* open /dev/null as new stdin */ -+ open ("/dev/null", O_RDONLY); -+ /* redirect stdout as stderr */ -+ dup2 (2, 1); -+ } -+ - /* Try to launch valgrind. Add --vgdb-error=0 to stop immediately so we - can attach and --launched-with-multi to let valgrind know it doesn't - need to show a banner how to connect to gdb, we will do that -@@ -1309,7 +1322,7 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir, - - /* Do multi stuff. */ - static --void do_multi_mode(int check_trials) -+void do_multi_mode(int check_trials, int in_port) - { - char *buf = vmalloc(PBUFSIZ+1); - char *q_buf = vmalloc(PBUFSIZ+1); //save the qSupported packet sent by gdb -@@ -1459,6 +1472,7 @@ void do_multi_mode(int check_trials) - int res = fork_and_exec_valgrind (count, - decoded_string, - working_dir, -+ in_port, - &valgrind_pid); - - if (res == 0) { -@@ -2427,7 +2441,7 @@ int main(int argc, char** argv) - if (multi_mode) { - /* check_trails is the --wait argument in seconds, defaulting to 1 - * if not given. */ -- do_multi_mode (check_trials); -+ do_multi_mode (check_trials, in_port); - } else if (last_command >= 0) { - standalone_send_commands(pid, last_command, commands); - } else { --- -2.41.0 - diff --git a/valgrind-3.21.0-lazy-debuginfo.patch b/valgrind-3.21.0-lazy-debuginfo.patch deleted file mode 100644 index 6500abc..0000000 --- a/valgrind-3.21.0-lazy-debuginfo.patch +++ /dev/null @@ -1,850 +0,0 @@ -From 60f7e89ba32b54d73b9e36d49e28d0f559ade0b9 Mon Sep 17 00:00:00 2001 -From: Aaron Merey -Date: Fri, 30 Jun 2023 18:31:42 -0400 -Subject: [PATCH] Support lazy reading and downloading of DWARF debuginfo - -Currently valgrind attempts to read DWARF .debug_* sections as well -as separate debuginfo files for ELF binaries as soon as a shared library -is loaded. This might also result in the downloading of separate debuginfo -files via debuginfod. - -This is inefficient when some of this debuginfo never ends up being used -by valgrind while running the client process. - -This patch adds support for lazy reading and downloading of DWARF -debuginfo. When an ELF shared library is loaded, the reading of .debug_* -sections as well as separate or alternate debuginfo is deferred until -valgrind handles an instruction pointer corresponding to a text segment -of the shared library. At this point the deferred sections and separate -debug files are loaded. - -This feature is only supported on ELF platforms. - -https://bugs.kde.org/show_bug.cgi?id=471807 - -ChangeLog - * debuginfo.c (di_notify_ACHIEVE_ACCEPT_STATE): Replace - read_elf_debug_info with read_elf_object. - (addr_load_di): New function. Attempts to load deferred debuginfo - associated with a given address. - (load_di): New function. Attempts to load a given deferred - debuginfo associated with a given address. - (describe_IP): Add calls to load_di and addr_load_di. - (find_DiCfSI): Add call to load_di. - - * priv_readelf.h (read_elf_object): New declaration. - (read_elf_debug): Ditto. - - * priv_storage.h (struct _DebugInfo): New field 'bool deferred'. - - * readelf.c (read_elf_debug_info): Split into read_elf_object and - read_elf_debug. - (read_elf_object): Read non .debug_* section from an ELF binary. - (read_elf_debug): Read .debug_* sections from an ELF binary as - as well any separate/alternate debuginfo files. - - * storage.c (canonicaliseSymtab): Remove assert in order to support - canonicalization of deferred _DebugInfo. - (finish_CFSI_arrays): Add early return if _DebugInfo is - deferred in order to avoid freeing memory that will be needed - when reading debuginfo at a later time. - (canonicaliseTables): Ditto. - - * pub_core_debuginfo.h (addr_load_di): New declaration. - (load_di): New declaration. ---- - NEWS | 1 + - coregrind/m_debuginfo/debuginfo.c | 57 +++- - coregrind/m_debuginfo/priv_readelf.h | 24 +- - coregrind/m_debuginfo/priv_storage.h | 7 + - coregrind/m_debuginfo/readelf.c | 437 ++++++++++++++++++--------- - coregrind/m_debuginfo/storage.c | 13 +- - coregrind/pub_core_debuginfo.h | 4 + - 7 files changed, 379 insertions(+), 164 deletions(-) - -diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c -index 22b41def2..8d1fdc696 100644 ---- a/coregrind/m_debuginfo/debuginfo.c -+++ b/coregrind/m_debuginfo/debuginfo.c -@@ -959,14 +959,16 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di ) - discard_DebugInfos_which_overlap_with( di ); - - /* The DebugInfoMappings that now exist in the FSM may involve -- overlaps. This confuses ML_(read_elf_debug_info), and may cause -+ overlaps. This confuses ML_(read_elf_*), and may cause - it to compute wrong biases. So de-overlap them now. - See http://bugzilla.mozilla.org/show_bug.cgi?id=788974 */ - truncate_DebugInfoMapping_overlaps( di, di->fsm.maps ); - - /* And acquire new info. */ - # if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) -- ok = ML_(read_elf_debug_info)( di ); -+ ok = ML_(read_elf_object)( di ); -+ if (ok) -+ di->deferred = True; - # elif defined(VGO_darwin) - ok = ML_(read_macho_debug_info)( di ); - # else -@@ -1443,6 +1445,50 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) - } - } - -+/* Load DI if it has a text segment containing A and DI hasn't already -+ been loaded. */ -+ -+void VG_(load_di)( DebugInfo *di, Addr a) -+{ -+ if (!di->deferred -+ || !di->text_present -+ || di->text_size <= 0 -+ || di->text_avma > a -+ || a >= di->text_avma + di->text_size) -+ return; -+ -+ di->deferred = False; -+ ML_(read_elf_debug) (di); -+ ML_(canonicaliseTables)( di ); -+ -+ /* Check invariants listed in -+ Comment_on_IMPORTANT_REPRESENTATIONAL_INVARIANTS in -+ priv_storage.h. */ -+ check_CFSI_related_invariants(di); -+ ML_(finish_CFSI_arrays)(di); -+} -+ -+/* Attempt to load DebugInfo with a text segment containing A, -+ if such a debuginfo hasn't already been loaded. */ -+ -+void VG_(addr_load_di)( Addr a ) -+{ -+ DebugInfo *di; -+ -+ di = VG_(find_DebugInfo)(VG_(current_DiEpoch)(), a); -+ if (di != NULL) -+ if (di->deferred) { -+ di->deferred = False; -+ ML_(read_elf_debug) (di); -+ ML_(canonicaliseTables)( di ); -+ -+ /* Check invariants listed in -+ Comment_on_IMPORTANT_REPRESENTATIONAL_INVARIANTS in -+ priv_storage.h. */ -+ check_CFSI_related_invariants(di); -+ ML_(finish_CFSI_arrays)(di); -+ } -+} - - /* Unmap is simpler - throw away any SegInfos intersecting - [a, a+len). */ -@@ -2746,6 +2792,11 @@ const HChar* VG_(describe_IP)(DiEpoch ep, Addr eip, const InlIPCursor *iipc) - Bool know_objname; - Bool know_srcloc; - -+ if (iipc && iipc->di) -+ VG_(load_di) (iipc->di, eip); -+ else -+ VG_(addr_load_di) (eip); -+ - if (is_bottom(iipc)) { - // At the bottom (towards main), we describe the fn at eip. - know_fnname = VG_(clo_sym_offsets) -@@ -3090,6 +3141,8 @@ static void find_DiCfSI ( /*OUT*/DebugInfo** diP, - if (!is_DI_valid_for_epoch(di, curr_epoch)) - continue; - -+ VG_(load_di)(di, ip); -+ - /* Use the per-DebugInfo summary address ranges to skip - inapplicable DebugInfos quickly. */ - if (di->cfsi_used == 0) -diff --git a/coregrind/m_debuginfo/priv_readelf.h b/coregrind/m_debuginfo/priv_readelf.h -index 57aa0cc3f..7e0fa17c9 100644 ---- a/coregrind/m_debuginfo/priv_readelf.h -+++ b/coregrind/m_debuginfo/priv_readelf.h -@@ -44,13 +44,23 @@ - extern Bool ML_(is_elf_object_file)( const void* image, SizeT n_image, - Bool rel_ok ); - --/* The central function for reading ELF debug info. For the -- object/exe specified by the SegInfo, find ELF sections, then read -- the symbols, line number info, file name info, CFA (stack-unwind -- info) and anything else we want, into the tables within the -- supplied SegInfo. --*/ --extern Bool ML_(read_elf_debug_info) ( DebugInfo* di ); -+/* Read the ELF binary specified by DI. For the object/exe specified -+ by the SegInfo, find ELF sections, then read the symbols, line number -+ info, file name info, CFA (stack-unwind info) and anything else we -+ want, into the tables within the supplied SegInfo. -+ -+ .debug_* sections as well as any separate debuginfo files are not -+ loaded by this function but instead by ML_(read_elf_debug). This -+ separation facilitates lazy loading of debuginfo. */ -+extern Bool ML_(read_elf_object) ( DebugInfo* di ); -+ -+/* Read .debug_* sections from the ELF binary specified by DI. Also -+ attempt to load any separate debuginfo files associated with the -+ object. -+ -+ ML_(read_elf_object) should be called on DI before calling this -+ function. */ -+extern Bool ML_(read_elf_debug) ( DebugInfo* di ); - - extern Bool ML_(check_elf_and_get_rw_loads) ( Int fd, const HChar* filename, Int * rw_load_count ); - -diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h -index a4b90d36b..b959873ab 100644 ---- a/coregrind/m_debuginfo/priv_storage.h -+++ b/coregrind/m_debuginfo/priv_storage.h -@@ -678,6 +678,13 @@ struct _DebugInfo { - invalid and should not be consulted. */ - Bool have_dinfo; /* initially False */ - -+ /* If true then the reading of .debug_* section has been deferred -+ until it this information is required (such as when printing -+ a stacktrace). Additionally, if true then the reading of any -+ separate debuginfo files associated with this object has also -+ been deferred. */ -+ Bool deferred; -+ - /* All the rest of the fields in this structure are filled in once - we have committed to reading the symbols and debug info (that - is, at the point where .have_dinfo is set to True). */ -diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c -index ce7b7998d..f99d3dfd2 100644 ---- a/coregrind/m_debuginfo/readelf.c -+++ b/coregrind/m_debuginfo/readelf.c -@@ -1836,6 +1836,44 @@ static HChar* readlink_path (const HChar *path) - return buf; - } - -+#define FINDX_MIMG(_sec_name, _sec_escn, _post_fx) \ -+ do { \ -+ ElfXX_Shdr a_shdr; \ -+ ML_(img_get)(&a_shdr, mimg, \ -+ INDEX_BIS(shdr_mioff, i, shdr_ment_szB), \ -+ sizeof(a_shdr)); \ -+ if (0 == ML_(img_strcmp_c)(mimg, shdr_strtab_mioff \ -+ + a_shdr.sh_name, _sec_name)) { \ -+ Bool nobits; \ -+ _sec_escn.img = mimg; \ -+ _sec_escn.ioff = (DiOffT)a_shdr.sh_offset; \ -+ _sec_escn.szB = a_shdr.sh_size; \ -+ if (!check_compression(&a_shdr, &_sec_escn)) { \ -+ ML_(symerr)(di, True, " Compression type is unsupported"); \ -+ goto out; \ -+ } \ -+ nobits = a_shdr.sh_type == SHT_NOBITS; \ -+ vg_assert(_sec_escn.img != NULL); \ -+ vg_assert(_sec_escn.ioff != DiOffT_INVALID); \ -+ TRACE_SYMTAB( "%-18s: ioff %llu .. %llu\n", \ -+ _sec_name, (ULong)a_shdr.sh_offset, \ -+ ((ULong)a_shdr.sh_offset) + a_shdr.sh_size - 1); \ -+ /* SHT_NOBITS sections have zero size in the file. */ \ -+ if (!nobits && \ -+ a_shdr.sh_offset + \ -+ a_shdr.sh_size > ML_(img_real_size)(mimg)) { \ -+ ML_(symerr)(di, True, \ -+ " section beyond image end?!"); \ -+ goto out; \ -+ } \ -+ _post_fx; \ -+ } \ -+ } while (0); -+ -+/* Version with no post-effects */ -+#define FIND_MIMG(_sec_name, _sec_escn) \ -+ FINDX_MIMG(_sec_name, _sec_escn, /**/) -+ - /* The central function for reading ELF debug info. For the - object/exe specified by the DebugInfo, find ELF sections, then read - the symbols, line number info, file name info, CFA (stack-unwind -@@ -1843,7 +1881,7 @@ static HChar* readlink_path (const HChar *path) - supplied DebugInfo. - */ - --Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) -+Bool ML_(read_elf_object) ( struct _DebugInfo* di ) - { - /* This function is long and complex. That, and the presence of - nested scopes, means it's not always easy to see which parts are -@@ -1874,7 +1912,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - - - /* TOPLEVEL */ -- Bool res, ok; -+ Bool ok; - Word i, j; - Bool dynbss_present = False; - Bool sdynbss_present = False; -@@ -1882,12 +1920,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - /* Image for the main ELF file we're working with. */ - DiImage* mimg = NULL; - -- /* Ditto for any ELF debuginfo file that we might happen to load. */ -- DiImage* dimg = NULL; -- -- /* Ditto for alternate ELF debuginfo file that we might happen to load. */ -- DiImage* aimg = NULL; -- - /* ELF header offset for the main file. Should be zero since the - ELF header is at start of file. */ - DiOffT ehdr_mioff = 0; -@@ -1970,8 +2002,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - got, plt, and toc. - ---------------------------------------------------------- */ - -- res = False; -- - if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir)) - VG_(message)(Vg_DebugMsg, "Reading syms from %s\n", - di->fsm.filename ); -@@ -2056,7 +2086,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - shdr_strtab_mioff - = ehdr_mioff /* isn't this always zero? */ + a_shdr.sh_offset; - -- if (!ML_(img_valid)(mimg, shdr_strtab_mioff, -+ if (!ML_(img_valid)(mimg, shdr_strtab_mioff, - 1/*bogus, but we don't know the real size*/ )) { - ML_(symerr)(di, True, "Invalid ELF Section Header String Table"); - goto out; -@@ -2798,10 +2828,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - di->text_avma - di->text_bias, - di->text_avma ); - -- TRACE_SYMTAB("\n"); -- TRACE_SYMTAB("------ Finding image addresses " -- "for debug-info sections ------\n"); -- - /* TOPLEVEL */ - /* Find interesting sections, read the symbol table(s), read any - debug information. Each section is located either in the main, -@@ -2821,27 +2847,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - # if defined(VGO_solaris) - DiSlice ldynsym_escn = DiSlice_INVALID; // .SUNW_ldynsym - # endif -- DiSlice debuglink_escn = DiSlice_INVALID; // .gnu_debuglink -- DiSlice debugaltlink_escn = DiSlice_INVALID; // .gnu_debugaltlink -- DiSlice debug_line_escn = DiSlice_INVALID; // .debug_line (dwarf2) -- DiSlice debug_info_escn = DiSlice_INVALID; // .debug_info (dwarf2) -- DiSlice debug_types_escn = DiSlice_INVALID; // .debug_types (dwarf4) -- DiSlice debug_abbv_escn = DiSlice_INVALID; // .debug_abbrev (dwarf2) -- DiSlice debug_str_escn = DiSlice_INVALID; // .debug_str (dwarf2) -- DiSlice debug_line_str_escn = DiSlice_INVALID; // .debug_line_str(dwarf5) -- DiSlice debug_ranges_escn = DiSlice_INVALID; // .debug_ranges (dwarf2) -- DiSlice debug_rnglists_escn = DiSlice_INVALID; // .debug_rnglists(dwarf5) -- DiSlice debug_loclists_escn = DiSlice_INVALID; // .debug_loclists(dwarf5) -- DiSlice debug_addr_escn = DiSlice_INVALID; // .debug_addr (dwarf5) -- DiSlice debug_str_offsets_escn = DiSlice_INVALID; // .debug_str_offsets (dwarf5) -- DiSlice debug_loc_escn = DiSlice_INVALID; // .debug_loc (dwarf2) -- DiSlice debug_frame_escn = DiSlice_INVALID; // .debug_frame (dwarf2) -- DiSlice debug_line_alt_escn = DiSlice_INVALID; // .debug_line (alt) -- DiSlice debug_info_alt_escn = DiSlice_INVALID; // .debug_info (alt) -- DiSlice debug_abbv_alt_escn = DiSlice_INVALID; // .debug_abbrev (alt) -- DiSlice debug_str_alt_escn = DiSlice_INVALID; // .debug_str (alt) -- DiSlice dwarf1d_escn = DiSlice_INVALID; // .debug (dwarf1) -- DiSlice dwarf1l_escn = DiSlice_INVALID; // .line (dwarf1) - DiSlice opd_escn = DiSlice_INVALID; // .opd (dwarf2, - // ppc64be-linux) - DiSlice ehframe_escn[N_EHFRAME_SECTS]; // .eh_frame (dwarf2) -@@ -2868,118 +2873,282 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - /* TOPLEVEL */ - /* Iterate over section headers (again) */ - for (i = 0; i < ehdr_m.e_shnum; i++) { -+ /* NAME ElfSec */ -+ FIND_MIMG( ".dynsym", dynsym_escn) -+ FIND_MIMG( ".dynstr", dynstr_escn) -+ FIND_MIMG( ".symtab", symtab_escn) -+ FIND_MIMG( ".strtab", strtab_escn) -+# if defined(VGO_solaris) -+ FIND_MIMG( ".SUNW_ldynsym", ldynsym_escn) -+# endif - --# define FINDX(_sec_name, _sec_escn, _post_fx) \ -- do { \ -- ElfXX_Shdr a_shdr; \ -- ML_(img_get)(&a_shdr, mimg, \ -- INDEX_BIS(shdr_mioff, i, shdr_ment_szB), \ -- sizeof(a_shdr)); \ -- if (0 == ML_(img_strcmp_c)(mimg, shdr_strtab_mioff \ -- + a_shdr.sh_name, _sec_name)) { \ -- Bool nobits; \ -- _sec_escn.img = mimg; \ -- _sec_escn.ioff = (DiOffT)a_shdr.sh_offset; \ -- _sec_escn.szB = a_shdr.sh_size; \ -- if (!check_compression(&a_shdr, &_sec_escn)) { \ -- ML_(symerr)(di, True, " Compression type is unsupported"); \ -- goto out; \ -- } \ -- nobits = a_shdr.sh_type == SHT_NOBITS; \ -- vg_assert(_sec_escn.img != NULL); \ -- vg_assert(_sec_escn.ioff != DiOffT_INVALID); \ -- TRACE_SYMTAB( "%-18s: ioff %llu .. %llu\n", \ -- _sec_name, (ULong)a_shdr.sh_offset, \ -- ((ULong)a_shdr.sh_offset) + a_shdr.sh_size - 1); \ -- /* SHT_NOBITS sections have zero size in the file. */ \ -- if (!nobits && \ -- a_shdr.sh_offset + \ -- a_shdr.sh_size > ML_(img_real_size)(mimg)) { \ -- ML_(symerr)(di, True, \ -- " section beyond image end?!"); \ -- goto out; \ -- } \ -- _post_fx; \ -- } \ -- } while (0); -+ FINDX_MIMG( ".eh_frame", ehframe_escn[ehframe_mix], -+ do { ehframe_mix++; vg_assert(ehframe_mix <= N_EHFRAME_SECTS); -+ } while (0) -+ ) -+ /* Comment_on_EH_FRAME_MULTIPLE_INSTANCES: w.r.t. .eh_frame -+ multi-instance kludgery, how are we assured that the order -+ in which we fill in ehframe_escn[] is consistent with the -+ order in which we previously filled in di->ehframe_avma[] -+ and di->ehframe_size[] ? By the fact that in both cases, -+ these arrays were filled in by iterating over the section -+ headers top-to-bottom. So both loops (this one and the -+ previous one) encounter the .eh_frame entries in the same -+ order and so fill in these arrays in a consistent order. -+ */ -+ } /* Iterate over section headers (again) */ - -- /* Version with no post-effects */ --# define FIND(_sec_name, _sec_escn) \ -- FINDX(_sec_name, _sec_escn, /**/) -+ /* Check some sizes */ -+ vg_assert((dynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); -+ vg_assert((symtab_escn.szB % sizeof(ElfXX_Sym)) == 0); -+# if defined(VGO_solaris) -+ vg_assert((ldynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); -+# endif - -- /* NAME ElfSec */ -- FIND( ".dynsym", dynsym_escn) -- FIND( ".dynstr", dynstr_escn) -- FIND( ".symtab", symtab_escn) -- FIND( ".strtab", strtab_escn) -+ /* Read symbols */ -+ { -+ void (*read_elf_symtab)(struct _DebugInfo*, const HChar*, -+ DiSlice*, DiSlice*, DiSlice*, Bool); -+# if defined(VGP_ppc64be_linux) -+ read_elf_symtab = read_elf_symtab__ppc64be_linux; -+# else -+ read_elf_symtab = read_elf_symtab__normal; -+# endif -+ if (symtab_escn.img != NULL) -+ read_elf_symtab(di, "symbol table", -+ &symtab_escn, &strtab_escn, &opd_escn, -+ False); -+ read_elf_symtab(di, "dynamic symbol table", -+ &dynsym_escn, &dynstr_escn, &opd_escn, -+ False); - # if defined(VGO_solaris) -- FIND( ".SUNW_ldynsym", ldynsym_escn) -+ read_elf_symtab(di, "local dynamic symbol table", -+ &ldynsym_escn, &dynstr_escn, &opd_escn, -+ False); - # endif -+ } - -- FIND( ".gnu_debuglink", debuglink_escn) -- FIND( ".gnu_debugaltlink", debugaltlink_escn) -+ /* TOPLEVEL */ -+ /* Read .eh_frame and .debug_frame (call-frame-info) if any. Do -+ the .eh_frame section(s) first. */ -+ vg_assert(di->n_ehframe >= 0 && di->n_ehframe <= N_EHFRAME_SECTS); -+ for (i = 0; i < di->n_ehframe; i++) { -+ /* see Comment_on_EH_FRAME_MULTIPLE_INSTANCES above for why -+ this next assertion should hold. */ -+ vg_assert(ML_(sli_is_valid)(ehframe_escn[i])); -+ vg_assert(ehframe_escn[i].szB == di->ehframe_size[i]); -+ ML_(read_callframe_info_dwarf3)( di, -+ ehframe_escn[i], -+ di->ehframe_avma[i], -+ True/*is_ehframe*/ ); -+ } -+ } -+ -+ return True; -+ -+ out: -+ { -+ /* Last, but not least, detach from the image. */ -+ if (mimg) ML_(img_done)(mimg); -+ -+ if (svma_ranges) VG_(deleteXA)(svma_ranges); - -- FIND( ".debug_line", debug_line_escn) -+ return False; -+ } /* out: */ -+ -+ /* NOTREACHED */ -+} -+ -+Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) -+{ -+ Word i, j; -+ Bool res = True; -+ Bool ok; -+ -+ /* Image for the main ELF file we're working with. */ -+ DiImage* mimg = NULL; -+ -+ /* Ditto for any ELF debuginfo file that we might happen to load. */ -+ DiImage* dimg = NULL; -+ -+ /* Ditto for alternate ELF debuginfo file that we might happen to load. */ -+ DiImage* aimg = NULL; -+ -+ /* Section header image addr, # entries, entry size. Also the -+ associated string table. */ -+ DiOffT shdr_mioff = 0; -+ UWord shdr_mnent = 0; -+ UWord shdr_ment_szB = 0; -+ DiOffT shdr_strtab_mioff = 0; -+ -+ DiOffT ehdr_mioff = 0; -+ -+ /* Connect to the primary object image, so that we can read symbols -+ and line number info out of it. It will be disconnected -+ immediately thereafter; it is only connected transiently. */ -+ mimg = ML_(img_from_local_file)(di->fsm.filename); -+ if (mimg == NULL) { -+ VG_(message)(Vg_UserMsg, "warning: connection to image %s failed\n", -+ di->fsm.filename ); -+ VG_(message)(Vg_UserMsg, " no debug info loaded\n" ); -+ return False; -+ } -+ -+ /* Ok, the object image is available. Now verify that it is a -+ valid ELF .so or executable image. */ -+ ok = is_elf_object_file_by_DiImage(mimg, False); -+ if (!ok) { -+ ML_(symerr)(di, True, "Invalid ELF Header"); -+ goto out; -+ } -+ -+ /* Find where the program and section header tables are, and give -+ up if either is missing or outside the image (bogus). */ -+ ElfXX_Ehdr ehdr_m; -+ vg_assert(ehdr_mioff == 0); // ensured by its initialisation -+ ok = ML_(img_valid)(mimg, ehdr_mioff, sizeof(ehdr_m)); -+ vg_assert(ok); // ML_(is_elf_object_file) should ensure this -+ ML_(img_get)(&ehdr_m, mimg, ehdr_mioff, sizeof(ehdr_m)); -+ -+ shdr_mioff = ehdr_mioff + ehdr_m.e_shoff; -+ shdr_mnent = ehdr_m.e_shnum; -+ shdr_ment_szB = ehdr_m.e_shentsize; -+ -+ if (shdr_mnent == 0 -+ || !ML_(img_valid)(mimg, shdr_mioff, shdr_mnent * shdr_ment_szB)) { -+ ML_(symerr)(di, True, "Missing or invalid ELF Section Header Table"); -+ goto out; -+ } -+ -+ /* Also find the section header's string table, and validate. */ -+ /* checked previously by is_elf_object_file: */ -+ vg_assert(ehdr_m.e_shstrndx != SHN_UNDEF); -+ -+ // shdr_mioff is the offset of the section header table -+ // and we need the ehdr_m.e_shstrndx'th entry -+ { ElfXX_Shdr a_shdr; -+ ML_(img_get)(&a_shdr, mimg, -+ INDEX_BIS(shdr_mioff, ehdr_m.e_shstrndx, shdr_ment_szB), -+ sizeof(a_shdr)); -+ shdr_strtab_mioff -+ = ehdr_mioff /* isn't this always zero? */ + a_shdr.sh_offset; -+ -+ if (!ML_(img_valid)(mimg, shdr_strtab_mioff, -+ 1/*bogus, but we don't know the real size*/ )) { -+ ML_(symerr)(di, True, "Invalid ELF Section Header String Table"); -+ goto out; -+ } -+ } -+ -+ TRACE_SYMTAB("\n"); -+ TRACE_SYMTAB("------ Finding image addresses " -+ "for debug-info sections ------\n"); -+ /* TOPLEVEL */ -+ /* Find interesting sections, read the symbol table(s), read any -+ debug information. Each section is located either in the main, -+ debug or alt-debug files, but only in one. For each section, -+ |section_escn| records which of |mimg|, |dimg| or |aimg| we -+ found it in, along with the section's image offset and its size. -+ The triples (section_img, section_ioff, section_szB) are -+ consistent, in that they are always either (NULL, -+ DiOffT_INVALID, 0), or refer to the same image, and are all -+ assigned together. */ -+ -+ { -+ /* TOPLEVEL */ -+ DiSlice strtab_escn = DiSlice_INVALID; // .strtab -+ DiSlice symtab_escn = DiSlice_INVALID; // .symtab -+ DiSlice debuglink_escn = DiSlice_INVALID; // .gnu_debuglink -+ DiSlice debugaltlink_escn = DiSlice_INVALID; // .gnu_debugaltlink -+ DiSlice debug_line_escn = DiSlice_INVALID; // .debug_line (dwarf2) -+ DiSlice debug_info_escn = DiSlice_INVALID; // .debug_info (dwarf2) -+ DiSlice debug_types_escn = DiSlice_INVALID; // .debug_types (dwarf4) -+ DiSlice debug_abbv_escn = DiSlice_INVALID; // .debug_abbrev (dwarf2) -+ DiSlice debug_str_escn = DiSlice_INVALID; // .debug_str (dwarf2) -+ DiSlice debug_line_str_escn = DiSlice_INVALID; // .debug_line_str(dwarf5) -+ DiSlice debug_ranges_escn = DiSlice_INVALID; // .debug_ranges (dwarf2) -+ DiSlice debug_rnglists_escn = DiSlice_INVALID; // .debug_rnglists(dwarf5) -+ DiSlice debug_loclists_escn = DiSlice_INVALID; // .debug_loclists(dwarf5) -+ DiSlice debug_addr_escn = DiSlice_INVALID; // .debug_addr (dwarf5) -+ DiSlice debug_str_offsets_escn = DiSlice_INVALID; // .debug_str_offsets (dwarf5) -+ DiSlice debug_loc_escn = DiSlice_INVALID; // .debug_loc (dwarf2) -+ DiSlice debug_frame_escn = DiSlice_INVALID; // .debug_frame (dwarf2) -+ DiSlice debug_line_alt_escn = DiSlice_INVALID; // .debug_line (alt) -+ DiSlice debug_info_alt_escn = DiSlice_INVALID; // .debug_info (alt) -+ DiSlice debug_abbv_alt_escn = DiSlice_INVALID; // .debug_abbrev (alt) -+ DiSlice debug_str_alt_escn = DiSlice_INVALID; // .debug_str (alt) -+ DiSlice dwarf1d_escn = DiSlice_INVALID; // .debug (dwarf1) -+ DiSlice dwarf1l_escn = DiSlice_INVALID; // .line (dwarf1) -+ DiSlice opd_escn = DiSlice_INVALID; // .opd (dwarf2, -+ // ppc64be-linux) -+ -+ /* TOPLEVEL */ -+ /* Iterate over section headers (again) */ -+ for (i = 0; i < ehdr_m.e_shnum; i++) { -+ -+ /* NAME ElfSec */ -+ FIND_MIMG( ".symtab", symtab_escn) -+ FIND_MIMG( ".strtab", strtab_escn) -+ FIND_MIMG( ".gnu_debuglink", debuglink_escn) -+ FIND_MIMG( ".gnu_debugaltlink", debugaltlink_escn) -+ -+ FIND_MIMG( ".debug_line", debug_line_escn) - if (!ML_(sli_is_valid)(debug_line_escn)) -- FIND(".zdebug_line", debug_line_escn) -+ FIND_MIMG(".zdebug_line", debug_line_escn) - -- FIND( ".debug_info", debug_info_escn) -+ FIND_MIMG( ".debug_info", debug_info_escn) - if (!ML_(sli_is_valid)(debug_info_escn)) -- FIND(".zdebug_info", debug_info_escn) -+ FIND_MIMG(".zdebug_info", debug_info_escn) - -- FIND( ".debug_types", debug_types_escn) -+ FIND_MIMG( ".debug_types", debug_types_escn) - if (!ML_(sli_is_valid)(debug_types_escn)) -- FIND(".zdebug_types", debug_types_escn) -+ FIND_MIMG(".zdebug_types", debug_types_escn) - -- FIND( ".debug_abbrev", debug_abbv_escn) -+ FIND_MIMG( ".debug_abbrev", debug_abbv_escn) - if (!ML_(sli_is_valid)(debug_abbv_escn)) -- FIND(".zdebug_abbrev", debug_abbv_escn) -+ FIND_MIMG(".zdebug_abbrev", debug_abbv_escn) - -- FIND( ".debug_str", debug_str_escn) -+ FIND_MIMG( ".debug_str", debug_str_escn) - if (!ML_(sli_is_valid)(debug_str_escn)) -- FIND(".zdebug_str", debug_str_escn) -+ FIND_MIMG(".zdebug_str", debug_str_escn) - -- FIND( ".debug_line_str", debug_line_str_escn) -+ FIND_MIMG( ".debug_line_str", debug_line_str_escn) - if (!ML_(sli_is_valid)(debug_line_str_escn)) -- FIND(".zdebug_str", debug_line_str_escn) -+ FIND_MIMG(".zdebug_str", debug_line_str_escn) - -- FIND( ".debug_ranges", debug_ranges_escn) -+ FIND_MIMG( ".debug_ranges", debug_ranges_escn) - if (!ML_(sli_is_valid)(debug_ranges_escn)) -- FIND(".zdebug_ranges", debug_ranges_escn) -+ FIND_MIMG(".zdebug_ranges", debug_ranges_escn) - -- FIND( ".debug_rnglists", debug_rnglists_escn) -+ FIND_MIMG( ".debug_rnglists", debug_rnglists_escn) - if (!ML_(sli_is_valid)(debug_rnglists_escn)) -- FIND(".zdebug_rnglists", debug_rnglists_escn) -+ FIND_MIMG(".zdebug_rnglists", debug_rnglists_escn) - -- FIND( ".debug_loclists", debug_loclists_escn) -+ FIND_MIMG( ".debug_loclists", debug_loclists_escn) - if (!ML_(sli_is_valid)(debug_loclists_escn)) -- FIND(".zdebug_loclists", debug_loclists_escn) -+ FIND_MIMG(".zdebug_loclists", debug_loclists_escn) - -- FIND( ".debug_loc", debug_loc_escn) -+ FIND_MIMG( ".debug_loc", debug_loc_escn) - if (!ML_(sli_is_valid)(debug_loc_escn)) -- FIND(".zdebug_loc", debug_loc_escn) -+ FIND_MIMG(".zdebug_loc", debug_loc_escn) - -- FIND( ".debug_frame", debug_frame_escn) -+ FIND_MIMG( ".debug_frame", debug_frame_escn) - if (!ML_(sli_is_valid)(debug_frame_escn)) -- FIND(".zdebug_frame", debug_frame_escn) -+ FIND_MIMG(".zdebug_frame", debug_frame_escn) - -- FIND( ".debug_addr", debug_addr_escn) -+ FIND_MIMG( ".debug_addr", debug_addr_escn) - if (!ML_(sli_is_valid)(debug_addr_escn)) -- FIND(".zdebug_addr", debug_addr_escn) -+ FIND_MIMG(".zdebug_addr", debug_addr_escn) - -- FIND( ".debug_str_offsets", debug_str_offsets_escn) -+ FIND_MIMG( ".debug_str_offsets", debug_str_offsets_escn) - if (!ML_(sli_is_valid)(debug_str_offsets_escn)) -- FIND(".zdebug_str_offsets", debug_str_offsets_escn) -+ FIND_MIMG(".zdebug_str_offsets", debug_str_offsets_escn) - -- FIND( ".debug", dwarf1d_escn) -- FIND( ".line", dwarf1l_escn) -+ FIND_MIMG( ".debug", dwarf1d_escn) -+ FIND_MIMG( ".line", dwarf1l_escn) - -- FIND( ".opd", opd_escn) -+ FIND_MIMG( ".opd", opd_escn) - -- FINDX( ".eh_frame", ehframe_escn[ehframe_mix], -- do { ehframe_mix++; vg_assert(ehframe_mix <= N_EHFRAME_SECTS); -- } while (0) -- ) - /* Comment_on_EH_FRAME_MULTIPLE_INSTANCES: w.r.t. .eh_frame - multi-instance kludgery, how are we assured that the order - in which we fill in ehframe_escn[] is consistent with the -@@ -2991,8 +3160,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - order and so fill in these arrays in a consistent order. - */ - --# undef FINDX --# undef FIND - } /* Iterate over section headers (again) */ - - /* TOPLEVEL */ -@@ -3465,53 +3632,23 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - } /* Find all interesting sections */ - } /* do we have a debug image? */ - -- - /* TOPLEVEL */ -- /* Check some sizes */ -- vg_assert((dynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); - vg_assert((symtab_escn.szB % sizeof(ElfXX_Sym)) == 0); --# if defined(VGO_solaris) -- vg_assert((ldynsym_escn.szB % sizeof(ElfXX_Sym)) == 0); --# endif - - /* TOPLEVEL */ - /* Read symbols */ - { - void (*read_elf_symtab)(struct _DebugInfo*, const HChar*, - DiSlice*, DiSlice*, DiSlice*, Bool); -- Bool symtab_in_debug; - # if defined(VGP_ppc64be_linux) - read_elf_symtab = read_elf_symtab__ppc64be_linux; - # else - read_elf_symtab = read_elf_symtab__normal; - # endif -- symtab_in_debug = symtab_escn.img == dimg; -- read_elf_symtab(di, "symbol table", -- &symtab_escn, &strtab_escn, &opd_escn, -- symtab_in_debug); -- read_elf_symtab(di, "dynamic symbol table", -- &dynsym_escn, &dynstr_escn, &opd_escn, -- False); --# if defined(VGO_solaris) -- read_elf_symtab(di, "local dynamic symbol table", -- &ldynsym_escn, &dynstr_escn, &opd_escn, -- False); --# endif -- } -- -- /* TOPLEVEL */ -- /* Read .eh_frame and .debug_frame (call-frame-info) if any. Do -- the .eh_frame section(s) first. */ -- vg_assert(di->n_ehframe >= 0 && di->n_ehframe <= N_EHFRAME_SECTS); -- for (i = 0; i < di->n_ehframe; i++) { -- /* see Comment_on_EH_FRAME_MULTIPLE_INSTANCES above for why -- this next assertion should hold. */ -- vg_assert(ML_(sli_is_valid)(ehframe_escn[i])); -- vg_assert(ehframe_escn[i].szB == di->ehframe_size[i]); -- ML_(read_callframe_info_dwarf3)( di, -- ehframe_escn[i], -- di->ehframe_avma[i], -- True/*is_ehframe*/ ); -+ if (symtab_escn.img != NULL) -+ read_elf_symtab(di, "symbol table", -+ &symtab_escn, &strtab_escn, &opd_escn, -+ True); - } - if (ML_(sli_is_valid)(debug_frame_escn)) { - ML_(read_callframe_info_dwarf3)( di, -@@ -3643,8 +3780,6 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - if (dimg) ML_(img_done)(dimg); - if (aimg) ML_(img_done)(aimg); - -- if (svma_ranges) VG_(deleteXA)(svma_ranges); -- - return res; - } /* out: */ - -diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c -index c3fa62e96..3ad114607 100644 ---- a/coregrind/m_debuginfo/storage.c -+++ b/coregrind/m_debuginfo/storage.c -@@ -1297,8 +1297,7 @@ void ML_(addVar)( struct _DebugInfo* di, - that those extra sections have the same bias as .text, but that - seems a reasonable assumption to me. */ - /* This is assured us by top level steering logic in debuginfo.c, -- and it is re-checked at the start of -- ML_(read_elf_debug_info). */ -+ and it is re-checked at the start of ML_(read_elf_object). */ - vg_assert(di->fsm.have_rx_map && di->fsm.rw_map_count); - if (level > 0 && ML_(find_rx_mapping)(di, aMin, aMax) == NULL) { - if (VG_(clo_verbosity) > 1) { -@@ -1725,7 +1724,6 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) - for (i = 0; i < di->symtab_used; i++) { - DiSym* sym = &di->symtab[i]; - vg_assert(sym->pri_name); -- vg_assert(!sym->sec_names); - } - - /* Sort by address. */ -@@ -2383,6 +2381,9 @@ void ML_(finish_CFSI_arrays) ( struct _DebugInfo* di ) - vg_assert (f_holes == n_holes); - vg_assert (pos == new_used); - -+ if (di->deferred) -+ return; -+ - di->cfsi_used = new_used; - di->cfsi_size = new_used; - ML_(dinfo_free) (di->cfsi_rd); -@@ -2398,9 +2399,13 @@ void ML_(canonicaliseTables) ( struct _DebugInfo* di ) - canonicaliseLoctab ( di ); - canonicaliseInltab ( di ); - ML_(canonicaliseCFI) ( di ); -+ canonicaliseVarInfo ( di ); -+ -+ if (di->deferred) -+ return; -+ - if (di->cfsi_m_pool) - VG_(freezeDedupPA) (di->cfsi_m_pool, ML_(dinfo_shrink_block)); -- canonicaliseVarInfo ( di ); - if (di->strpool) - VG_(freezeDedupPA) (di->strpool, ML_(dinfo_shrink_block)); - if (di->fndnpool) -diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h -index 938ed00cc..ce7246217 100644 ---- a/coregrind/pub_core_debuginfo.h -+++ b/coregrind/pub_core_debuginfo.h -@@ -76,6 +76,10 @@ extern void VG_(di_notify_pdb_debuginfo)( Int fd, Addr avma, - extern void VG_(di_notify_vm_protect)( Addr a, SizeT len, UInt prot ); - #endif - -+extern void VG_(addr_load_di)( Addr a ); -+ -+extern void VG_(load_di)( DebugInfo *di, Addr a ); -+ - extern void VG_(di_discard_ALL_debuginfo)( void ); - - /* Like VG_(get_fnname), but it does not do C++ demangling nor Z-demangling --- -2.41.0 - diff --git a/valgrind-3.21.0-pgste.patch b/valgrind-3.21.0-pgste.patch deleted file mode 100644 index 4646aa2..0000000 --- a/valgrind-3.21.0-pgste.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 56f1bd12c92806fd18337ba4cd3c0a8d714d0e94 Mon Sep 17 00:00:00 2001 -From: Andreas Arnez -Date: Thu, 15 Jun 2023 17:24:53 +0200 -Subject: [PATCH] Bug 470978 - s390x: Link the tools with -Wl,--s390-pgste - -Programs that require the PGSTE mode to be enabled may currently fail -under Valgrind. In particular this affects qemu-kvm. - -While it is also possible to enable the PGSTE mode globally with - - sysctl vm.allocate_psgte=1 - -the problem can more easily be prevented by linking the Valgrind tools -with -Wl,--s390-pgste. Add a configure check if the linker supports this, -and activate the flag if it does. - -To verify the intended result, the following shell command can be used to -list the executables having this flag set: - - find . -type f -perm -u+x -execdir \ - /bin/sh -c 'readelf -lW $0 2>/dev/null | grep PGSTE' {} \; -print ---- - Makefile.tool.am | 2 +- - configure.ac | 20 ++++++++++++++++++++ - 2 files changed, 21 insertions(+), 1 deletion(-) - -diff --git a/Makefile.tool.am b/Makefile.tool.am -index df9502913..4ce6d5ab0 100644 ---- a/Makefile.tool.am -+++ b/Makefile.tool.am -@@ -78,7 +78,7 @@ TOOL_LDFLAGS_ARM64_LINUX = \ - $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ - - TOOL_LDFLAGS_S390X_LINUX = \ -- $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ -+ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ @FLAG_S390_PGSTE@ - - TOOL_LDFLAGS_X86_DARWIN = \ - $(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386 -diff --git a/configure.ac b/configure.ac -index 0cf84a1c0..1d4164a7d 100755 ---- a/configure.ac -+++ b/configure.ac -@@ -3096,6 +3096,26 @@ AC_SUBST([FLAG_NO_BUILD_ID], [""]) - fi - CFLAGS=$safe_CFLAGS - -+# On s390x, if the linker supports -Wl,--s390-pgste, then we build the -+# tools with that flag. This enables running programs that need it, such -+# as qemu-kvm. -+if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then -+AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste]) -+safe_CFLAGS=$CFLAGS -+CFLAGS="-Wl,--s390-pgste" -+ -+AC_LINK_IFELSE( -+[AC_LANG_PROGRAM([ ], [return 0;])], -+[ -+ AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"]) -+ AC_MSG_RESULT([yes]) -+], [ -+ AC_SUBST([FLAG_S390_PGSTE], [""]) -+ AC_MSG_RESULT([no]) -+]) -+CFLAGS=$safe_CFLAGS -+fi -+ - # does the ppc assembler support "mtocrf" et al? - AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf]) - --- -2.40.1 - diff --git a/valgrind-3.21.0-realloc-again.patch b/valgrind-3.21.0-realloc-again.patch deleted file mode 100644 index 7501cd2..0000000 --- a/valgrind-3.21.0-realloc-again.patch +++ /dev/null @@ -1,167 +0,0 @@ -From b904112d7084227f8d6fab322bc360a8a6240a51 Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Thu, 1 Jun 2023 16:10:56 +0200 -Subject: [PATCH] memcheck: Handle Err_ReallocSizeZero in MC_(eq_Error) - -When an realloc size zero error is emitted MC_(eq_Error) is called to -see if the errors can be deduplicated. This crashed since -Err_ReallocSizeZero wasn't handled. Handle it like Err_Free. - -Also add a testcase for this case and test with both ---realloc-zero-bytes-frees=yes and ---realloc-zero-bytes-frees=no. -Which will report a different number of errors. - -https://bugs.kde.org/show_bug.cgi?id=470520 ---- - memcheck/mc_errors.c | 1 + - memcheck/tests/Makefile.am | 7 +++++++ - memcheck/tests/realloc_size_zero_again.c | 15 +++++++++++++++ - .../realloc_size_zero_again_no.stderr.exp | 18 ++++++++++++++++++ - .../realloc_size_zero_again_no.stdout.exp | 0 - .../tests/realloc_size_zero_again_no.vgtest | 2 ++ - .../realloc_size_zero_again_yes.stderr.exp | 18 ++++++++++++++++++ - .../realloc_size_zero_again_yes.stdout.exp | 0 - .../tests/realloc_size_zero_again_yes.vgtest | 2 ++ - 9 files changed, 63 insertions(+) - create mode 100644 memcheck/tests/realloc_size_zero_again.c - create mode 100644 memcheck/tests/realloc_size_zero_again_no.stderr.exp - create mode 100644 memcheck/tests/realloc_size_zero_again_no.stdout.exp - create mode 100644 memcheck/tests/realloc_size_zero_again_no.vgtest - create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stderr.exp - create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stdout.exp - create mode 100644 memcheck/tests/realloc_size_zero_again_yes.vgtest - -diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c -index 00d6ec301..65210a220 100644 ---- a/memcheck/mc_errors.c -+++ b/memcheck/mc_errors.c -@@ -1041,6 +1041,7 @@ Bool MC_(eq_Error) ( VgRes res, const Error* e1, const Error* e2 ) - case Err_IllegalMempool: - case Err_Overlap: - case Err_Cond: -+ case Err_ReallocSizeZero: - return True; - - case Err_FishyValue: -diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am -index 71c38acba..5a17fd35d 100644 ---- a/memcheck/tests/Makefile.am -+++ b/memcheck/tests/Makefile.am -@@ -291,8 +291,14 @@ EXTRA_DIST = \ - realloc_size_zero.vgtest \ - realloc_size_zero_yes.stderr.exp realloc_size_zero_yes.stdout.exp \ - realloc_size_zero_yes.vgtest \ -+ realloc_size_zero_again_yes.stderr.exp \ -+ realloc_size_zero_again_yes.stdout.exp \ -+ realloc_size_zero_again_yes.vgtest \ - realloc_size_zero_no.stderr.exp realloc_size_zero_no.stdout.exp \ - realloc_size_zero_no.vgtest \ -+ realloc_size_zero_again_no.stderr.exp \ -+ realloc_size_zero_again_no.stdout.exp \ -+ realloc_size_zero_again_no.vgtest \ - realloc_size_zero_off.stderr.exp realloc_size_zero_off.stdout.exp \ - realloc_size_zero_off.vgtest \ - realloc_size_zero_mismatch.stderr.exp \ -@@ -459,6 +465,7 @@ check_PROGRAMS = \ - posix_memalign \ - post-syscall \ - realloc_size_zero realloc_size_zero_mismatch \ -+ realloc_size_zero_again \ - realloc1 realloc2 realloc3 \ - recursive-merge \ - resvn_stack \ -diff --git a/memcheck/tests/realloc_size_zero_again.c b/memcheck/tests/realloc_size_zero_again.c -new file mode 100644 -index 000000000..782d4bde5 ---- /dev/null -+++ b/memcheck/tests/realloc_size_zero_again.c -@@ -0,0 +1,15 @@ -+#include -+ -+int -+main () -+{ -+ char *p = malloc (1024); -+ for (int i = 3; i >= 0; i--) -+ for (int j = 0; j <= 3; j++) -+ { -+ char *q = realloc (p, i * j * 512); -+ p = q; -+ } -+ -+ free (p); -+} -diff --git a/memcheck/tests/realloc_size_zero_again_no.stderr.exp b/memcheck/tests/realloc_size_zero_again_no.stderr.exp -new file mode 100644 -index 000000000..b9c061d1a ---- /dev/null -+++ b/memcheck/tests/realloc_size_zero_again_no.stderr.exp -@@ -0,0 +1,18 @@ -+realloc() with size 0 -+ at 0x........: realloc (vg_replace_malloc.c:...) -+ ... -+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd -+ at 0x........: malloc (vg_replace_malloc.c:...) -+ ... -+ -+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0) -+ -+7 errors in context 1 of 1: -+realloc() with size 0 -+ at 0x........: realloc (vg_replace_malloc.c:...) -+ ... -+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd -+ at 0x........: malloc (vg_replace_malloc.c:...) -+ ... -+ -+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0) -diff --git a/memcheck/tests/realloc_size_zero_again_no.stdout.exp b/memcheck/tests/realloc_size_zero_again_no.stdout.exp -new file mode 100644 -index 000000000..e69de29bb -diff --git a/memcheck/tests/realloc_size_zero_again_no.vgtest b/memcheck/tests/realloc_size_zero_again_no.vgtest -new file mode 100644 -index 000000000..f1757b6c1 ---- /dev/null -+++ b/memcheck/tests/realloc_size_zero_again_no.vgtest -@@ -0,0 +1,2 @@ -+prog: realloc_size_zero_again -+vgopts: -q -s --realloc-zero-bytes-frees=no -diff --git a/memcheck/tests/realloc_size_zero_again_yes.stderr.exp b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp -new file mode 100644 -index 000000000..d40aa2455 ---- /dev/null -+++ b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp -@@ -0,0 +1,18 @@ -+realloc() with size 0 -+ at 0x........: realloc (vg_replace_malloc.c:...) -+ ... -+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd -+ at 0x........: malloc (vg_replace_malloc.c:...) -+ ... -+ -+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0) -+ -+5 errors in context 1 of 1: -+realloc() with size 0 -+ at 0x........: realloc (vg_replace_malloc.c:...) -+ ... -+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd -+ at 0x........: malloc (vg_replace_malloc.c:...) -+ ... -+ -+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0) -diff --git a/memcheck/tests/realloc_size_zero_again_yes.stdout.exp b/memcheck/tests/realloc_size_zero_again_yes.stdout.exp -new file mode 100644 -index 000000000..e69de29bb -diff --git a/memcheck/tests/realloc_size_zero_again_yes.vgtest b/memcheck/tests/realloc_size_zero_again_yes.vgtest -new file mode 100644 -index 000000000..215392ed6 ---- /dev/null -+++ b/memcheck/tests/realloc_size_zero_again_yes.vgtest -@@ -0,0 +1,2 @@ -+prog: realloc_size_zero_again -+vgopts: -q -s --realloc-zero-bytes-frees=yes --- -2.40.1 - diff --git a/valgrind-3.21.0-vgm-tests.patch b/valgrind-3.21.0-vgm-tests.patch deleted file mode 100644 index 8fa7712..0000000 --- a/valgrind-3.21.0-vgm-tests.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 21f7a2af2805a02a144c81f12895c134f4a171a3 Mon Sep 17 00:00:00 2001 -From: Andreas Arnez -Date: Mon, 22 May 2023 19:49:08 +0200 -Subject: [PATCH 2/2] Bug 470132 - s390x: Increase test coverage for VGM - -Add more tests for the VGM instruction, to verify the fix for the VGM -wrap-around case. Also test setting unused bits in the I2 and I3 fields, -to check that Valgrind ignores them as it should. ---- - none/tests/s390x/vec2.c | 44 ++++++++++++++++++++++++++++++++ - none/tests/s390x/vec2.stdout.exp | 20 +++++++++++++++ - 2 files changed, 64 insertions(+) - -diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c -index 73b04dee4..c473a2a9a 100644 ---- a/none/tests/s390x/vec2.c -+++ b/none/tests/s390x/vec2.c -@@ -301,6 +301,49 @@ static void test_all_fp_int_conversions() - #undef TEST_EXEC - #undef TEST_GENERATE - -+/* -- Vector generate mask -- */ -+ -+#define TEST_GENERATE(insn, i2, i3, m4) \ -+ static void test_vgm_##i2##_##i3##_##m4(void) \ -+ { \ -+ ulong_v out = vec_ini; \ -+ __asm__("vgm %[out]," #i2 "," #i3 "," #m4 : [out] "+v"(out) : :); \ -+ printf("\t%016lx %016lx\n", out[0], out[1]); \ -+ } -+ -+#define TEST_EXEC(insn, i2, i3, m4) \ -+ do { \ -+ puts(#insn " " #i2 "," #i3 "," #m4); \ -+ test_vgm_##i2##_##i3##_##m4(); \ -+ } while (0) -+ -+#define INSNS \ -+ XTEST(vgmb, 2, 1, 0); \ -+ XTEST(vgmb, 0xf7, 0x30, 0); \ -+ XTEST(vgmb, 0, 0, 0); \ -+ XTEST(vgmh, 3, 2, 1); \ -+ XTEST(vgmh, 15, 15, 1); \ -+ XTEST(vgmf, 4, 3, 2); \ -+ XTEST(vgmf, 16, 17, 2); \ -+ XTEST(vgmg, 55, 63, 3); \ -+ XTEST(vgmg, 43, 55, 3); \ -+ XTEST(vgmg, 63, 2, 3); -+ -+#define XTEST TEST_GENERATE -+INSNS -+#undef XTEST -+ -+static void test_all_generate_mask() -+{ -+#define XTEST TEST_EXEC -+ INSNS -+#undef XTEST -+} -+ -+#undef INSNS -+#undef TEST_EXEC -+#undef TEST_GENERATE -+ - - int main() - { -@@ -310,5 +353,6 @@ int main() - test_all_double_bitshifts(); - test_all_int_fp_conversions(); - test_all_fp_int_conversions(); -+ test_all_generate_mask(); - return 0; - } -diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp -index b32cbe1bc..2c9ac21c1 100644 ---- a/none/tests/s390x/vec2.stdout.exp -+++ b/none/tests/s390x/vec2.stdout.exp -@@ -166,3 +166,23 @@ vcsfp 0 - vcsfp 8 - 00ffffff - - - - 00000004 - - - -+vgmb 2,1,0 -+ ffffffffffffffff ffffffffffffffff -+vgmb 0xf7,0x30,0 -+ 8181818181818181 8181818181818181 -+vgmb 0,0,0 -+ 8080808080808080 8080808080808080 -+vgmh 3,2,1 -+ ffffffffffffffff ffffffffffffffff -+vgmh 15,15,1 -+ 0001000100010001 0001000100010001 -+vgmf 4,3,2 -+ ffffffffffffffff ffffffffffffffff -+vgmf 16,17,2 -+ 0000c0000000c000 0000c0000000c000 -+vgmg 55,63,3 -+ 00000000000001ff 00000000000001ff -+vgmg 43,55,3 -+ 00000000001fff00 00000000001fff00 -+vgmg 63,2,3 -+ e000000000000001 e000000000000001 --- -2.40.1 - diff --git a/valgrind-3.21.0-vgm.patch b/valgrind-3.21.0-vgm.patch deleted file mode 100644 index 422035f..0000000 --- a/valgrind-3.21.0-vgm.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 70ef4417837b690755feede0088331a28b102c65 Mon Sep 17 00:00:00 2001 -From: Andreas Arnez -Date: Mon, 22 May 2023 18:57:35 +0200 -Subject: [PATCH 1/2] Bug 470132 - s390x: Fix the wrap-around case in VGM - -Valgrind's implementation of VGM is incomplete: - -* It doesn't support generating a wrap-around bit mask. Such a mask - should result when the ending bit position is smaller than the starting - bit position. Valgrind runs into an assertion failure instead. - -* It doesn't ignore unused bits in the I2 and I3 fields of the - instruction, as it should. - -Fix this by re-implementing the main logic in s390_irgen_VGM(). ---- - VEX/priv/guest_s390_toIR.c | 57 +++++++++++++++----------------------- - 1 file changed, 22 insertions(+), 35 deletions(-) - -diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c -index 11dda41ef..d9d746c38 100644 ---- a/VEX/priv/guest_s390_toIR.c -+++ b/VEX/priv/guest_s390_toIR.c -@@ -16388,50 +16388,37 @@ s390_irgen_VGBM(UChar v1, UShort i2, UChar m3 __attribute__((unused))) - static const HChar * - s390_irgen_VGM(UChar v1, UShort i2, UChar m3) - { -- UChar from = (i2 & 0xff00) >> 8; -- UChar to = (i2 & 0x00ff); -- ULong value = 0UL; -- IRType type = s390_vr_get_type(m3); -- vassert(from <= to); -- -- UChar maxIndex = 0; -- switch (type) { -- case Ity_I8: -- maxIndex = 7; -- break; -- case Ity_I16: -- maxIndex = 15; -- break; -- case Ity_I32: -- maxIndex = 31; -- break; -- case Ity_I64: -- maxIndex = 63; -- break; -- default: -- vpanic("s390_irgen_VGM: unknown type"); -- } -- -- for(UChar index = from; index <= to; index++) { -- value |= (1ULL << (maxIndex - index)); -- } -- -- IRExpr *fillValue; -- switch (type) { -- case Ity_I8: -+ s390_insn_assert("vgm", m3 <= 3); -+ -+ UChar max_idx = (8 << m3) - 1; -+ UChar from = max_idx & (i2 >> 8); -+ UChar to = max_idx & i2; -+ ULong all_one = (1ULL << max_idx << 1) - 1; -+ ULong value = (all_one >> from) ^ (all_one >> to >> 1); -+ -+ /* In case of wrap-around we now have a value that needs inverting: -+ to from -+ V V -+ 00000111111111110000000000000000 */ -+ if (to < from) -+ value ^= all_one; -+ -+ IRExpr* fillValue; -+ switch (m3) { -+ case 0: - fillValue = mkU8(value); - break; -- case Ity_I16: -+ case 1: - fillValue = mkU16(value); - break; -- case Ity_I32: -+ case 2: - fillValue = mkU32(value); - break; -- case Ity_I64: -+ case 3: - fillValue = mkU64(value); - break; - default: -- vpanic("s390_irgen_VGM: unknown type"); -+ vpanic("s390_irgen_VGM: unknown element size"); - } - - s390_vr_fill(v1, fillValue); --- -2.40.1 - diff --git a/valgrind.spec b/valgrind.spec index d630003..ab1816f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -2,8 +2,8 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind -Version: 3.21.0 -Release: 10%{?dist} +Version: 3.22.0 +Release: 0.1.RC1%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -69,7 +69,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -87,41 +87,6 @@ Patch4: valgrind-3.16.0-some-Wl-z-now.patch # by disabling overlap checking for memcpy Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch -# Add --with-gdbscripts-dir=PATH configure option -# https://bugs.kde.org/show_bug.cgi?id=469768 -Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch - -# Add epoll_pwait2 -# https://bugs.kde.org/show_bug.cgi?id=460192 -Patch7: valgrind-3.21.0-epoll_pwait2.patch - -# Can't run callgrind_control with valgrind 3.21.0 because of perl errors -# https://bugs.kde.org/show_bug.cgi?id=470121 -Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch - -# Multiple realloc zero errors crash in MC_(eq_Error) -# https://bugs.kde.org/show_bug.cgi?id=470520 -Patch9: valgrind-3.21.0-realloc-again.patch - -# s390x: Assertion failure on VGM instruction -# https://bugs.kde.org/show_bug.cgi?id=470132 -Patch10: valgrind-3.21.0-vgm.patch -Patch11: valgrind-3.21.0-vgm-tests.patch - -# s390x: Valgrind cannot start qemu-kvm when "sysctl vm.allocate_pgste=0" -# https://bugs.kde.org/show_bug.cgi?id=470978 -Patch12: valgrind-3.21.0-pgste.patch - -# gdb --multi mode stdout redirecting to stderr -# https://bugs.kde.org/show_bug.cgi?id=471311 -Patch13: valgrind-3.21.0-gdb-multi-mode-stdout-redirecting-to-stderr.patch - -# Add support for lazy reading and downloading of DWARF debuginfo -# https://bugs.kde.org/show_bug.cgi?id=471807 -# Plus fixup commit a0d555a0dfe078ef04ea49d991a8090ab14bd4a5 -Patch14: valgrind-3.21.0-lazy-debuginfo.patch -Patch15: valgrind-3.21.0-cleanup-read_elf_object.patch - BuildRequires: make BuildRequires: glibc-devel @@ -248,7 +213,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 %patch -P1 -p1 %patch -P2 -p1 @@ -260,17 +225,6 @@ Valgrind User Manual for details. %endif %patch -P5 -p1 -%patch -P6 -p1 -%patch -P7 -p1 -%patch -P8 -p1 -%patch -P9 -p1 -%patch -P10 -p1 -%patch -P11 -p1 -%patch -P12 -p1 -%patch -P13 -p1 -%patch -P14 -p1 -%patch -P15 -p1 - %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -465,6 +419,7 @@ echo ===============END TESTING=============== %files devel %dir %{_includedir}/valgrind %{_includedir}/valgrind/valgrind.h +%{_includedir}/valgrind/cachegrind.h %{_includedir}/valgrind/callgrind.h %{_includedir}/valgrind/drd.h %{_includedir}/valgrind/helgrind.h @@ -503,6 +458,13 @@ fi %endif %changelog +* Tue Oct 17 2023 Mark Wielaard - 3.22.0-0.1.RC1 +- Upstream 3.22.0-RC1 +- Remove all upstreamed patches +- Adjust valgrind-3.16.0-some-stack-protector.patch +- Adjust valgrind-3.16.0-some-Wl-z-now.patch +- Add cachegrind.h to valgrind-devel package + * Mon Aug 21 2023 Mark Wielaard - 3.21.0-10 - Add valgrind-3.21.0-lazy-debuginfo.patch - Add valgrind-3.21.0-cleanup-read_elf_object.patch From ebfba02e334d174208f50c928e95f22a0d4b78ea Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 26 Oct 2023 14:53:15 +0200 Subject: [PATCH 25/86] 3.22.0-0.1.RC2 - Upstream 3.22.0-RC2 --- .gitignore | 1 + sources | 2 +- valgrind.spec | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3f735f2..8398eb2 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ /valgrind-3.21.0.RC2.tar.bz2 /valgrind-3.21.0.tar.bz2 /valgrind-3.22.0.RC1.tar.bz2 +/valgrind-3.22.0.RC2.tar.bz2 diff --git a/sources b/sources index e2e8ed5..e14d456 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.22.0.RC1.tar.bz2) = 0aa9e98a959808d20cce53575433f81973ef3de3acc313ef2700f58cf9b2b7ee951b5bc701ef8508f5c136cb14239bbe7d81ae4208679ba55150b3edfd6078f0 +SHA512 (valgrind-3.22.0.RC2.tar.bz2) = 6a15101f4b92454856850fc35b9c38fd7fb294bee422274a803331465f347a732dc71e52c28e2d489c8d08ec7c677c1041bd32aeb4f43dd91ee404d4f6fa1208 diff --git a/valgrind.spec b/valgrind.spec index ab1816f..80231ec 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 0.1.RC1%{?dist} +Release: 0.1.RC2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -69,7 +69,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -213,7 +213,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 %patch -P1 -p1 %patch -P2 -p1 @@ -458,6 +458,9 @@ fi %endif %changelog +* Thu Oct 26 2023 Mark Wielaard - 3.22.0-0.1.RC2 +- Upstream 3.22.0-RC2 + * Tue Oct 17 2023 Mark Wielaard - 3.22.0-0.1.RC1 - Upstream 3.22.0-RC1 - Remove all upstreamed patches From 79f7a0b69f360048736c7eb4da31473a42146726 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 30 Oct 2023 20:37:03 +0100 Subject: [PATCH 26/86] 3.22.0-0.2.RC2 - Update valgrind-3.21.0-no-memcpy-replace-check.patch --- valgrind-3.21.0-no-memcpy-replace-check.patch | 48 +++++++++++++++---- valgrind.spec | 5 +- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/valgrind-3.21.0-no-memcpy-replace-check.patch b/valgrind-3.21.0-no-memcpy-replace-check.patch index 6e26e04..1f59a90 100644 --- a/valgrind-3.21.0-no-memcpy-replace-check.patch +++ b/valgrind-3.21.0-no-memcpy-replace-check.patch @@ -1,22 +1,54 @@ +diff --git a/memcheck/tests/overlap.vgtest b/memcheck/tests/overlap.vgtest +index 54a0baacf..eba65897c 100644 +--- a/memcheck/tests/overlap.vgtest ++++ b/memcheck/tests/overlap.vgtest +@@ -1,2 +1,4 @@ + prog: overlap + vgopts: -q ++# https://bugs.kde.org/show_bug.cgi?id=402833 ++prereq: ! ../../tests/arch_test amd64 diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c -index b32f13f76..464e8d4ca 100644 +index 8de6a0698..79e640189 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c -@@ -1128,7 +1128,7 @@ static inline void my_exit ( int x ) +@@ -1128,8 +1128,15 @@ static inline void my_exit ( int x ) + #define MEMMOVE(soname, fnname) \ MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0) - #define MEMCPY(soname, fnname) \ -- MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) -+ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) /* See KDE bug #402833 */ +-#define MEMCPY(soname, fnname) \ ++/* See https://bugs.kde.org/show_bug.cgi?id=402833 ++ why we disable the overlap check on x86_64. */ ++#if defined(VGP_amd64_linux) ++ #define MEMCPY(soname, fnname) \ ++ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) ++#else ++ #define MEMCPY(soname, fnname) \ + MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) ++#endif #if defined(VGO_linux) /* For older memcpy we have to use memmove-like semantics and skip -@@ -1714,8 +1714,6 @@ static inline void my_exit ( int x ) +@@ -1704,6 +1711,14 @@ static inline void my_exit ( int x ) + + /*-------------------- memcpy_chk --------------------*/ + ++/* See https://bugs.kde.org/show_bug.cgi?id=402833 ++ why we disable the overlap check on x86_64. */ ++#if defined(VGP_amd64_linux) ++ #define CHECK_OVERLAP 0 ++#else ++ #define CHECK_OVERLAP 1 ++#endif ++ + #define GLIBC26___MEMCPY_CHK(soname, fnname) \ + void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \ + (void* dst, const void* src, SizeT len, SizeT dstlen ); \ +@@ -1717,7 +1732,7 @@ static inline void my_exit ( int x ) RECORD_COPY(len); \ if (len == 0) \ return dst; \ - if (is_overlap(dst, src, len, len)) \ -- RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ ++ if (CHECK_OVERLAP && is_overlap(dst, src, len, len)) \ + RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ if ( dst > src ) { \ d = (HChar *)dst + len - 1; \ - s = (const HChar *)src + len - 1; \ diff --git a/valgrind.spec b/valgrind.spec index 80231ec..277bf90 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 0.1.RC2%{?dist} +Release: 0.2.RC2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -458,6 +458,9 @@ fi %endif %changelog +* Mon Oct 30 2023 Mark Wielaard - 3.22.0-0.2.RC2 +- Update valgrind-3.21.0-no-memcpy-replace-check.patch + * Thu Oct 26 2023 Mark Wielaard - 3.22.0-0.1.RC2 - Upstream 3.22.0-RC2 From 3fdfb3c05f54634b056caca8f9d0c8743e4238de Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 30 Oct 2023 21:06:00 +0100 Subject: [PATCH 27/86] Fedora 40 dropped openmpi support on i386 --- valgrind.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index 277bf90..b3421cd 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -15,11 +15,16 @@ URL: https://www.valgrind.org/ # We never want the openmpi subpackage when building a software collecton. # We always want it for fedora. # We only want it for older rhel. But not s390x for too old rhel. +# And on fedora > 39 i386 dropped openmpi. %if %{is_scl} %global build_openmpi 0 %else %if 0%{?fedora} - %global build_openmpi 1 + %ifarch %{ix86} + %global build_openmpi (%{?fedora} < 40) + %else + %global build_openmpi 1 + %endif %endif %if 0%{?rhel} %if 0%{?rhel} > 7 @@ -460,6 +465,7 @@ fi %changelog * Mon Oct 30 2023 Mark Wielaard - 3.22.0-0.2.RC2 - Update valgrind-3.21.0-no-memcpy-replace-check.patch +- Fedora 40 dropped openmpi support on i386 * Thu Oct 26 2023 Mark Wielaard - 3.22.0-0.1.RC2 - Upstream 3.22.0-RC2 From b62216ce3ab95d68b7e195e0f29c04c6b032aa3e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 31 Oct 2023 19:02:21 +0100 Subject: [PATCH 28/86] 3.22.0-1 - Upstream 3.22.0 final --- .gitignore | 1 + sources | 2 +- valgrind.spec | 15 ++++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 8398eb2..4ddb7e4 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ /valgrind-3.21.0.tar.bz2 /valgrind-3.22.0.RC1.tar.bz2 /valgrind-3.22.0.RC2.tar.bz2 +/valgrind-3.22.0.tar.bz2 diff --git a/sources b/sources index e14d456..9965f6f 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.22.0.RC2.tar.bz2) = 6a15101f4b92454856850fc35b9c38fd7fb294bee422274a803331465f347a732dc71e52c28e2d489c8d08ec7c677c1041bd32aeb4f43dd91ee404d4f6fa1208 +SHA512 (valgrind-3.22.0.tar.bz2) = 2904c13f68245bbafcea70998c6bd20725271300a7e94b6751ca00916943595fc3fac8557da7ea8db31b54a43f092823a0a947bc142829da811d074e1fe49777 diff --git a/valgrind.spec b/valgrind.spec index b3421cd..c637884 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 0.2.RC2%{?dist} +Release: 1%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -74,7 +74,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -88,10 +88,6 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch -# Workaround https://bugs.kde.org/show_bug.cgi?id=402833 -# by disabling overlap checking for memcpy -Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch - BuildRequires: make BuildRequires: glibc-devel @@ -218,7 +214,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} %patch -P1 -p1 %patch -P2 -p1 @@ -229,8 +225,6 @@ Valgrind User Manual for details. %patch -P4 -p1 %endif -%patch -P5 -p1 - %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -463,6 +457,9 @@ fi %endif %changelog +* Tue Oct 31 2023 Mark Wielaard - 3.22.0-1 +- Upstream 3.22.0 final + * Mon Oct 30 2023 Mark Wielaard - 3.22.0-0.2.RC2 - Update valgrind-3.21.0-no-memcpy-replace-check.patch - Fedora 40 dropped openmpi support on i386 From 4295b515b73f046fd41117d98b7aa3b8697f687f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 30 Oct 2023 21:23:54 +0100 Subject: [PATCH 29/86] BuildRequires elfutils-debuginfod for testing --- valgrind.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/valgrind.spec b/valgrind.spec index c637884..fd14ef0 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -120,6 +120,7 @@ BuildRequires: docbook-dtds # For testing debuginfod-find %if 0%{?fedora} > 29 || 0%{?rhel} > 7 +BuildRequires: elfutils-debuginfod BuildRequires: elfutils-debuginfod-client # For using debuginfod at runtime Recommends: elfutils-debuginfod-client @@ -459,6 +460,7 @@ fi %changelog * Tue Oct 31 2023 Mark Wielaard - 3.22.0-1 - Upstream 3.22.0 final +- BuildRequires elfutils-debuginfod for testing * Mon Oct 30 2023 Mark Wielaard - 3.22.0-0.2.RC2 - Update valgrind-3.21.0-no-memcpy-replace-check.patch From b0b6accc1282a11a37e5d0bac0e8826ca7a5d597 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 4 Nov 2023 03:28:23 +0100 Subject: [PATCH 30/86] delete valgrind-3.21.0-no-memcpy-replace-check.patch --- valgrind-3.21.0-no-memcpy-replace-check.patch | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 valgrind-3.21.0-no-memcpy-replace-check.patch diff --git a/valgrind-3.21.0-no-memcpy-replace-check.patch b/valgrind-3.21.0-no-memcpy-replace-check.patch deleted file mode 100644 index 1f59a90..0000000 --- a/valgrind-3.21.0-no-memcpy-replace-check.patch +++ /dev/null @@ -1,54 +0,0 @@ -diff --git a/memcheck/tests/overlap.vgtest b/memcheck/tests/overlap.vgtest -index 54a0baacf..eba65897c 100644 ---- a/memcheck/tests/overlap.vgtest -+++ b/memcheck/tests/overlap.vgtest -@@ -1,2 +1,4 @@ - prog: overlap - vgopts: -q -+# https://bugs.kde.org/show_bug.cgi?id=402833 -+prereq: ! ../../tests/arch_test amd64 -diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c -index 8de6a0698..79e640189 100644 ---- a/shared/vg_replace_strmem.c -+++ b/shared/vg_replace_strmem.c -@@ -1128,8 +1128,15 @@ static inline void my_exit ( int x ) - #define MEMMOVE(soname, fnname) \ - MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0) - --#define MEMCPY(soname, fnname) \ -+/* See https://bugs.kde.org/show_bug.cgi?id=402833 -+ why we disable the overlap check on x86_64. */ -+#if defined(VGP_amd64_linux) -+ #define MEMCPY(soname, fnname) \ -+ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) -+#else -+ #define MEMCPY(soname, fnname) \ - MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1) -+#endif - - #if defined(VGO_linux) - /* For older memcpy we have to use memmove-like semantics and skip -@@ -1704,6 +1711,14 @@ static inline void my_exit ( int x ) - - /*-------------------- memcpy_chk --------------------*/ - -+/* See https://bugs.kde.org/show_bug.cgi?id=402833 -+ why we disable the overlap check on x86_64. */ -+#if defined(VGP_amd64_linux) -+ #define CHECK_OVERLAP 0 -+#else -+ #define CHECK_OVERLAP 1 -+#endif -+ - #define GLIBC26___MEMCPY_CHK(soname, fnname) \ - void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \ - (void* dst, const void* src, SizeT len, SizeT dstlen ); \ -@@ -1717,7 +1732,7 @@ static inline void my_exit ( int x ) - RECORD_COPY(len); \ - if (len == 0) \ - return dst; \ -- if (is_overlap(dst, src, len, len)) \ -+ if (CHECK_OVERLAP && is_overlap(dst, src, len, len)) \ - RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \ - if ( dst > src ) { \ - d = (HChar *)dst + len - 1; \ From b86a6d3e9f0f1d06ac064ac7599f327e565579bf Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 17 Nov 2023 13:49:17 +0100 Subject: [PATCH 31/86] Add valgrind-3.22.0-valgrind-monitor-python-re.patch --- ...nd-3.22.0-valgrind-monitor-python-re.patch | 32 +++++++++++++++++++ valgrind.spec | 11 ++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.22.0-valgrind-monitor-python-re.patch diff --git a/valgrind-3.22.0-valgrind-monitor-python-re.patch b/valgrind-3.22.0-valgrind-monitor-python-re.patch new file mode 100644 index 0000000..61d26cd --- /dev/null +++ b/valgrind-3.22.0-valgrind-monitor-python-re.patch @@ -0,0 +1,32 @@ +commit 0fbfbe05028ad18efda786a256a2738d2c231ed4 +Author: Mark Wielaard +Date: Fri Nov 17 13:31:52 2023 +0100 + + valgrind-monitor.py regular expressions should use raw strings + + With python 3.12 gdb will produce the following SyntaxWarning when + loading valgrind-monitor-def.py: + + /usr/share/gdb/auto-load/valgrind-monitor-def.py:214: + SyntaxWarning: invalid escape sequence '\[' + if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): + + In a future python version this will become an SyntaxError. + + Use a raw strings for the regular expression. + + https://bugs.kde.org/show_bug.cgi?id=476708 + +diff --git a/coregrind/m_gdbserver/valgrind-monitor-def.py b/coregrind/m_gdbserver/valgrind-monitor-def.py +index b4e7b992d..d74b1590c 100644 +--- a/coregrind/m_gdbserver/valgrind-monitor-def.py ++++ b/coregrind/m_gdbserver/valgrind-monitor-def.py +@@ -211,7 +211,7 @@ class Valgrind_ADDR_LEN_opt(Valgrind_Command): + For compatibility reason with the Valgrind gdbserver monitor command, + we detect and accept usages such as 0x1234ABCD[10].""" + def invoke(self, arg_str : str, from_tty : bool) -> None: +- if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): ++ if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): + arg_str = arg_str.replace("[", " ") + arg_str = arg_str.replace("]", " ") + eval_execute_2(self, arg_str, diff --git a/valgrind.spec b/valgrind.spec index fd14ef0..c658948 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -88,6 +88,10 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch +# valgrind-monitor.py regular expressions should use raw strings +# https://bugs.kde.org/show_bug.cgi?id=476708 +Patch5: valgrind-3.22.0-valgrind-monitor-python-re.patch + BuildRequires: make BuildRequires: glibc-devel @@ -226,6 +230,8 @@ Valgrind User Manual for details. %patch -P4 -p1 %endif +%patch -P5 -p1 + %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -458,6 +464,9 @@ fi %endif %changelog +* Fri Nov 17 2023 Mark Wielaard - 3.22.0-2 +- Add valgrind-3.22.0-valgrind-monitor-python-re.patch + * Tue Oct 31 2023 Mark Wielaard - 3.22.0-1 - Upstream 3.22.0 final - BuildRequires elfutils-debuginfod for testing From 9c3fb46e674e0ff1105e0658ceb840f8336bec05 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 17 Nov 2023 15:04:55 +0100 Subject: [PATCH 32/86] 3.22.0-2 - Drop support for rhel6 --- valgrind.spec | 47 +++++------------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index c658948..abef8fd 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -14,7 +14,7 @@ URL: https://www.valgrind.org/ # We never want the openmpi subpackage when building a software collecton. # We always want it for fedora. -# We only want it for older rhel. But not s390x for too old rhel. +# We only want it for older rhel. # And on fedora > 39 i386 dropped openmpi. %if %{is_scl} %global build_openmpi 0 @@ -30,11 +30,7 @@ URL: https://www.valgrind.org/ %if 0%{?rhel} > 7 %global build_openmpi 0 %else - %ifarch s390x - %global build_openmpi (%{?rhel} > 6) - %else - %global build_openmpi 1 - %endif + %global build_openmpi 1 %endif %endif %endif @@ -54,17 +50,11 @@ URL: https://www.valgrind.org/ # Whether to run the full regtest or only a limited set # The full regtest includes gdb_server integration tests # and experimental tools. -# Only run full regtests on fedora, but not on older rhel -# or when creating scl, the gdb_server tests might hang. +# Don't run them when creating scl, the gdb_server tests might hang. %if %{is_scl} %global run_full_regtest 0 %else - %if 0%{?fedora} - %global run_full_regtest 1 - %endif - %if 0%{?rhel} - %global run_full_regtest (%rhel >= 7) - %endif + %global run_full_regtest 1 %endif # Generating minisymtabs doesn't really work for the staticly linked @@ -132,13 +122,6 @@ Recommends: elfutils-debuginfod-client %{?scl:Requires:%scl_runtime} -# We need to fixup selinux file context when doing a scl build. -# In RHEL6 we might need to fix up the labels even though the -# meta package sets up a fs equivalence. See post. -%if 0%{?rhel} == 6 -%{?scl:Requires(post): /sbin/restorecon} -%endif - # We could use %%valgrind_arches as defined in redhat-rpm-config # But that is really for programs using valgrind, it defines the # set of architectures that valgrind works correctly on. @@ -223,12 +206,8 @@ Valgrind User Manual for details. %patch -P1 -p1 %patch -P2 -p1 - -# Old rhel gcc doesn't have -fstack-protector-strong. -%if 0%{?fedora} || 0%{?rhel} >= 7 %patch -P3 -p1 %patch -P4 -p1 -%endif %patch -P5 -p1 @@ -242,14 +221,9 @@ Valgrind User Manual for details. # Just always autoreconf so we don't need patches to prebuild files. ./autogen.sh -# Old openmpi-devel has version depended paths for mpicc. %if %{build_openmpi} -%if 0%{?fedora} >= 13 || 0%{?rhel} >= 6 %define mpiccpath %{!?scl:%{_libdir}}%{?scl:%{_root_libdir}}/openmpi/bin/mpicc %else -%define mpiccpath %{!?scl:%{_libdir}}%{?scl:%{_root_libdir}}/openmpi/*/bin/mpicc -%endif -%else # We explicitly don't want the libmpi wrapper. So make sure that configure # doesn't pick some random mpi compiler that happens to be installed. %define mpiccpath /bin/false @@ -451,21 +425,10 @@ echo ===============END TESTING=============== %{_libdir}/valgrind/libmpiwrap*.so %endif -%if 0%{?rhel} == 6 -%post -# There is a bug in rpm (rhbz#214737) that might cause post to be run -# even thought the binary isn't installed when installing two multilib -# versions at the same time. -if [ -x %{_bindir}/valgrind ]; then -# On RHEL6 the fs equivalency should be setup by the devtoolset meta -# package, but because of a rpm bug (rhbz#924044) it might not work. -%{?scl:/sbin/restorecon %{_bindir}/valgrind}%{!?scl:true} -fi -%endif - %changelog * Fri Nov 17 2023 Mark Wielaard - 3.22.0-2 - Add valgrind-3.22.0-valgrind-monitor-python-re.patch +- Drop support for rhel6 * Tue Oct 31 2023 Mark Wielaard - 3.22.0-1 - Upstream 3.22.0 final From ae4f286130200ae1085da61d4a8347ed94a1f20d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 5 Dec 2023 23:09:25 +0100 Subject: [PATCH 33/86] 3.22.0-3 - Add valgrind-3.22.0-rodata.patch --- valgrind-3.22.0-rodata.patch | 122 +++++++++++++++++++++++++++++++++++ valgrind.spec | 10 ++- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.22.0-rodata.patch diff --git a/valgrind-3.22.0-rodata.patch b/valgrind-3.22.0-rodata.patch new file mode 100644 index 0000000..47f31ed --- /dev/null +++ b/valgrind-3.22.0-rodata.patch @@ -0,0 +1,122 @@ +commit 1d00e5ce0fb069911c4b525ec38289fb5d9021b0 +Author: Paul Floyd +Date: Sat Nov 18 08:49:34 2023 +0100 + + Bug 476548 - valgrind 3.22.0 fails on assertion when loading debuginfo file produced by mold + + (cherry picked from commit 9ea4ae66707a4dcc6f4328e11911652e4418c585) + +diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c +index 02e509071..445f95555 100644 +--- a/coregrind/m_debuginfo/image.c ++++ b/coregrind/m_debuginfo/image.c +@@ -1221,6 +1221,20 @@ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2) + } + } + ++Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n) ++{ ++ ensure_valid(img, off1, 1, "ML_(img_strcmp_c)"); ++ while (n) { ++ UChar c1 = get(img, off1); ++ UChar c2 = *(const UChar*)str2; ++ if (c1 < c2) return -1; ++ if (c1 > c2) return 1; ++ if (c1 == 0) return 0; ++ off1++; str2++; --n; ++ } ++ return 0; ++} ++ + UChar ML_(img_get_UChar)(DiImage* img, DiOffT offset) + { + ensure_valid(img, offset, 1, "ML_(img_get_UChar)"); +diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h +index a49846f14..c91e49f01 100644 +--- a/coregrind/m_debuginfo/priv_image.h ++++ b/coregrind/m_debuginfo/priv_image.h +@@ -115,6 +115,10 @@ Int ML_(img_strcmp)(DiImage* img, DiOffT off1, DiOffT off2); + cast to HChar before comparison. */ + Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2); + ++/* Do strncmp of a C string in the image vs a normal one. Chars are ++ cast to HChar before comparison. */ ++Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n); ++ + /* Do strlen of a C string in the image. */ + SizeT ML_(img_strlen)(DiImage* img, DiOffT off); + +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index fb64ed976..46f8c8343 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -2501,8 +2501,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) + di->rodata_avma += inrw1->bias; + di->rodata_bias = inrw1->bias; + di->rodata_debug_bias = inrw1->bias; +- } +- else { ++ } else { + BAD(".rodata"); /* should not happen? */ + } + di->rodata_present = True; +@@ -2977,6 +2976,46 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) + return retval; + } + ++static void find_rodata(Word i, Word shnum, DiImage* dimg, struct _DebugInfo* di, DiOffT shdr_dioff, ++ UWord shdr_dent_szB, DiOffT shdr_strtab_dioff, PtrdiffT rw_dbias) ++{ ++ ElfXX_Shdr a_shdr; ++ ElfXX_Shdr a_extra_shdr; ++ ML_(img_get)(&a_shdr, dimg, ++ INDEX_BIS(shdr_dioff, i, shdr_dent_szB), ++ sizeof(a_shdr)); ++ if (di->rodata_present && ++ 0 == ML_(img_strcmp_c)(dimg, shdr_strtab_dioff ++ + a_shdr.sh_name, ".rodata")) { ++ Word sh_size = a_shdr.sh_size; ++ Word j; ++ Word next_addr = a_shdr.sh_addr + a_shdr.sh_size; ++ for (j = i + 1; j < shnum; ++j) { ++ ML_(img_get)(&a_extra_shdr, dimg, ++ INDEX_BIS(shdr_dioff, j, shdr_dent_szB), ++ sizeof(a_shdr)); ++ if (0 == ML_(img_strcmp_n)(dimg, shdr_strtab_dioff ++ + a_extra_shdr.sh_name, ".rodata", 7)) { ++ if (a_extra_shdr.sh_addr == ++ VG_ROUNDUP(next_addr, a_extra_shdr.sh_addralign)) { ++ sh_size = VG_ROUNDUP(sh_size, a_extra_shdr.sh_addralign) + a_extra_shdr.sh_size; ++ } ++ next_addr = a_extra_shdr.sh_addr + a_extra_shdr.sh_size; ++ } else { ++ break; ++ } ++ } ++ vg_assert(di->rodata_size == sh_size); ++ vg_assert(di->rodata_avma + a_shdr.sh_addr + rw_dbias); ++ di->rodata_debug_svma = a_shdr.sh_addr; ++ di->rodata_debug_bias = di->rodata_bias + ++ di->rodata_svma - di->rodata_debug_svma; ++ TRACE_SYMTAB("acquiring .rodata debug svma = %#lx .. %#lx\n", ++ di->rodata_debug_svma, ++ di->rodata_debug_svma + di->rodata_size - 1); ++ TRACE_SYMTAB("acquiring .rodata debug bias = %#lx\n", (UWord)di->rodata_debug_bias); ++ } ++} + Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) + { + Word i, j; +@@ -3391,7 +3430,11 @@ Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) + FIND(text, rx) + FIND(data, rw) + FIND(sdata, rw) +- FIND(rodata, rw) ++ // https://bugs.kde.org/show_bug.cgi?id=476548 ++ // special handling for rodata as adjacent ++ // rodata sections may have been merged in ML_(read_elf_object) ++ //FIND(rodata, rw) ++ find_rodata(i, ehdr_dimg.e_shnum, dimg, di, shdr_dioff, shdr_dent_szB, shdr_strtab_dioff, rw_dbias); + FIND(bss, rw) + FIND(sbss, rw) + diff --git a/valgrind.spec b/valgrind.spec index abef8fd..e607f68 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -82,6 +82,10 @@ Patch4: valgrind-3.16.0-some-Wl-z-now.patch # https://bugs.kde.org/show_bug.cgi?id=476708 Patch5: valgrind-3.22.0-valgrind-monitor-python-re.patch +# valgrind 3.22.0 fails on assertion when loading debuginfo +# https://bugs.kde.org/show_bug.cgi?id=476548 +Patch6: valgrind-3.22.0-rodata.patch + BuildRequires: make BuildRequires: glibc-devel @@ -210,6 +214,7 @@ Valgrind User Manual for details. %patch -P4 -p1 %patch -P5 -p1 +%patch -P6 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -426,6 +431,9 @@ echo ===============END TESTING=============== %endif %changelog +* Tue Dec 5 2023 Mark Wielaard - 3.22.0-3 +- Add valgrind-3.22.0-rodata.patch + * Fri Nov 17 2023 Mark Wielaard - 3.22.0-2 - Add valgrind-3.22.0-valgrind-monitor-python-re.patch - Drop support for rhel6 From 70f76aaabfd8f926f6b3528289939f9fcdb54461 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 9 Dec 2023 22:29:05 +0100 Subject: [PATCH 34/86] Add valgrind-3.22.0-fchmodat2.patch --- valgrind-3.22.0-fchmodat2.patch | 206 ++++++++++++++++++++++++++++++++ valgrind.spec | 8 ++ 2 files changed, 214 insertions(+) create mode 100644 valgrind-3.22.0-fchmodat2.patch diff --git a/valgrind-3.22.0-fchmodat2.patch b/valgrind-3.22.0-fchmodat2.patch new file mode 100644 index 0000000..b1ba313 --- /dev/null +++ b/valgrind-3.22.0-fchmodat2.patch @@ -0,0 +1,206 @@ +From a43e62dddcf51ec6578a90c5988a41e856b44b05 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sat, 18 Nov 2023 21:17:02 +0100 +Subject: [PATCH] Add fchmodat2 syscall on linux + +fchmodat2 is a new syscall on linux 6.6. It is a variant of fchmodat +that takes an extra flags argument. + +https://bugs.kde.org/show_bug.cgi?id=477198 + +(cherry picked from commit 372d09fd9a8d76847c81092ebff71c80fd6c145d) +--- + NEWS | 1 + + coregrind/m_syswrap/priv_syswrap-linux.h | 3 +++ + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-linux.c | 11 +++++++++++ + coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + + coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + + coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ + coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ + include/vki/vki-scnums-shared-linux.h | 2 ++ + 14 files changed, 35 insertions(+) + +diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h +index 7c9decf5a..798c456c9 100644 +--- a/coregrind/m_syswrap/priv_syswrap-linux.h ++++ b/coregrind/m_syswrap/priv_syswrap-linux.h +@@ -331,6 +331,9 @@ DECL_TEMPLATE(linux, sys_openat2); + // Linux-specific (new in Linux 5.14) + DECL_TEMPLATE(linux, sys_memfd_secret); + ++// Since Linux 6.6 ++DECL_TEMPLATE(linux, sys_fchmodat2); ++ + /* --------------------------------------------------------------------- + Wrappers for sockets and ipc-ery. These are split into standalone + procedures because x86-linux hides them inside multiplexors +diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c +index 008600798..fe17d118b 100644 +--- a/coregrind/m_syswrap/syswrap-amd64-linux.c ++++ b/coregrind/m_syswrap/syswrap-amd64-linux.c +@@ -886,6 +886,8 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 ++ ++ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c +index 9a7a1e0d2..811931d3b 100644 +--- a/coregrind/m_syswrap/syswrap-arm-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm-linux.c +@@ -1059,6 +1059,8 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ ++ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + +diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c +index 6af7bab83..3307bc2ca 100644 +--- a/coregrind/m_syswrap/syswrap-arm64-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm64-linux.c +@@ -840,6 +840,8 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 ++ ++ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index d571fc327..efa47f2e6 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -6059,6 +6059,17 @@ PRE(sys_fchmodat) + PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 ); + } + ++PRE(sys_fchmodat2) ++{ ++ PRINT("sys_fchmodat2 ( %ld, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" ++ FMT_REGWORD "u )", ++ SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4); ++ PRE_REG_READ4(long, "fchmodat2", ++ int, dfd, const char *, path, vki_mode_t, mode, ++ unsigned int, flags); ++ PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 ); ++} ++ + PRE(sys_faccessat) + { + PRINT("sys_faccessat ( %ld, %#" FMT_REGWORD "x(%s), %ld )", +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index 6268a00dd..74a1f6eac 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1143,6 +1143,8 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_ (__NR_faccessat2, sys_faccessat2), // 439 + + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ ++ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) +diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c +index 6cdf25893..4e8508b7a 100644 +--- a/coregrind/m_syswrap/syswrap-mips64-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips64-linux.c +@@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY (__NR_close_range, sys_close_range), + LINX_ (__NR_faccessat2, sys_faccessat2), + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), ++ LINX_ (__NR_fchmodat2, sys_fchmodat2), + }; + + SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c +index d724cde74..7859900c1 100644 +--- a/coregrind/m_syswrap/syswrap-nanomips-linux.c ++++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c +@@ -829,6 +829,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY (__NR_close_range, sys_close_range), + LINX_ (__NR_faccessat2, sys_faccessat2), + LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), ++ LINX_ (__NR_fchmodat2, sys_fchmodat2), + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) +diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c +index c0cfef235..1e19116ee 100644 +--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c +@@ -1063,6 +1063,8 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + + LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ ++ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c +index f5976f30c..1097212a4 100644 +--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c +@@ -1032,6 +1032,8 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + + LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ ++ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c +index afba154e7..3588672c7 100644 +--- a/coregrind/m_syswrap/syswrap-s390x-linux.c ++++ b/coregrind/m_syswrap/syswrap-s390x-linux.c +@@ -873,6 +873,8 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_faccessat2, sys_faccessat2), // 439 + + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 ++ ++ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c +index da4fd8fa2..58badc6b0 100644 +--- a/coregrind/m_syswrap/syswrap-x86-linux.c ++++ b/coregrind/m_syswrap/syswrap-x86-linux.c +@@ -1658,6 +1658,8 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 + + LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 ++ ++ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 + }; + + SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) +diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h +index 542382b53..a4cd87149 100644 +--- a/include/vki/vki-scnums-shared-linux.h ++++ b/include/vki/vki-scnums-shared-linux.h +@@ -50,4 +50,6 @@ + + #define __NR_memfd_secret 447 + ++#define __NR_fchmodat2 452 ++ + #endif +-- +2.39.3 + diff --git a/valgrind.spec b/valgrind.spec index e607f68..e511b7f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -86,6 +86,10 @@ Patch5: valgrind-3.22.0-valgrind-monitor-python-re.patch # https://bugs.kde.org/show_bug.cgi?id=476548 Patch6: valgrind-3.22.0-rodata.patch +# Add fchmodat2 syscall on linux +# https://bugs.kde.org/show_bug.cgi?id=477198 +Patch7: valgrind-3.22.0-fchmodat2.patch + BuildRequires: make BuildRequires: glibc-devel @@ -215,6 +219,7 @@ Valgrind User Manual for details. %patch -P5 -p1 %patch -P6 -p1 +%patch -P7 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -431,6 +436,9 @@ echo ===============END TESTING=============== %endif %changelog +* Sat Dec 9 2023 Mark Wielaard +- Add valgrind-3.22.0-fchmodat2.patch + * Tue Dec 5 2023 Mark Wielaard - 3.22.0-3 - Add valgrind-3.22.0-rodata.patch From ebfe3bd913aecefa5162a004532d37d8315a1712 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 10 Dec 2023 00:03:53 +0100 Subject: [PATCH 35/86] 3.22.0-4 - Prep for migration to SPDX identifiers --- valgrind.spec | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index e511b7f..25feea8 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,9 +3,9 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 1 -License: GPLv2+ +License: GPLv2+ AND BSD URL: https://www.valgrind.org/ # Are we building for a Software Collection? @@ -183,6 +183,11 @@ profiler (callgrind), and a heap profiler (massif). %package devel Summary: Development files for valgrind aware programs +# This is really Hybrid-BSD +# https://fedoraproject.org/wiki/Licensing:BSD#Hybrid_BSD_(half_BSD,_half_zlib) +# But that doesnt have a SPDX identifier yet +# https://gitlab.com/fedora/legal/fedora-license-data/-/issues/422 +License: BSD Requires: %{?scl_prefix}valgrind = %{epoch}:%{version}-%{release} %description devel @@ -201,6 +206,7 @@ Header files and libraries for development of valgrind tools. %if %{build_openmpi} %package openmpi Summary: OpenMPI support for valgrind +License: BSD Requires: %{?scl_prefix}valgrind = %{epoch}:%{version}-%{release} %description openmpi @@ -436,8 +442,9 @@ echo ===============END TESTING=============== %endif %changelog -* Sat Dec 9 2023 Mark Wielaard +* Sat Dec 9 2023 Mark Wielaard - 3.22.0-4 - Add valgrind-3.22.0-fchmodat2.patch +- Prep for migration to SPDX identifiers * Tue Dec 5 2023 Mark Wielaard - 3.22.0-3 - Add valgrind-3.22.0-rodata.patch From fc6a1192e439b035e1d8c978e61b8943c4941ea3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 22 Jan 2024 13:51:09 +0100 Subject: [PATCH 36/86] 3.22.0-5 - Add valgrind-3.22.0-x86-nop.patch --- valgrind-3.22.0-x86-nop.patch | 136 ++++++++++++++++++++++++++++++++++ valgrind.spec | 11 ++- 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.22.0-x86-nop.patch diff --git a/valgrind-3.22.0-x86-nop.patch b/valgrind-3.22.0-x86-nop.patch new file mode 100644 index 0000000..421b291 --- /dev/null +++ b/valgrind-3.22.0-x86-nop.patch @@ -0,0 +1,136 @@ +From d35005cef8ad8207542738812705ceabf137d7e0 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sun, 17 Dec 2023 14:18:51 +0100 +Subject: [PATCH] Bug 478624 - Valgrind incompatibility with binutils-2.42 on + x86 with new nop patterns (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26) + +It was a bit of a struggle to get the testcase to build +with both clang and gcc (oddly enough gcc was more difficult) so +I just resorted to using .byte arrays. +--- + .gitignore | 1 + + NEWS | 2 ++ + VEX/priv/guest_x86_toIR.c | 22 +++++++++++++- + none/tests/x86/Makefile.am | 2 ++ + none/tests/x86/gnu_binutils_nop.c | 34 ++++++++++++++++++++++ + none/tests/x86/gnu_binutils_nop.stderr.exp | 0 + none/tests/x86/gnu_binutils_nop.vgtest | 2 ++ + 7 files changed, 62 insertions(+), 1 deletion(-) + create mode 100644 none/tests/x86/gnu_binutils_nop.c + create mode 100644 none/tests/x86/gnu_binutils_nop.stderr.exp + create mode 100644 none/tests/x86/gnu_binutils_nop.vgtest + +diff --git a/VEX/priv/guest_x86_toIR.c b/VEX/priv/guest_x86_toIR.c +index 5d6e6dc64..3b6efb387 100644 +--- a/VEX/priv/guest_x86_toIR.c ++++ b/VEX/priv/guest_x86_toIR.c +@@ -8198,7 +8198,7 @@ DisResult disInstr_X86_WRK ( + delta += 5; + goto decode_success; + } +- /* Don't barf on recent binutils padding, ++ /* Don't barf on recent (2010) binutils padding, + all variants of which are: nopw %cs:0x0(%eax,%eax,1) + 66 2e 0f 1f 84 00 00 00 00 00 + 66 66 2e 0f 1f 84 00 00 00 00 00 +@@ -8223,6 +8223,26 @@ DisResult disInstr_X86_WRK ( + } + } + ++ /* bug478624 GNU binutils uses a leal of esi into itself with ++ a zero offset and CS prefix as an 8 byte no-op (Dec 2023). ++ Since the CS prefix is hardly ever used we don't do much ++ to decode it, just a few cases for conditional branches. ++ So add handling here with other pseudo-no-ops. ++ */ ++ if (code[0] == 0x2E && code[1] == 0x8D) { ++ if (code[2] == 0x74 && code[3] == 0x26 && code[4] == 0x00) { ++ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n"); ++ delta += 5; ++ goto decode_success; ++ } ++ if (code[2] == 0xB4 && code[3] == 0x26 && code[4] == 0x00 ++ && code[5] == 0x00 && code[6] == 0x00 && code[7] == 0x00) { ++ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n"); ++ delta += 8; ++ goto decode_success; ++ } ++ } ++ + // Intel CET requires the following opcodes to be treated as NOPs + // with any prefix and ModRM, SIB and disp combination: + // "0F 19", "0F 1C", "0F 1D", "0F 1E", "0F 1F" +diff --git a/none/tests/x86/Makefile.am b/none/tests/x86/Makefile.am +index 3ecd1ad3c..dbae86571 100644 +--- a/none/tests/x86/Makefile.am ++++ b/none/tests/x86/Makefile.am +@@ -52,6 +52,7 @@ EXTRA_DIST = \ + fxtract.stdout.exp fxtract.stderr.exp fxtract.vgtest \ + fxtract.stdout.exp-older-glibc \ + getseg.stdout.exp getseg.stderr.exp getseg.vgtest \ ++ gnu_binutils_nop.stderr.exp gnu_binutils_nop.vgtest \ + incdec_alt.stdout.exp incdec_alt.stderr.exp incdec_alt.vgtest \ + int.stderr.exp int.stdout.exp int.disabled \ + $(addsuffix .stderr.exp,$(INSN_TESTS)) \ +@@ -100,6 +101,7 @@ check_PROGRAMS = \ + fpu_lazy_eflags \ + fxtract \ + getseg \ ++ gnu_binutils_nop \ + incdec_alt \ + $(INSN_TESTS) \ + int \ +diff --git a/none/tests/x86/gnu_binutils_nop.c b/none/tests/x86/gnu_binutils_nop.c +new file mode 100644 +index 000000000..412a4c2cb +--- /dev/null ++++ b/none/tests/x86/gnu_binutils_nop.c +@@ -0,0 +1,34 @@ ++int main(void) ++{ ++ // GNU binutils uses various opcodes as alternatives for nop ++ // the idea is that it is faster to execute one large opcode ++ // with no side-effects than multiple repetitions of the ++ // single byte 'nop'. This gives more choice when code ++ // needs to be padded. ++ ++ // the following is based on ++ // https://sourceware.org/cgit/binutils-gdb/tree/gas/config/tc-i386.c#n1256 ++ ++ // one byte ++ __asm__ __volatile__("nop"); ++ // two bytes ++ __asm__ __volatile__("xchg %ax,%ax"); ++ // three bytes ++ //__asm__ __volatile__("leal 0(%esi),%esi"); ++ __asm__ __volatile__(".byte 0x8d,0x76,0x00"); ++ // four bytes ++ //__asm__ __volatile__("leal 0(%esi,%eiz),%esi"); ++ __asm__ __volatile__(".byte 0x8d,0x74,0x26,0x00"); ++ // five bytes ++ //__asm__ __volatile__("leal %cs:0(%esi,%eiz),%esi"); ++ __asm__ __volatile__(".byte 0x2e,0x8d,0x74,0x26,0x00"); ++ // six bytes ++ //__asm__ __volatile__("leal 0L(%esi),%esi"); ++ __asm__ __volatile__(".byte 0x8d,0xb6,0x00,0x00,0x00,0x00"); ++ // seven bytes ++ //__asm__ __volatile__("leal 0L(%esi,%eiz),%esi"); ++ __asm__ __volatile__(".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00"); ++ // eight bytes ++ //__asm__ __volatile__("leal %cs:0L(%esi,%eiz),%esi"); ++ __asm__ __volatile__(".byte 0x2e,0x8d,0xb4,0x26,0x00,0x00,0x00,0x00"); ++} +diff --git a/none/tests/x86/gnu_binutils_nop.stderr.exp b/none/tests/x86/gnu_binutils_nop.stderr.exp +new file mode 100644 +index 000000000..e69de29bb +diff --git a/none/tests/x86/gnu_binutils_nop.vgtest b/none/tests/x86/gnu_binutils_nop.vgtest +new file mode 100644 +index 000000000..7f378dd53 +--- /dev/null ++++ b/none/tests/x86/gnu_binutils_nop.vgtest +@@ -0,0 +1,2 @@ ++prog: gnu_binutils_nop ++vgopts: -q +-- +2.43.0 + diff --git a/valgrind.spec b/valgrind.spec index 25feea8..b81a407 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 4%{?dist} +Release: 5%{?dist} Epoch: 1 License: GPLv2+ AND BSD URL: https://www.valgrind.org/ @@ -90,6 +90,11 @@ Patch6: valgrind-3.22.0-rodata.patch # https://bugs.kde.org/show_bug.cgi?id=477198 Patch7: valgrind-3.22.0-fchmodat2.patch +# Valgrind incompatibility with binutils-2.42 on x86 with new nop patterns +# (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26) +# https://bugs.kde.org/show_bug.cgi?id=478624 +Patch8: valgrind-3.22.0-x86-nop.patch + BuildRequires: make BuildRequires: glibc-devel @@ -226,6 +231,7 @@ Valgrind User Manual for details. %patch -P5 -p1 %patch -P6 -p1 %patch -P7 -p1 +%patch -P8 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -442,6 +448,9 @@ echo ===============END TESTING=============== %endif %changelog +* Mon Jan 22 2023 Mark Wielaard - 3.22.0-5 +- Add valgrind-3.22.0-x86-nop.patch + * Sat Dec 9 2023 Mark Wielaard - 3.22.0-4 - Add valgrind-3.22.0-fchmodat2.patch - Prep for migration to SPDX identifiers From 0e24fe58be57fa4cfeee421b3d03866f49d8ac95 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 22 Jan 2024 14:23:53 +0100 Subject: [PATCH 37/86] Fix date in changelog, it is 2024 already --- valgrind.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index b81a407..a38f0af 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -448,7 +448,7 @@ echo ===============END TESTING=============== %endif %changelog -* Mon Jan 22 2023 Mark Wielaard - 3.22.0-5 +* Mon Jan 22 2024 Mark Wielaard - 3.22.0-5 - Add valgrind-3.22.0-x86-nop.patch * Sat Dec 9 2023 Mark Wielaard - 3.22.0-4 From fedf3d4030dbad87b04085dbbec5e2666f50b36d Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 27 Jan 2024 07:28:38 +0000 Subject: [PATCH 38/86] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- valgrind.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index a38f0af..c0dcfbc 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 5%{?dist} +Release: 6%{?dist} Epoch: 1 License: GPLv2+ AND BSD URL: https://www.valgrind.org/ @@ -448,6 +448,9 @@ echo ===============END TESTING=============== %endif %changelog +* Sat Jan 27 2024 Fedora Release Engineering - 1:3.22.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Mon Jan 22 2024 Mark Wielaard - 3.22.0-5 - Add valgrind-3.22.0-x86-nop.patch From 5ef9ac5930c3bddd1a27572694cf327abc109a72 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 4 Mar 2024 16:34:58 +0100 Subject: [PATCH 39/86] Update Fedora license tags to spdx license tags --- valgrind.spec | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index c0dcfbc..7401c3b 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -5,7 +5,14 @@ Name: %{?scl_prefix}valgrind Version: 3.22.0 Release: 6%{?dist} Epoch: 1 -License: GPLv2+ AND BSD + +# This ignores licenses that are only found in the test or perf sources +# we only care about those license statements found in sources that end +# up in the binary packages. One piece of code for which we don't have +# a license specifier is in coregrind/m_main.c for some Hacker's Delight +# public domain code, which is only compiled into Darwin binaries, which +# we don't create. Also some subpackages have their own license tags. +License: GPL-2.0-or-later AND bzip2-1.0.6 AND GFDL-1.2-or-later AND (GPL-2.0-or-later AND LGPL-2.0-or-later) AND (GPL-2.0-or-later AND ISC) AND (GPL-2.0-or-later AND Unlicense) AND (GPL-2.0-or-later AND Zlib) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later AND BSD-3-Clause) AND (GPL-2.0-or-later AND (MIT OR NCSA)) AND CMU-Mach AND (GPL-2.0-or-later AND X11 AND BSD-3-Clause) AND X11 AND (GPL-2.0-or-later AND LGPL-2.0-or-later) AND (GPL-2.0-or-later AND (GPL-2.0-or-later OR MPL-2.0)) AND (GPL-2.0-or-later WITH Autoconf-exception-generic) AND (GPL-3.0-or-later WITH Autoconf-exception-generic-3.0) AND FSFULLR AND FSFAP AND FSFUL AND FSFULLRWD URL: https://www.valgrind.org/ # Are we building for a Software Collection? @@ -192,7 +199,7 @@ Summary: Development files for valgrind aware programs # https://fedoraproject.org/wiki/Licensing:BSD#Hybrid_BSD_(half_BSD,_half_zlib) # But that doesnt have a SPDX identifier yet # https://gitlab.com/fedora/legal/fedora-license-data/-/issues/422 -License: BSD +License: bzip2-1.0.6 Requires: %{?scl_prefix}valgrind = %{epoch}:%{version}-%{release} %description devel @@ -211,7 +218,8 @@ Header files and libraries for development of valgrind tools. %if %{build_openmpi} %package openmpi Summary: OpenMPI support for valgrind -License: BSD +# See above, Hybrid-BSD like. +License: bzip2-1.0.6 Requires: %{?scl_prefix}valgrind = %{epoch}:%{version}-%{release} %description openmpi @@ -448,6 +456,9 @@ echo ===============END TESTING=============== %endif %changelog +* Mon Mar 4 2024 Mark Wielaard +- Update Fedora license tags to spdx license tags + * Sat Jan 27 2024 Fedora Release Engineering - 1:3.22.0-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 489c705d3f7f77c0e8319eb48533d6794dc53933 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 11 Mar 2024 21:18:28 +0100 Subject: [PATCH 40/86] 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2 https://bugzilla.redhat.com/show_bug.cgi?id=2257546 --- ...cc-builtin_strcmp-128-256-bit-vector.patch | 355 ++++++++++++++++++ valgrind.spec | 10 +- 2 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch diff --git a/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch b/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch new file mode 100644 index 0000000..cbcf6e0 --- /dev/null +++ b/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch @@ -0,0 +1,355 @@ +From 316ef0d22b6f41722cc71316a6b59e60e7c9576c Mon Sep 17 00:00:00 2001 +From: Julian Seward +Date: Mon, 11 Mar 2024 17:53:14 +0100 +Subject: [PATCH] Handle gcc __builtin_strcmp using 128/256 bit vectors with + sse4.1, avx/avx2 + +* amd64 front end: redo the translation into IR for PTEST, so as to + use only IROps which we know Memcheck can do exact instrumentation + for. Handling for both the 128- and 256-bit cases is has been + changed. + +* ir_opt.c: add some constant folding rules to support the above. In + particular, for the case `ptest %reg, %reg` (the same reg twice), we + want rflags.C to be set to a defined-1 even if %reg is completely + undefined. Doing that requires folding `x and not(x)` to zero when + x has type V128 or V256. + +* memcheck/tests/amd64/rh2257546_{128,256}.c: new test cases + +https://bugzilla.redhat.com/show_bug.cgi?id=2257546 +--- + VEX/priv/guest_amd64_toIR.c | 64 +++++++++---------- + VEX/priv/ir_opt.c | 34 ++++++++++ + memcheck/tests/amd64/Makefile.am | 7 +- + memcheck/tests/amd64/rh2257546_128.c | 32 ++++++++++ + memcheck/tests/amd64/rh2257546_128.stderr.exp | 0 + memcheck/tests/amd64/rh2257546_128.stdout.exp | 1 + + memcheck/tests/amd64/rh2257546_128.vgtest | 2 + + memcheck/tests/amd64/rh2257546_256.c | 32 ++++++++++ + memcheck/tests/amd64/rh2257546_256.stderr.exp | 0 + memcheck/tests/amd64/rh2257546_256.stdout.exp | 1 + + memcheck/tests/amd64/rh2257546_256.vgtest | 3 + + 11 files changed, 141 insertions(+), 35 deletions(-) + create mode 100644 memcheck/tests/amd64/rh2257546_128.c + create mode 100644 memcheck/tests/amd64/rh2257546_128.stderr.exp + create mode 100644 memcheck/tests/amd64/rh2257546_128.stdout.exp + create mode 100644 memcheck/tests/amd64/rh2257546_128.vgtest + create mode 100644 memcheck/tests/amd64/rh2257546_256.c + create mode 100644 memcheck/tests/amd64/rh2257546_256.stderr.exp + create mode 100644 memcheck/tests/amd64/rh2257546_256.stdout.exp + create mode 100644 memcheck/tests/amd64/rh2257546_256.vgtest + +diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c +index 0414aa5c5..d7c25042d 100644 +--- a/VEX/priv/guest_amd64_toIR.c ++++ b/VEX/priv/guest_amd64_toIR.c +@@ -16826,13 +16826,18 @@ static Long dis_VBLENDV_256 ( const VexAbiInfo* vbi, Prefix pfx, Long delta, + + static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) + { +- /* Set Z=1 iff (vecE & vecG) == 0 +- Set C=1 iff (vecE & not vecG) == 0 ++ /* Set Z=1 iff (vecE & vecG) == 0--(128)--0 ++ Set C=1 iff (vecE & not vecG) == 0--(128)--0 ++ ++ For the case `sign == 0`, be careful to use only IROps that can be ++ instrumented exactly by memcheck. This is because PTEST is used for ++ __builtin_strcmp in gcc14. See ++ https://bugzilla.redhat.com/show_bug.cgi?id=2257546 + */ + + /* andV, andnV: vecE & vecG, vecE and not(vecG) */ + +- /* andV resp. andnV, reduced to 64-bit values, by or-ing the top ++ /* andV resp. andnV, are reduced to 64-bit values by or-ing the top + and bottom 64-bits together. It relies on this trick: + + InterleaveLO64x2([a,b],[c,d]) == [b,d] hence +@@ -16862,11 +16867,13 @@ static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) + binop(Iop_InterleaveHI64x2, + mkexpr(andnV), mkexpr(andnV))))); + ++ // Make z64 and c64 be either all-0s or all-1s + IRTemp z64 = newTemp(Ity_I64); + IRTemp c64 = newTemp(Ity_I64); ++ + if (sign == 64) { +- /* When only interested in the most significant bit, just shift +- arithmetically right and negate. */ ++ /* When only interested in the most significant bit, just copy bit 63 ++ into all bit positions, then invert. */ + assign(z64, + unop(Iop_Not64, + binop(Iop_Sar64, mkexpr(and64), mkU8(63)))); +@@ -16874,37 +16881,28 @@ static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) + assign(c64, + unop(Iop_Not64, + binop(Iop_Sar64, mkexpr(andn64), mkU8(63)))); +- } else { +- if (sign == 32) { +- /* When interested in bit 31 and bit 63, mask those bits and +- fallthrough into the PTEST handling. */ +- IRTemp t0 = newTemp(Ity_I64); +- IRTemp t1 = newTemp(Ity_I64); +- IRTemp t2 = newTemp(Ity_I64); +- assign(t0, mkU64(0x8000000080000000ULL)); +- assign(t1, binop(Iop_And64, mkexpr(and64), mkexpr(t0))); +- assign(t2, binop(Iop_And64, mkexpr(andn64), mkexpr(t0))); +- and64 = t1; +- andn64 = t2; +- } +- /* Now convert and64, andn64 to all-zeroes or all-1s, so we can +- slice out the Z and C bits conveniently. We use the standard +- trick all-zeroes -> all-zeroes, anything-else -> all-ones +- done by "(x | -x) >>s (word-size - 1)". +- */ ++ } else if (sign == 32) { ++ /* If we're interested into bits 63 and 31, OR bit 31 into bit 63, copy ++ bit 63 into all bit positions, then invert. */ ++ IRTemp and3264 = newTemp(Ity_I64); ++ assign(and3264, binop(Iop_Or64, mkexpr(and64), ++ binop(Iop_Shl64, mkexpr(and64), mkU8(32)))); + assign(z64, + unop(Iop_Not64, +- binop(Iop_Sar64, +- binop(Iop_Or64, +- binop(Iop_Sub64, mkU64(0), mkexpr(and64)), +- mkexpr(and64)), mkU8(63)))); ++ binop(Iop_Sar64, mkexpr(and3264), mkU8(63)))); + ++ IRTemp andn3264 = newTemp(Ity_I64); ++ assign(andn3264, binop(Iop_Or64, mkexpr(andn64), ++ binop(Iop_Shl64, mkexpr(andn64), mkU8(32)))); + assign(c64, + unop(Iop_Not64, +- binop(Iop_Sar64, +- binop(Iop_Or64, +- binop(Iop_Sub64, mkU64(0), mkexpr(andn64)), +- mkexpr(andn64)), mkU8(63)))); ++ binop(Iop_Sar64, mkexpr(andn3264), mkU8(63)))); ++ } else { ++ vassert(sign == 0); ++ assign(z64, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(and64), mkU64(0)), ++ mkU64(~0ULL), mkU64(0ULL))); ++ assign(c64, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(andn64), mkU64(0)), ++ mkU64(~0ULL), mkU64(0ULL))); + } + + /* And finally, slice out the Z and C flags and set the flags +@@ -16966,9 +16964,7 @@ static Long dis_xTESTy_128 ( const VexAbiInfo* vbi, Prefix pfx, + IRTemp andnV = newTemp(Ity_V128); + assign(andV, binop(Iop_AndV128, mkexpr(vecE), mkexpr(vecG))); + assign(andnV, binop(Iop_AndV128, +- mkexpr(vecE), +- binop(Iop_XorV128, mkexpr(vecG), +- mkV128(0xFFFF)))); ++ mkexpr(vecE), unop(Iop_NotV128, mkexpr(vecG)))); + + finish_xTESTy ( andV, andnV, sign ); + return delta; +diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c +index f918e9f85..6453f4fdf 100644 +--- a/VEX/priv/ir_opt.c ++++ b/VEX/priv/ir_opt.c +@@ -1693,6 +1693,17 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) + break; + } + ++ /* Similarly .. */ ++ case Iop_V256toV128_0: case Iop_V256toV128_1: { ++ UInt v256 = e->Iex.Unop.arg->Iex.Const.con->Ico.V256; ++ if (v256 == 0x00000000) { ++ e2 = IRExpr_Const(IRConst_V128(0x0000)); ++ } else { ++ goto unhandled; ++ } ++ break; ++ } ++ + case Iop_ZeroHI64ofV128: { + /* Could do better here -- only need to look at the bottom 64 bits + of the argument, really. */ +@@ -2129,6 +2140,8 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) + } + + /* -- V128 stuff -- */ ++ case Iop_InterleaveLO64x2: // This, and the HI64, are created ++ case Iop_InterleaveHI64x2: // by the amd64 PTEST translation + case Iop_InterleaveLO8x16: { + /* This turns up a lot in Memcheck instrumentation of + Icc generated code. I don't know why. */ +@@ -2321,6 +2334,27 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) + break; + } + } ++ /* AndV128( x, NotV128( x ) ) ==> 0...0 and ++ AndV256( x, NotV256( x ) ) ==> 0...0 ++ This is generated by amd64 `ptest %xmmReg, %xmmReg` ++ (the same reg both times) ++ See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 */ ++ if (e->Iex.Binop.op == Iop_AndV128 ++ || e->Iex.Binop.op == Iop_AndV256) { ++ Bool isV256 = e->Iex.Binop.op == Iop_AndV256; ++ IRExpr* x1 = chase(env, e->Iex.Binop.arg1); ++ IRExpr* rhs = chase(env, e->Iex.Binop.arg2); ++ if (x1 && rhs ++ && rhs->tag == Iex_Unop ++ && rhs->Iex.Unop.op == (isV256 ? Iop_NotV256 ++ : Iop_NotV128)) { ++ IRExpr* x2 = chase(env, rhs->Iex.Unop.arg); ++ if (x2 && sameIRExprs(env, x1, x2)) { ++ e2 = mkZeroOfPrimopResultType(e->Iex.Binop.op); ++ break; ++ } ++ } ++ } + break; + + case Iop_OrV128: +diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am +index 0d2812dd8..906b8f393 100644 +--- a/memcheck/tests/amd64/Makefile.am ++++ b/memcheck/tests/amd64/Makefile.am +@@ -20,6 +20,10 @@ EXTRA_DIST = \ + insn-pmovmskb.stderr.exp-clang \ + more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \ + pcmpgt.stderr.exp pcmpgt.vgtest \ ++ rh2257546_128.vgtest \ ++ rh2257546_128.stderr.exp rh2257546_128.stdout.exp \ ++ rh2257546_256.vgtest \ ++ rh2257546_256.stderr.exp rh2257546_256.stdout.exp \ + sh-mem-vec128-plo-no.vgtest \ + sh-mem-vec128-plo-no.stderr.exp \ + sh-mem-vec128-plo-no.stdout.exp \ +@@ -46,12 +50,13 @@ check_PROGRAMS = \ + insn-bsfl \ + insn-pmovmskb \ + pcmpgt \ ++ rh2257546_128 \ + sh-mem-vec128 \ + sse_memory \ + xor-undef-amd64 + + if BUILD_AVX_TESTS +- check_PROGRAMS += sh-mem-vec256 xsave-avx ++ check_PROGRAMS += rh2257546_256 sh-mem-vec256 xsave-avx + endif + if HAVE_ASM_CONSTRAINT_P + check_PROGRAMS += insn-pcmpistri +diff --git a/memcheck/tests/amd64/rh2257546_128.c b/memcheck/tests/amd64/rh2257546_128.c +new file mode 100644 +index 000000000..a405aa775 +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_128.c +@@ -0,0 +1,32 @@ ++ ++// This should run on memcheck without reporting an undef-value error. ++// See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 ++ ++#include ++#include ++ ++int main ( void ) ++{ ++ char* c1 = malloc(16); ++ c1[0] = 'x'; c1[1] = 'y'; c1[2] = 'x'; c1[3] = 0; ++ ++ char* c2 = "foobarxyzzyfoobarzyzzy"; // strlen > 16 ++ ++ long long int res; ++ __asm__ __volatile__( ++ "movdqu (%1), %%xmm4" "\n\t" ++ "movdqu (%2), %%xmm5" "\n\t" ++ "pxor %%xmm4, %%xmm5" "\n\t" ++ "ptest %%xmm5, %%xmm5" "\n\t" ++ "je zzz1f" "\n\t" ++ "mov $99, %0" "\n\t" ++ "jmp zzzafter" "\n" ++ "zzz1f:" "\n\t" ++ "mov $88, %0" "\n" ++ "zzzafter:" "\n\t" ++ : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"xmm4","xmm5","cc" ++ ); ++ printf("res = %lld\n", res); ++ free(c1); ++ return 0; ++} +diff --git a/memcheck/tests/amd64/rh2257546_128.stderr.exp b/memcheck/tests/amd64/rh2257546_128.stderr.exp +new file mode 100644 +index 000000000..e69de29bb +diff --git a/memcheck/tests/amd64/rh2257546_128.stdout.exp b/memcheck/tests/amd64/rh2257546_128.stdout.exp +new file mode 100644 +index 000000000..454131089 +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_128.stdout.exp +@@ -0,0 +1 @@ ++res = 99 +diff --git a/memcheck/tests/amd64/rh2257546_128.vgtest b/memcheck/tests/amd64/rh2257546_128.vgtest +new file mode 100644 +index 000000000..94414cd6f +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_128.vgtest +@@ -0,0 +1,2 @@ ++prog: rh2257546_128 ++vgopts: -q +diff --git a/memcheck/tests/amd64/rh2257546_256.c b/memcheck/tests/amd64/rh2257546_256.c +new file mode 100644 +index 000000000..235005ca6 +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_256.c +@@ -0,0 +1,32 @@ ++ ++// This should run on memcheck without reporting an undef-value error. ++// See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 ++ ++#include ++#include ++ ++int main ( void ) ++{ ++ char* c1 = malloc(32); ++ c1[0] = 'x'; c1[1] = 'y'; c1[2] = 'x'; c1[3] = 0; ++ ++ char* c2 = "foobarxyzzyfoobarzyzzyandawholelotmoretoo"; // strlen > 32 ++ ++ long long int res; ++ __asm__ __volatile__( ++ "vmovdqu (%1), %%ymm4" "\n\t" ++ "vmovdqu (%2), %%ymm5" "\n\t" ++ "vpxor %%ymm4, %%ymm5, %%ymm5" "\n\t" ++ "vptest %%ymm5, %%ymm5" "\n\t" ++ "je zzz1f" "\n\t" ++ "mov $99, %0" "\n\t" ++ "jmp zzzafter" "\n" ++ "zzz1f:" "\n\t" ++ "mov $88, %0" "\n" ++ "zzzafter:" "\n\t" ++ : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"ymm4","ymm5","cc" ++ ); ++ printf("res = %lld\n", res); ++ free(c1); ++ return 0; ++} +diff --git a/memcheck/tests/amd64/rh2257546_256.stderr.exp b/memcheck/tests/amd64/rh2257546_256.stderr.exp +new file mode 100644 +index 000000000..e69de29bb +diff --git a/memcheck/tests/amd64/rh2257546_256.stdout.exp b/memcheck/tests/amd64/rh2257546_256.stdout.exp +new file mode 100644 +index 000000000..454131089 +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_256.stdout.exp +@@ -0,0 +1 @@ ++res = 99 +diff --git a/memcheck/tests/amd64/rh2257546_256.vgtest b/memcheck/tests/amd64/rh2257546_256.vgtest +new file mode 100644 +index 000000000..86eef8fe2 +--- /dev/null ++++ b/memcheck/tests/amd64/rh2257546_256.vgtest +@@ -0,0 +1,3 @@ ++prereq: test -e rh2257546_256 ++prog: rh2257546_256 ++vgopts: -q +-- +2.43.0 + diff --git a/valgrind.spec b/valgrind.spec index 7401c3b..54c0a3c 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 6%{?dist} +Release: 7%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -102,6 +102,10 @@ Patch7: valgrind-3.22.0-fchmodat2.patch # https://bugs.kde.org/show_bug.cgi?id=478624 Patch8: valgrind-3.22.0-x86-nop.patch +# Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2 +# https://bugzilla.redhat.com/show_bug.cgi?id=2257546 +Patch9: valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch + BuildRequires: make BuildRequires: glibc-devel @@ -240,6 +244,7 @@ Valgrind User Manual for details. %patch -P6 -p1 %patch -P7 -p1 %patch -P8 -p1 +%patch -P9 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -456,6 +461,9 @@ echo ===============END TESTING=============== %endif %changelog +* Mon Mar 11 2024 Mark Wielaard +- Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch + * Mon Mar 4 2024 Mark Wielaard - Update Fedora license tags to spdx license tags From 1cabfb854f3ba203673a27e673dfc63b6291bbf6 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 16:59:09 +0200 Subject: [PATCH 41/86] Add BuildRequires: python3-devel For running the testsuite. Some of the python scripts require python 3.9+ https://bugzilla.redhat.com/show_bug.cgi?id=2274913 --- valgrind.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index 54c0a3c..3a90a7b 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -144,6 +144,10 @@ BuildRequires: elfutils-debuginfod-client Recommends: elfutils-debuginfod-client %endif +# For running the testsuite. +# Some of the python scripts require python 3.9+ +BuildRequires: python3-devel + %{?scl:Requires:%scl_runtime} # We could use %%valgrind_arches as defined in redhat-rpm-config @@ -461,7 +465,10 @@ echo ===============END TESTING=============== %endif %changelog -* Mon Mar 11 2024 Mark Wielaard +* Sat Apr 13 2024 Mark Wielaard +- Add BuildRequires: python3-devel for running testsuite. + +* Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch * Mon Mar 4 2024 Mark Wielaard From acc33b04c9d1ae81d0ee8a0a336903e0ac7add8a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 17:24:37 +0200 Subject: [PATCH 42/86] Add valgrind-3.22.0-gdb-thread-exited.patch --- valgrind-3.22.0-gdb-thread-exited.patch | 23 +++++++++++++++++++++++ valgrind.spec | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 valgrind-3.22.0-gdb-thread-exited.patch diff --git a/valgrind-3.22.0-gdb-thread-exited.patch b/valgrind-3.22.0-gdb-thread-exited.patch new file mode 100644 index 0000000..4a4d451 --- /dev/null +++ b/valgrind-3.22.0-gdb-thread-exited.patch @@ -0,0 +1,23 @@ +commit 7aa63de01a3cda2a346f90be16bd29fd7b410c63 +Author: Mark Wielaard +Date: Mon Jan 22 14:08:30 2024 +0100 + + gdbserver_tests/filter_gdb.in: delete thread exiting + + The hginfo testcase would fail with GDB 14.1 because it would output + an extra line saying: [Thread .... exited] + +diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in +index 16186dfe2c9b..6c85284b7531 100755 +--- a/gdbserver_tests/filter_gdb.in ++++ b/gdbserver_tests/filter_gdb.in +@@ -65,6 +65,9 @@ s/Thread [0-9][0-9]*/Thread ..../g + # delete thread switches + /\[Switching to Thread ....\]/d + ++# delete thread exiting ++/\[Thread .... exited\]/d ++ + # ??? Probably we had a 'Switching ' message in front of + # a frame line ? + s/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/ diff --git a/valgrind.spec b/valgrind.spec index 3a90a7b..ceb9109 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -106,6 +106,10 @@ Patch8: valgrind-3.22.0-x86-nop.patch # https://bugzilla.redhat.com/show_bug.cgi?id=2257546 Patch9: valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch +# Upstream commit 7aa63de01a3cda2a346f90be16bd29fd7b410c63 +# Testsuite fix gdbserver_tests/filter_gdb.in: delete thread exiting +Patch10: valgrind-3.22.0-gdb-thread-exited.patch + BuildRequires: make BuildRequires: glibc-devel @@ -249,6 +253,7 @@ Valgrind User Manual for details. %patch -P7 -p1 %patch -P8 -p1 %patch -P9 -p1 +%patch -P10 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -467,6 +472,7 @@ echo ===============END TESTING=============== %changelog * Sat Apr 13 2024 Mark Wielaard - Add BuildRequires: python3-devel for running testsuite. +- Add valgrind-3.22.0-gdb-thread-exited.patch * Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch From 554fc90612394901d1bf9456026d65fd47d3e611 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 17:28:25 +0200 Subject: [PATCH 43/86] Add valgrind-3.22.0-set_vma_name-supp.patch --- valgrind-3.22.0-set_vma_name-supp.patch | 24 ++++++++++++++++++++++++ valgrind.spec | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 valgrind-3.22.0-set_vma_name-supp.patch diff --git a/valgrind-3.22.0-set_vma_name-supp.patch b/valgrind-3.22.0-set_vma_name-supp.patch new file mode 100644 index 0000000..42b39a0 --- /dev/null +++ b/valgrind-3.22.0-set_vma_name-supp.patch @@ -0,0 +1,24 @@ +commit 5505e7b371f26f9f9588f4aa3a156dfa6856b90a +Author: Mark Wielaard +Date: Thu Apr 11 19:48:22 2024 +0200 + + Add __set_vma_name suppression to drd/tests/std_thread2.supp + + glibc uses a atomic var to set whether the kernel supports + PR_SET_VMA_ANON_NAME. This looks like a conflicting access to drd. + Suppress it for this testcase. + +diff --git a/drd/tests/std_thread2.supp b/drd/tests/std_thread2.supp +index 4f30560cb924..22052cf2c935 100644 +--- a/drd/tests/std_thread2.supp ++++ b/drd/tests/std_thread2.supp +@@ -44,4 +44,9 @@ + drd:ConflictingAccess + obj:/libexec/ld-elf*.so.1 + } ++{ ++ drd-glibc-set-vma-name ++ drd:ConflictingAccess ++ fun:__set_vma_name ++} + diff --git a/valgrind.spec b/valgrind.spec index ceb9109..91e9ca1 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -110,6 +110,10 @@ Patch9: valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch # Testsuite fix gdbserver_tests/filter_gdb.in: delete thread exiting Patch10: valgrind-3.22.0-gdb-thread-exited.patch +# Upstream commit 5505e7b371f26f9f9588f4aa3a156dfa6856b90a +# Add __set_vma_name suppression to drd/tests/std_thread2.supp +Patch11: valgrind-3.22.0-set_vma_name-supp.patch + BuildRequires: make BuildRequires: glibc-devel @@ -254,6 +258,7 @@ Valgrind User Manual for details. %patch -P8 -p1 %patch -P9 -p1 %patch -P10 -p1 +%patch -P11 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -473,6 +478,7 @@ echo ===============END TESTING=============== * Sat Apr 13 2024 Mark Wielaard - Add BuildRequires: python3-devel for running testsuite. - Add valgrind-3.22.0-gdb-thread-exited.patch +- Add valgrind-3.22.0-set_vma_name-supp.patch * Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch From e2bd2af70cd989b69972c358831362d40d90420c Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 17:32:46 +0200 Subject: [PATCH 44/86] Add valgrind-3.22.0-pth_mempcpy_false_races.patch --- valgrind-3.22.0-pth_mempcpy_false_races.patch | 33 +++++++++++++++++++ valgrind.spec | 6 ++++ 2 files changed, 39 insertions(+) create mode 100644 valgrind-3.22.0-pth_mempcpy_false_races.patch diff --git a/valgrind-3.22.0-pth_mempcpy_false_races.patch b/valgrind-3.22.0-pth_mempcpy_false_races.patch new file mode 100644 index 0000000..d1d426d --- /dev/null +++ b/valgrind-3.22.0-pth_mempcpy_false_races.patch @@ -0,0 +1,33 @@ +commit f47109d30ca319a3bcd4288803e30a473d1506d2 +Author: Mark Wielaard +Date: Fri Apr 12 15:18:51 2024 +0200 + + Add new helgrind race suppression for pth_mempcpy_false_races + + In glibc 2.39+ the internal __printf_buffer_write might use memmove + instead of a memcpy variant. Add an extra suppression variant using + memmove. + + This makes pth_mempcpy_false_races pass again. + + See also https://bugs.kde.org/show_bug.cgi?id=450962 + +diff --git a/glibc-2.X-helgrind.supp.in b/glibc-2.X-helgrind.supp.in +index 2b576b982e42..dce611a09e38 100644 +--- a/glibc-2.X-helgrind.supp.in ++++ b/glibc-2.X-helgrind.supp.in +@@ -63,6 +63,14 @@ + fun:__printf_buffer_write + } + ++{ ++ helgrind-glibc-__printf_buffer_write2 ++ Helgrind:Race ++ fun:*memmove* ++ ... ++ fun:__printf_buffer_write ++} ++ + { + helgrind-glibc2X-005 + Helgrind:Race diff --git a/valgrind.spec b/valgrind.spec index 91e9ca1..c0659c4 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -114,6 +114,10 @@ Patch10: valgrind-3.22.0-gdb-thread-exited.patch # Add __set_vma_name suppression to drd/tests/std_thread2.supp Patch11: valgrind-3.22.0-set_vma_name-supp.patch +# Upstream commit f47109d30ca319a3bcd4288803e30a473d1506d2 +# Add new helgrind race suppression for pth_mempcpy_false_races +Patch12: valgrind-3.22.0-pth_mempcpy_false_races.patch + BuildRequires: make BuildRequires: glibc-devel @@ -259,6 +263,7 @@ Valgrind User Manual for details. %patch -P9 -p1 %patch -P10 -p1 %patch -P11 -p1 +%patch -P12 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -479,6 +484,7 @@ echo ===============END TESTING=============== - Add BuildRequires: python3-devel for running testsuite. - Add valgrind-3.22.0-gdb-thread-exited.patch - Add valgrind-3.22.0-set_vma_name-supp.patch +- Add valgrind-3.22.0-pth_mempcpy_false_races.patch * Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch From 8f2edbfc2a0084c4cc5f675134ef11f84646861f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 20:21:52 +0200 Subject: [PATCH 45/86] Add valgrind-3.22.0-amd64-VFMADD213.patch amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64 https://bugs.kde.org/show_bug.cgi?id=481127 --- valgrind-3.22.0-amd64-VFMADD213.patch | 530 ++++++++++++++++++++++++++ valgrind.spec | 6 + 2 files changed, 536 insertions(+) create mode 100644 valgrind-3.22.0-amd64-VFMADD213.patch diff --git a/valgrind-3.22.0-amd64-VFMADD213.patch b/valgrind-3.22.0-amd64-VFMADD213.patch new file mode 100644 index 0000000..1b58b3d --- /dev/null +++ b/valgrind-3.22.0-amd64-VFMADD213.patch @@ -0,0 +1,530 @@ +commit a5693c1203c3a26443af13182a8082c2e9152f6c +Author: Mark Wielaard +Date: Sat Apr 13 14:33:19 2024 +0200 + + amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64 + + Speed up F32 and F64 FMA on amd64. Add priv/host_amd64_maddf.c + implementing h_amd64_calc_MAddF32_fma4 and h_amd64_calc_MAddF64_fma4 + to be used instead of the generic variants h_generic_calc_MAddF32 + and h_generic_calc_MAddF64 when host has VEX_HWCAPS_AMD64_FMA4. + Add fma3 and fma4 detection m_machine.c (machine_get_hwcaps). + + This patch also fixes the memcheck/tests/vcpu_fnfns and + none/tests/amd64/fma testcases when run on a x86-64-v3 system. + + Patch contributed by Grazvydas Ignotas and + Bruno Lathuilière + + https://bugs.kde.org/show_bug.cgi?id=481127 + https://bugs.kde.org/show_bug.cgi?id=463463 + https://bugs.kde.org/show_bug.cgi?id=463458 + +diff --git a/Makefile.vex.am b/Makefile.vex.am +index 98d84835946b..c1244a69d25c 100644 +--- a/Makefile.vex.am ++++ b/Makefile.vex.am +@@ -54,6 +54,7 @@ noinst_HEADERS = \ + priv/host_generic_simd128.h \ + priv/host_generic_simd256.h \ + priv/host_generic_maddf.h \ ++ priv/host_amd64_maddf.h \ + priv/host_x86_defs.h \ + priv/host_amd64_defs.h \ + priv/host_ppc_defs.h \ +@@ -156,6 +157,7 @@ LIBVEX_SOURCES_COMMON = \ + priv/host_generic_simd128.c \ + priv/host_generic_simd256.c \ + priv/host_generic_maddf.c \ ++ priv/host_amd64_maddf.c \ + priv/host_generic_reg_alloc2.c \ + priv/host_generic_reg_alloc3.c \ + priv/host_x86_defs.c \ +diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c +index 69afab739ce8..253ed65150e5 100644 +--- a/VEX/priv/host_amd64_defs.c ++++ b/VEX/priv/host_amd64_defs.c +@@ -590,6 +590,7 @@ const HChar* showAMD64SseOp ( AMD64SseOp op ) { + case Asse_PMADDUBSW: return "pmaddubsw"; + case Asse_F32toF16: return "vcvtps2ph(rm_field=$0x4)."; + case Asse_F16toF32: return "vcvtph2ps."; ++ case Asse_VFMADD213: return "vfmadd213"; + default: vpanic("showAMD64SseOp"); + } + } +@@ -1056,6 +1057,28 @@ AMD64Instr* AMD64Instr_SseMOVQ ( HReg gpr, HReg xmm, Bool toXMM ) { + //uu i->Ain.AvxReRg.dst = rg; + //uu return i; + //uu } ++AMD64Instr* AMD64Instr_Avx32FLo ( AMD64SseOp op, HReg src1, HReg src2, HReg dst ) { ++ AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); ++ i->tag = Ain_Avx32FLo; ++ i->Ain.Avx32FLo.op = op; ++ i->Ain.Avx32FLo.src1 = src1; ++ i->Ain.Avx32FLo.src2 = src2; ++ i->Ain.Avx32FLo.dst = dst; ++ vassert(op != Asse_MOV); ++ return i; ++} ++ ++AMD64Instr* AMD64Instr_Avx64FLo ( AMD64SseOp op, HReg src1, HReg src2, HReg dst ) { ++ AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); ++ i->tag = Ain_Avx64FLo; ++ i->Ain.Avx64FLo.op = op; ++ i->Ain.Avx64FLo.src1 = src1; ++ i->Ain.Avx64FLo.src2 = src2; ++ i->Ain.Avx64FLo.dst = dst; ++ vassert(op != Asse_MOV); ++ return i; ++} ++ + AMD64Instr* AMD64Instr_EvCheck ( AMD64AMode* amCounter, + AMD64AMode* amFailAddr ) { + AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); +@@ -1434,6 +1457,22 @@ void ppAMD64Instr ( const AMD64Instr* i, Bool mode64 ) + //uu vex_printf(","); + //uu ppHRegAMD64(i->Ain.AvxReRg.dst); + //uu return; ++ case Ain_Avx32FLo: ++ vex_printf("%sss ", showAMD64SseOp(i->Ain.Avx32FLo.op)); ++ ppHRegAMD64(i->Ain.Avx32FLo.src2); ++ vex_printf(","); ++ ppHRegAMD64(i->Ain.Avx32FLo.src1); ++ vex_printf(","); ++ ppHRegAMD64(i->Ain.Avx32FLo.dst); ++ return; ++ case Ain_Avx64FLo: ++ vex_printf("%ssd ", showAMD64SseOp(i->Ain.Avx64FLo.op)); ++ ppHRegAMD64(i->Ain.Avx64FLo.src2); ++ vex_printf(","); ++ ppHRegAMD64(i->Ain.Avx64FLo.src1); ++ vex_printf(","); ++ ppHRegAMD64(i->Ain.Avx64FLo.dst); ++ return; + case Ain_EvCheck: + vex_printf("(evCheck) decl "); + ppAMD64AMode(i->Ain.EvCheck.amCounter); +@@ -1790,6 +1829,18 @@ void getRegUsage_AMD64Instr ( HRegUsage* u, const AMD64Instr* i, Bool mode64 ) + //uu } + //uu } + //uu return; ++ case Ain_Avx32FLo: ++ vassert(i->Ain.Avx32FLo.op != Asse_MOV); ++ addHRegUse(u, HRmRead, i->Ain.Avx32FLo.src1); ++ addHRegUse(u, HRmRead, i->Ain.Avx32FLo.src2); ++ addHRegUse(u, HRmModify, i->Ain.Avx32FLo.dst); ++ return; ++ case Ain_Avx64FLo: ++ vassert(i->Ain.Avx64FLo.op != Asse_MOV); ++ addHRegUse(u, HRmRead, i->Ain.Avx64FLo.src1); ++ addHRegUse(u, HRmRead, i->Ain.Avx64FLo.src2); ++ addHRegUse(u, HRmModify, i->Ain.Avx64FLo.dst); ++ return; + case Ain_EvCheck: + /* We expect both amodes only to mention %rbp, so this is in + fact pointless, since %rbp isn't allocatable, but anyway.. */ +@@ -1999,6 +2050,16 @@ void mapRegs_AMD64Instr ( HRegRemap* m, AMD64Instr* i, Bool mode64 ) + //uu mapReg(m, &i->Ain.AvxReRg.src); + //uu mapReg(m, &i->Ain.AvxReRg.dst); + //uu return; ++ case Ain_Avx32FLo: ++ mapReg(m, &i->Ain.Avx32FLo.src1); ++ mapReg(m, &i->Ain.Avx32FLo.src2); ++ mapReg(m, &i->Ain.Avx32FLo.dst); ++ return; ++ case Ain_Avx64FLo: ++ mapReg(m, &i->Ain.Avx64FLo.src1); ++ mapReg(m, &i->Ain.Avx64FLo.src2); ++ mapReg(m, &i->Ain.Avx64FLo.dst); ++ return; + case Ain_EvCheck: + /* We expect both amodes only to mention %rbp, so this is in + fact pointless, since %rbp isn't allocatable, but anyway.. */ +@@ -4061,6 +4122,53 @@ Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, + //uu goto done; + //uu } + ++ case Ain_Avx32FLo: { ++ UInt d = vregEnc3210(i->Ain.Avx32FLo.dst); ++ UInt v = vregEnc3210(i->Ain.Avx32FLo.src1); ++ UInt s = vregEnc3210(i->Ain.Avx32FLo.src2); ++ UInt m = 2, pp = 1; ++ UInt opcode; ++ switch (i->Ain.Avx32FLo.op) { ++ case Asse_VFMADD213: ++ // VFMADD213SS %xmmS2, %xmmS1, %xmmD (xmm regs range 0 .. 15) ++ opcode = 0xa9; ++ break; ++ default: ++ goto bad; ++ } ++ // 0xC4 : ~d3 1 ~s3 o4 o3 o2 o1 o0 : 0 ~v3 ~v2 ~v1 ~v0 0 p1 p0 : opcode_byte ++ // : 1 1 d2 d1 d0 s2 s1 s0 ++ *p++ = 0xC4; // 3-byte VEX ++ *p++ = ((((~d)>>3)&1)<<7) | (1<<6) | ((((~s)>>3)&1)<<5) | m; ++ *p++ = ((~v&0x0f) << 3) | pp; ++ *p++ = opcode; ++ *p++ = (1<<7) | (1<<6) | ((d&7) << 3) | ((s&7) << 0); ++ goto done; ++ } ++ case Ain_Avx64FLo: { ++ UInt d = vregEnc3210(i->Ain.Avx64FLo.dst); ++ UInt v = vregEnc3210(i->Ain.Avx64FLo.src1); ++ UInt s = vregEnc3210(i->Ain.Avx64FLo.src2); ++ UInt m = 2, pp = 1; ++ UInt opcode; ++ switch (i->Ain.Avx64FLo.op) { ++ case Asse_VFMADD213: ++ // VFMADD213SD %xmmS2, %xmmS1, %xmmD (xmm regs range 0 .. 15) ++ opcode = 0xa9; ++ break; ++ default: ++ goto bad; ++ } ++ // 0xC4 : ~d3 1 ~s3 o4 o3 o2 o1 o0 : 1 ~v3 ~v2 ~v1 ~v0 0 p1 p0 : opcode_byte ++ // : 1 1 d2 d1 d0 s2 s1 s0 ++ *p++ = 0xC4; // 3-byte VEX ++ *p++ = ((((~d)>>3)&1)<<7) | (1<<6) | ((((~s)>>3)&1)<<5) | m; ++ *p++ = (1<<7)|((~v&0x0f) << 3) | pp; ++ *p++ = opcode; ++ *p++ = (1<<7) | (1<<6) | ((d&7) << 3) | ((s&7) << 0); ++ goto done; ++ } ++ + case Ain_EvCheck: { + /* We generate: + (3 bytes) decl 8(%rbp) 8 == offsetof(host_EvC_COUNTER) +diff --git a/VEX/priv/host_amd64_defs.h b/VEX/priv/host_amd64_defs.h +index e2ed2613bf67..eae878e312d7 100644 +--- a/VEX/priv/host_amd64_defs.h ++++ b/VEX/priv/host_amd64_defs.h +@@ -347,6 +347,8 @@ typedef + // Only for F16C capable hosts: + Asse_F32toF16, // F32 to F16 conversion, aka vcvtps2ph + Asse_F16toF32, // F16 to F32 conversion, aka vcvtph2ps ++ // Only for FMA (FMA3) capable hosts: ++ Asse_VFMADD213, // Fused Multiply-Add, aka vfmadd213ss + } + AMD64SseOp; + +@@ -412,6 +414,8 @@ typedef + //uu Ain_AvxLdSt, /* AVX load/store 256 bits, + //uu no alignment constraints */ + //uu Ain_AvxReRg, /* AVX binary general reg-reg, Re, Rg */ ++ Ain_Avx32FLo, /* AVX binary 3 operand, 32F in lowest lane only */ ++ Ain_Avx64FLo, /* AVX binary 3 operand, 64F in lowest lane only */ + Ain_EvCheck, /* Event check */ + Ain_ProfInc /* 64-bit profile counter increment */ + } +@@ -729,6 +733,18 @@ typedef + //uu HReg src; + //uu HReg dst; + //uu } AvxReRg; ++ struct { ++ AMD64SseOp op; ++ HReg src1; ++ HReg src2; ++ HReg dst; ++ } Avx32FLo; ++ struct { ++ AMD64SseOp op; ++ HReg src1; ++ HReg src2; ++ HReg dst; ++ } Avx64FLo; + struct { + AMD64AMode* amCounter; + AMD64AMode* amFailAddr; +@@ -803,6 +819,8 @@ extern AMD64Instr* AMD64Instr_SseShiftN ( AMD64SseOp, + extern AMD64Instr* AMD64Instr_SseMOVQ ( HReg gpr, HReg xmm, Bool toXMM ); + //uu extern AMD64Instr* AMD64Instr_AvxLdSt ( Bool isLoad, HReg, AMD64AMode* ); + //uu extern AMD64Instr* AMD64Instr_AvxReRg ( AMD64SseOp, HReg, HReg ); ++extern AMD64Instr* AMD64Instr_Avx32FLo ( AMD64SseOp, HReg, HReg, HReg ); ++extern AMD64Instr* AMD64Instr_Avx64FLo ( AMD64SseOp, HReg, HReg, HReg ); + extern AMD64Instr* AMD64Instr_EvCheck ( AMD64AMode* amCounter, + AMD64AMode* amFailAddr ); + extern AMD64Instr* AMD64Instr_ProfInc ( void ); +diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c +index e15e1e60fb85..21d20c77f090 100644 +--- a/VEX/priv/host_amd64_isel.c ++++ b/VEX/priv/host_amd64_isel.c +@@ -42,6 +42,7 @@ + #include "host_generic_simd64.h" + #include "host_generic_simd128.h" + #include "host_generic_simd256.h" ++#include "host_amd64_maddf.h" + #include "host_generic_maddf.h" + #include "host_amd64_defs.h" + +@@ -2832,6 +2833,13 @@ static HReg iselFltExpr_wrk ( ISelEnv* env, const IRExpr* e ) + HReg argX = iselFltExpr(env, qop->arg2); + HReg argY = iselFltExpr(env, qop->arg3); + HReg argZ = iselFltExpr(env, qop->arg4); ++ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA3) { ++ vassert(dst.u32 != argY.u32 && dst.u32 != argZ.u32); ++ if (dst.u32 != argX.u32) ++ addInstr(env, AMD64Instr_SseReRg(Asse_MOV, argX, dst)); ++ addInstr(env, AMD64Instr_Avx32FLo(Asse_VFMADD213, argY, argZ, dst)); ++ return dst; ++ } + /* XXXROUNDINGFIXME */ + /* set roundingmode here */ + /* subq $16, %rsp -- make a space*/ +@@ -2861,10 +2869,22 @@ static HReg iselFltExpr_wrk ( ISelEnv* env, const IRExpr* e ) + AMD64AMode_IR(0, hregAMD64_RDX()))); + addInstr(env, AMD64Instr_SseLdSt(False/*!isLoad*/, 4, argZ, + AMD64AMode_IR(0, hregAMD64_RCX()))); +- /* call the helper */ +- addInstr(env, AMD64Instr_Call( Acc_ALWAYS, +- (ULong)(HWord)h_generic_calc_MAddF32, +- 4, mk_RetLoc_simple(RLPri_None) )); ++ ++ /* call the helper with priority order : fma4 -> fallback generic ++ remark: the fma3 case is handled before without helper*/ ++#if defined(VGA_amd64) ++ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA4) { ++ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, ++ (ULong)(HWord)h_amd64_calc_MAddF32_fma4, ++ 4, mk_RetLoc_simple(RLPri_None) )); ++ }else ++#endif ++ { ++ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, ++ (ULong)(HWord)h_generic_calc_MAddF32, ++ 4, mk_RetLoc_simple(RLPri_None) )); ++ } ++ + /* fetch the result from memory, using %r_argp, which the + register allocator will keep alive across the call. */ + addInstr(env, AMD64Instr_SseLdSt(True/*isLoad*/, 4, dst, +@@ -3024,6 +3044,14 @@ static HReg iselDblExpr_wrk ( ISelEnv* env, const IRExpr* e ) + HReg argX = iselDblExpr(env, qop->arg2); + HReg argY = iselDblExpr(env, qop->arg3); + HReg argZ = iselDblExpr(env, qop->arg4); ++ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA3) { ++ vassert(dst.u32 != argY.u32 && dst.u32 != argZ.u32); ++ if (dst.u32 != argX.u32) ++ addInstr(env, AMD64Instr_SseReRg(Asse_MOV, argX, dst)); ++ addInstr(env, AMD64Instr_Avx64FLo(Asse_VFMADD213, argY, argZ, dst)); ++ return dst; ++ } ++ + /* XXXROUNDINGFIXME */ + /* set roundingmode here */ + /* subq $32, %rsp -- make a space*/ +@@ -3053,10 +3081,22 @@ static HReg iselDblExpr_wrk ( ISelEnv* env, const IRExpr* e ) + AMD64AMode_IR(0, hregAMD64_RDX()))); + addInstr(env, AMD64Instr_SseLdSt(False/*!isLoad*/, 8, argZ, + AMD64AMode_IR(0, hregAMD64_RCX()))); +- /* call the helper */ +- addInstr(env, AMD64Instr_Call( Acc_ALWAYS, +- (ULong)(HWord)h_generic_calc_MAddF64, +- 4, mk_RetLoc_simple(RLPri_None) )); ++ ++ /* call the helper with priority order : fma4 -> fallback generic ++ remark: the fma3 case is handled before without helper*/ ++#if defined(VGA_amd64) ++ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA4) { ++ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, ++ (ULong)(HWord)h_amd64_calc_MAddF64_fma4, ++ 4, mk_RetLoc_simple(RLPri_None) )); ++ }else ++#endif ++ { ++ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, ++ (ULong)(HWord)h_generic_calc_MAddF64, ++ 4, mk_RetLoc_simple(RLPri_None) )); ++ } ++ + /* fetch the result from memory, using %r_argp, which the + register allocator will keep alive across the call. */ + addInstr(env, AMD64Instr_SseLdSt(True/*isLoad*/, 8, dst, +@@ -5372,7 +5412,9 @@ HInstrArray* iselSB_AMD64 ( const IRSB* bb, + | VEX_HWCAPS_AMD64_AVX2 + | VEX_HWCAPS_AMD64_F16C + | VEX_HWCAPS_AMD64_RDRAND +- | VEX_HWCAPS_AMD64_RDSEED))); ++ | VEX_HWCAPS_AMD64_RDSEED ++ | VEX_HWCAPS_AMD64_FMA3 ++ | VEX_HWCAPS_AMD64_FMA4))); + + /* Check that the host's endianness is as expected. */ + vassert(archinfo_host->endness == VexEndnessLE); +diff --git a/VEX/priv/host_amd64_maddf.c b/VEX/priv/host_amd64_maddf.c +new file mode 100644 +index 000000000000..579abb4389ac +--- /dev/null ++++ b/VEX/priv/host_amd64_maddf.c +@@ -0,0 +1,35 @@ ++ ++/*---------------------------------------------------------------*/ ++/*--- begin host_amd64_maddf.c ---*/ ++/*---------------------------------------------------------------*/ ++ ++/* ++ Compute x * y + z as ternary operation with intrinsics. ++*/ ++ ++ ++#include "libvex_basictypes.h" ++#include "host_amd64_maddf.h" ++ ++#if defined(VGA_amd64) ++void VEX_REGPARM(3) ++ h_amd64_calc_MAddF32_fma4 ( /*OUT*/Float* res, ++ Float* argX, Float* argY, Float* argZ ) ++{ ++ __asm__ ("vfmaddss %3,%2,%1,%0;" : ++ "=x"(*res): "x"(*argX),"x"(*argY), "x"(*argZ)); ++ return ; ++} ++ ++void VEX_REGPARM(3) ++ h_amd64_calc_MAddF64_fma4 ( /*OUT*/Double* res, ++ Double* argX, Double* argY, Double* argZ ) ++{ ++ __asm__ ("vfmaddsd %3,%2,%1,%0;" : ++ "=x"(*res): "x"(*argX),"x"(*argY), "x"(*argZ)); ++ return; ++} ++#endif ++/*---------------------------------------------------------------*/ ++/*--- end host_amd64_maddf.c --*/ ++/*---------------------------------------------------------------*/ +diff --git a/VEX/priv/host_amd64_maddf.h b/VEX/priv/host_amd64_maddf.h +new file mode 100644 +index 000000000000..b592a44e17d7 +--- /dev/null ++++ b/VEX/priv/host_amd64_maddf.h +@@ -0,0 +1,32 @@ ++ ++/*---------------------------------------------------------------*/ ++/*--- begin host_amd64_maddf.h ---*/ ++/*---------------------------------------------------------------*/ ++ ++/* ++ Compute x * y + z as ternary operation with intrinsics ++*/ ++ ++/* Generic helper functions for doing FMA, i.e. compute x * y + z ++ as ternary operation. ++ These are purely back-end entities and cannot be seen/referenced ++ from IR. */ ++ ++#ifndef __VEX_HOST_AMD64_MADDF_H ++#define __VEX_HOST_AMD64_MADDF_H ++ ++#include "libvex_basictypes.h" ++ ++#if defined(VGA_amd64) ++extern VEX_REGPARM(3) ++ void h_amd64_calc_MAddF32_fma4 ( /*OUT*/Float*, Float*, Float*, Float* ); ++ ++extern VEX_REGPARM(3) ++ void h_amd64_calc_MAddF64_fma4 ( /*OUT*/Double*, Double*, Double*, ++ Double* ); ++#endif ++#endif /* ndef __VEX_HOST_AMD64_MADDF_H */ ++ ++/*---------------------------------------------------------------*/ ++/*--- end host_amd64_maddf.h --*/ ++/*---------------------------------------------------------------*/ +diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c +index 482047c7aa1a..eda2fe6eeecd 100644 +--- a/VEX/priv/main_main.c ++++ b/VEX/priv/main_main.c +@@ -1650,6 +1650,8 @@ static const HChar* show_hwcaps_amd64 ( UInt hwcaps ) + { VEX_HWCAPS_AMD64_F16C, "f16c" }, + { VEX_HWCAPS_AMD64_RDRAND, "rdrand" }, + { VEX_HWCAPS_AMD64_RDSEED, "rdseed" }, ++ { VEX_HWCAPS_AMD64_FMA3, "fma" }, /*fma to keep the same naming as /proc/cpuinfo*/ ++ { VEX_HWCAPS_AMD64_FMA4, "fma4" }, + }; + /* Allocate a large enough buffer */ + static HChar buf[sizeof prefix + +diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h +index 42c013c1ece6..15e2d39deb10 100644 +--- a/VEX/pub/libvex.h ++++ b/VEX/pub/libvex.h +@@ -101,6 +101,8 @@ typedef + #define VEX_HWCAPS_AMD64_RDRAND (1<<13) /* RDRAND instructions */ + #define VEX_HWCAPS_AMD64_F16C (1<<14) /* F16C instructions */ + #define VEX_HWCAPS_AMD64_RDSEED (1<<15) /* RDSEED instructions */ ++#define VEX_HWCAPS_AMD64_FMA3 (1<<16) /* FMA3 instructions */ ++#define VEX_HWCAPS_AMD64_FMA4 (1<<17) /* FMA4 instructions */ + + /* ppc32: baseline capability is integer only */ + #define VEX_HWCAPS_PPC32_F (1<<8) /* basic (non-optional) FP */ +diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c +index 079383651226..81fb810643cf 100644 +--- a/coregrind/m_machine.c ++++ b/coregrind/m_machine.c +@@ -984,6 +984,7 @@ Bool VG_(machine_get_hwcaps)( void ) + #elif defined(VGA_amd64) + { Bool have_sse3, have_ssse3, have_cx8, have_cx16; + Bool have_lzcnt, have_avx, have_bmi, have_avx2; ++ Bool have_fma3, have_fma4; + Bool have_rdtscp, have_rdrand, have_f16c, have_rdseed; + UInt eax, ebx, ecx, edx, max_basic, max_extended; + ULong xgetbv_0 = 0; +@@ -992,7 +993,8 @@ Bool VG_(machine_get_hwcaps)( void ) + + have_sse3 = have_ssse3 = have_cx8 = have_cx16 + = have_lzcnt = have_avx = have_bmi = have_avx2 +- = have_rdtscp = have_rdrand = have_f16c = have_rdseed = False; ++ = have_rdtscp = have_rdrand = have_f16c = have_rdseed ++ = have_fma3 = have_fma4 = False; + + eax = ebx = ecx = edx = max_basic = max_extended = 0; + +@@ -1022,7 +1024,7 @@ Bool VG_(machine_get_hwcaps)( void ) + // we assume that SSE1 and SSE2 are available by default + have_sse3 = (ecx & (1<<0)) != 0; /* True => have sse3 insns */ + have_ssse3 = (ecx & (1<<9)) != 0; /* True => have Sup SSE3 insns */ +- // fma is ecx:12 ++ have_fma3 = (ecx & (1<<12))!= 0; /* True => have fma3 insns */ + // sse41 is ecx:19 + // sse42 is ecx:20 + // xsave is ecx:26 +@@ -1032,7 +1034,7 @@ Bool VG_(machine_get_hwcaps)( void ) + have_rdrand = (ecx & (1<<30)) != 0; /* True => have RDRAND insns */ + + have_avx = False; +- /* have_fma = False; */ ++ + if ( (ecx & ((1<<28)|(1<<27)|(1<<26))) == ((1<<28)|(1<<27)|(1<<26)) ) { + /* Processor supports AVX instructions and XGETBV is enabled + by OS and AVX instructions are enabled by the OS. */ +@@ -1059,9 +1061,6 @@ Bool VG_(machine_get_hwcaps)( void ) + if (ebx2 == 576 && eax2 == 256) { + have_avx = True; + } +- /* have_fma = (ecx & (1<<12)) != 0; */ +- /* have_fma: Probably correct, but gcc complains due to +- unusedness. */ + } + } + +@@ -1089,6 +1088,11 @@ Bool VG_(machine_get_hwcaps)( void ) + have_rdtscp = (edx & (1<<27)) != 0; /* True => have RDTSVCP */ + } + ++ if (max_extended >= 0x80000001) { ++ VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx); ++ have_fma4= (ecx & (1<<16)) != 0; /* True => have fma4 */ ++ } ++ + /* Check for BMI1 and AVX2. If we have AVX1 (plus OS support). */ + have_bmi = False; + have_avx2 = False; +@@ -1120,7 +1124,9 @@ Bool VG_(machine_get_hwcaps)( void ) + | (have_rdtscp ? VEX_HWCAPS_AMD64_RDTSCP : 0) + | (have_f16c ? VEX_HWCAPS_AMD64_F16C : 0) + | (have_rdrand ? VEX_HWCAPS_AMD64_RDRAND : 0) +- | (have_rdseed ? VEX_HWCAPS_AMD64_RDSEED : 0); ++ | (have_rdseed ? VEX_HWCAPS_AMD64_RDSEED : 0) ++ | (have_fma3 ? VEX_HWCAPS_AMD64_FMA3 : 0) ++ | (have_fma4 ? VEX_HWCAPS_AMD64_FMA4 : 0); + + VG_(machine_get_cache_info)(&vai); + diff --git a/valgrind.spec b/valgrind.spec index c0659c4..1f7d7a7 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -118,6 +118,10 @@ Patch11: valgrind-3.22.0-set_vma_name-supp.patch # Add new helgrind race suppression for pth_mempcpy_false_races Patch12: valgrind-3.22.0-pth_mempcpy_false_races.patch +# amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64 +# https://bugs.kde.org/show_bug.cgi?id=481127 +Patch13: valgrind-3.22.0-amd64-VFMADD213.patch + BuildRequires: make BuildRequires: glibc-devel @@ -264,6 +268,7 @@ Valgrind User Manual for details. %patch -P10 -p1 %patch -P11 -p1 %patch -P12 -p1 +%patch -P13 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -485,6 +490,7 @@ echo ===============END TESTING=============== - Add valgrind-3.22.0-gdb-thread-exited.patch - Add valgrind-3.22.0-set_vma_name-supp.patch - Add valgrind-3.22.0-pth_mempcpy_false_races.patch +- Add valgrind-3.22.0-amd64-VFMADD213.patch * Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch From fbb97f2a3f7291529db11c5326bb98e130f95da1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Apr 2024 20:25:56 +0200 Subject: [PATCH 46/86] 3.22.0-8 - Add valgrind-3.22.0-amd64-redir-strcmp.patch glibc built with -march=x86-64-v3 does not work due to ld.so strcmp https://bugs.kde.org/show_bug.cgi?id=485487 --- valgrind-3.22.0-amd64-redir-strcmp.patch | 66 ++++++++++++++++++++++++ valgrind.spec | 10 +++- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.22.0-amd64-redir-strcmp.patch diff --git a/valgrind-3.22.0-amd64-redir-strcmp.patch b/valgrind-3.22.0-amd64-redir-strcmp.patch new file mode 100644 index 0000000..6e37ba1 --- /dev/null +++ b/valgrind-3.22.0-amd64-redir-strcmp.patch @@ -0,0 +1,66 @@ +diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c +index cef241b4f85aad23..ce6073a62190a639 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 da96972323824bdb..716afb2121b84b57 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 54c575a7233a9451..c11060139e576616 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 UInt VG_(amd64_linux_REDIR_FOR_strcmp)( void*, void* ); + extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int ); + #endif + diff --git a/valgrind.spec b/valgrind.spec index 1f7d7a7..766d77f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.22.0 -Release: 7%{?dist} +Release: 8%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -122,6 +122,10 @@ Patch12: valgrind-3.22.0-pth_mempcpy_false_races.patch # https://bugs.kde.org/show_bug.cgi?id=481127 Patch13: valgrind-3.22.0-amd64-VFMADD213.patch +# glibc built with -march=x86-64-v3 does not work due to ld.so strcmp +# https://bugs.kde.org/show_bug.cgi?id=485487 +Patch14: valgrind-3.22.0-amd64-redir-strcmp.patch + BuildRequires: make BuildRequires: glibc-devel @@ -269,6 +273,7 @@ Valgrind User Manual for details. %patch -P11 -p1 %patch -P12 -p1 %patch -P13 -p1 +%patch -P14 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -485,12 +490,13 @@ echo ===============END TESTING=============== %endif %changelog -* Sat Apr 13 2024 Mark Wielaard +* Sat Apr 13 2024 Mark Wielaard - 3.22.0-8 - Add BuildRequires: python3-devel for running testsuite. - Add valgrind-3.22.0-gdb-thread-exited.patch - Add valgrind-3.22.0-set_vma_name-supp.patch - Add valgrind-3.22.0-pth_mempcpy_false_races.patch - Add valgrind-3.22.0-amd64-VFMADD213.patch +- Add valgrind-3.22.0-amd64-redir-strcmp.patch * Mon Mar 11 2024 Mark Wielaard - 3.22.0-7 - Add valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch From 1b1cdf661126b581e948de3a0c2051b654f51543 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 20 Apr 2024 20:14:33 +0200 Subject: [PATCH 47/86] 3.23.0-0.1.RC1 - Upstream 3.23.0-RC1 - Remove all upstreamed patches --- .gitignore | 1 + sources | 2 +- valgrind-3.22.0-amd64-VFMADD213.patch | 530 ------------------ valgrind-3.22.0-amd64-redir-strcmp.patch | 66 --- valgrind-3.22.0-fchmodat2.patch | 206 ------- ...cc-builtin_strcmp-128-256-bit-vector.patch | 355 ------------ valgrind-3.22.0-gdb-thread-exited.patch | 23 - valgrind-3.22.0-pth_mempcpy_false_races.patch | 33 -- valgrind-3.22.0-rodata.patch | 122 ---- valgrind-3.22.0-set_vma_name-supp.patch | 24 - ...nd-3.22.0-valgrind-monitor-python-re.patch | 32 -- valgrind-3.22.0-x86-nop.patch | 136 ----- valgrind.spec | 63 +-- 13 files changed, 10 insertions(+), 1583 deletions(-) delete mode 100644 valgrind-3.22.0-amd64-VFMADD213.patch delete mode 100644 valgrind-3.22.0-amd64-redir-strcmp.patch delete mode 100644 valgrind-3.22.0-fchmodat2.patch delete mode 100644 valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch delete mode 100644 valgrind-3.22.0-gdb-thread-exited.patch delete mode 100644 valgrind-3.22.0-pth_mempcpy_false_races.patch delete mode 100644 valgrind-3.22.0-rodata.patch delete mode 100644 valgrind-3.22.0-set_vma_name-supp.patch delete mode 100644 valgrind-3.22.0-valgrind-monitor-python-re.patch delete mode 100644 valgrind-3.22.0-x86-nop.patch diff --git a/.gitignore b/.gitignore index 4ddb7e4..27bdf5b 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ /valgrind-3.22.0.RC1.tar.bz2 /valgrind-3.22.0.RC2.tar.bz2 /valgrind-3.22.0.tar.bz2 +/valgrind-3.23.0.RC1.tar.bz2 diff --git a/sources b/sources index 9965f6f..b1c83bf 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.22.0.tar.bz2) = 2904c13f68245bbafcea70998c6bd20725271300a7e94b6751ca00916943595fc3fac8557da7ea8db31b54a43f092823a0a947bc142829da811d074e1fe49777 +SHA512 (valgrind-3.23.0.RC1.tar.bz2) = 6d9b95ce919ffa1993265c2972b407beb2879b87f84efd61ada4e75f334b332917a726b053c5dbc64b970a55334189c48ccae9231934c9474b65eb6ec1e2c18f diff --git a/valgrind-3.22.0-amd64-VFMADD213.patch b/valgrind-3.22.0-amd64-VFMADD213.patch deleted file mode 100644 index 1b58b3d..0000000 --- a/valgrind-3.22.0-amd64-VFMADD213.patch +++ /dev/null @@ -1,530 +0,0 @@ -commit a5693c1203c3a26443af13182a8082c2e9152f6c -Author: Mark Wielaard -Date: Sat Apr 13 14:33:19 2024 +0200 - - amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64 - - Speed up F32 and F64 FMA on amd64. Add priv/host_amd64_maddf.c - implementing h_amd64_calc_MAddF32_fma4 and h_amd64_calc_MAddF64_fma4 - to be used instead of the generic variants h_generic_calc_MAddF32 - and h_generic_calc_MAddF64 when host has VEX_HWCAPS_AMD64_FMA4. - Add fma3 and fma4 detection m_machine.c (machine_get_hwcaps). - - This patch also fixes the memcheck/tests/vcpu_fnfns and - none/tests/amd64/fma testcases when run on a x86-64-v3 system. - - Patch contributed by Grazvydas Ignotas and - Bruno Lathuilière - - https://bugs.kde.org/show_bug.cgi?id=481127 - https://bugs.kde.org/show_bug.cgi?id=463463 - https://bugs.kde.org/show_bug.cgi?id=463458 - -diff --git a/Makefile.vex.am b/Makefile.vex.am -index 98d84835946b..c1244a69d25c 100644 ---- a/Makefile.vex.am -+++ b/Makefile.vex.am -@@ -54,6 +54,7 @@ noinst_HEADERS = \ - priv/host_generic_simd128.h \ - priv/host_generic_simd256.h \ - priv/host_generic_maddf.h \ -+ priv/host_amd64_maddf.h \ - priv/host_x86_defs.h \ - priv/host_amd64_defs.h \ - priv/host_ppc_defs.h \ -@@ -156,6 +157,7 @@ LIBVEX_SOURCES_COMMON = \ - priv/host_generic_simd128.c \ - priv/host_generic_simd256.c \ - priv/host_generic_maddf.c \ -+ priv/host_amd64_maddf.c \ - priv/host_generic_reg_alloc2.c \ - priv/host_generic_reg_alloc3.c \ - priv/host_x86_defs.c \ -diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c -index 69afab739ce8..253ed65150e5 100644 ---- a/VEX/priv/host_amd64_defs.c -+++ b/VEX/priv/host_amd64_defs.c -@@ -590,6 +590,7 @@ const HChar* showAMD64SseOp ( AMD64SseOp op ) { - case Asse_PMADDUBSW: return "pmaddubsw"; - case Asse_F32toF16: return "vcvtps2ph(rm_field=$0x4)."; - case Asse_F16toF32: return "vcvtph2ps."; -+ case Asse_VFMADD213: return "vfmadd213"; - default: vpanic("showAMD64SseOp"); - } - } -@@ -1056,6 +1057,28 @@ AMD64Instr* AMD64Instr_SseMOVQ ( HReg gpr, HReg xmm, Bool toXMM ) { - //uu i->Ain.AvxReRg.dst = rg; - //uu return i; - //uu } -+AMD64Instr* AMD64Instr_Avx32FLo ( AMD64SseOp op, HReg src1, HReg src2, HReg dst ) { -+ AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); -+ i->tag = Ain_Avx32FLo; -+ i->Ain.Avx32FLo.op = op; -+ i->Ain.Avx32FLo.src1 = src1; -+ i->Ain.Avx32FLo.src2 = src2; -+ i->Ain.Avx32FLo.dst = dst; -+ vassert(op != Asse_MOV); -+ return i; -+} -+ -+AMD64Instr* AMD64Instr_Avx64FLo ( AMD64SseOp op, HReg src1, HReg src2, HReg dst ) { -+ AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); -+ i->tag = Ain_Avx64FLo; -+ i->Ain.Avx64FLo.op = op; -+ i->Ain.Avx64FLo.src1 = src1; -+ i->Ain.Avx64FLo.src2 = src2; -+ i->Ain.Avx64FLo.dst = dst; -+ vassert(op != Asse_MOV); -+ return i; -+} -+ - AMD64Instr* AMD64Instr_EvCheck ( AMD64AMode* amCounter, - AMD64AMode* amFailAddr ) { - AMD64Instr* i = LibVEX_Alloc_inline(sizeof(AMD64Instr)); -@@ -1434,6 +1457,22 @@ void ppAMD64Instr ( const AMD64Instr* i, Bool mode64 ) - //uu vex_printf(","); - //uu ppHRegAMD64(i->Ain.AvxReRg.dst); - //uu return; -+ case Ain_Avx32FLo: -+ vex_printf("%sss ", showAMD64SseOp(i->Ain.Avx32FLo.op)); -+ ppHRegAMD64(i->Ain.Avx32FLo.src2); -+ vex_printf(","); -+ ppHRegAMD64(i->Ain.Avx32FLo.src1); -+ vex_printf(","); -+ ppHRegAMD64(i->Ain.Avx32FLo.dst); -+ return; -+ case Ain_Avx64FLo: -+ vex_printf("%ssd ", showAMD64SseOp(i->Ain.Avx64FLo.op)); -+ ppHRegAMD64(i->Ain.Avx64FLo.src2); -+ vex_printf(","); -+ ppHRegAMD64(i->Ain.Avx64FLo.src1); -+ vex_printf(","); -+ ppHRegAMD64(i->Ain.Avx64FLo.dst); -+ return; - case Ain_EvCheck: - vex_printf("(evCheck) decl "); - ppAMD64AMode(i->Ain.EvCheck.amCounter); -@@ -1790,6 +1829,18 @@ void getRegUsage_AMD64Instr ( HRegUsage* u, const AMD64Instr* i, Bool mode64 ) - //uu } - //uu } - //uu return; -+ case Ain_Avx32FLo: -+ vassert(i->Ain.Avx32FLo.op != Asse_MOV); -+ addHRegUse(u, HRmRead, i->Ain.Avx32FLo.src1); -+ addHRegUse(u, HRmRead, i->Ain.Avx32FLo.src2); -+ addHRegUse(u, HRmModify, i->Ain.Avx32FLo.dst); -+ return; -+ case Ain_Avx64FLo: -+ vassert(i->Ain.Avx64FLo.op != Asse_MOV); -+ addHRegUse(u, HRmRead, i->Ain.Avx64FLo.src1); -+ addHRegUse(u, HRmRead, i->Ain.Avx64FLo.src2); -+ addHRegUse(u, HRmModify, i->Ain.Avx64FLo.dst); -+ return; - case Ain_EvCheck: - /* We expect both amodes only to mention %rbp, so this is in - fact pointless, since %rbp isn't allocatable, but anyway.. */ -@@ -1999,6 +2050,16 @@ void mapRegs_AMD64Instr ( HRegRemap* m, AMD64Instr* i, Bool mode64 ) - //uu mapReg(m, &i->Ain.AvxReRg.src); - //uu mapReg(m, &i->Ain.AvxReRg.dst); - //uu return; -+ case Ain_Avx32FLo: -+ mapReg(m, &i->Ain.Avx32FLo.src1); -+ mapReg(m, &i->Ain.Avx32FLo.src2); -+ mapReg(m, &i->Ain.Avx32FLo.dst); -+ return; -+ case Ain_Avx64FLo: -+ mapReg(m, &i->Ain.Avx64FLo.src1); -+ mapReg(m, &i->Ain.Avx64FLo.src2); -+ mapReg(m, &i->Ain.Avx64FLo.dst); -+ return; - case Ain_EvCheck: - /* We expect both amodes only to mention %rbp, so this is in - fact pointless, since %rbp isn't allocatable, but anyway.. */ -@@ -4061,6 +4122,53 @@ Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, - //uu goto done; - //uu } - -+ case Ain_Avx32FLo: { -+ UInt d = vregEnc3210(i->Ain.Avx32FLo.dst); -+ UInt v = vregEnc3210(i->Ain.Avx32FLo.src1); -+ UInt s = vregEnc3210(i->Ain.Avx32FLo.src2); -+ UInt m = 2, pp = 1; -+ UInt opcode; -+ switch (i->Ain.Avx32FLo.op) { -+ case Asse_VFMADD213: -+ // VFMADD213SS %xmmS2, %xmmS1, %xmmD (xmm regs range 0 .. 15) -+ opcode = 0xa9; -+ break; -+ default: -+ goto bad; -+ } -+ // 0xC4 : ~d3 1 ~s3 o4 o3 o2 o1 o0 : 0 ~v3 ~v2 ~v1 ~v0 0 p1 p0 : opcode_byte -+ // : 1 1 d2 d1 d0 s2 s1 s0 -+ *p++ = 0xC4; // 3-byte VEX -+ *p++ = ((((~d)>>3)&1)<<7) | (1<<6) | ((((~s)>>3)&1)<<5) | m; -+ *p++ = ((~v&0x0f) << 3) | pp; -+ *p++ = opcode; -+ *p++ = (1<<7) | (1<<6) | ((d&7) << 3) | ((s&7) << 0); -+ goto done; -+ } -+ case Ain_Avx64FLo: { -+ UInt d = vregEnc3210(i->Ain.Avx64FLo.dst); -+ UInt v = vregEnc3210(i->Ain.Avx64FLo.src1); -+ UInt s = vregEnc3210(i->Ain.Avx64FLo.src2); -+ UInt m = 2, pp = 1; -+ UInt opcode; -+ switch (i->Ain.Avx64FLo.op) { -+ case Asse_VFMADD213: -+ // VFMADD213SD %xmmS2, %xmmS1, %xmmD (xmm regs range 0 .. 15) -+ opcode = 0xa9; -+ break; -+ default: -+ goto bad; -+ } -+ // 0xC4 : ~d3 1 ~s3 o4 o3 o2 o1 o0 : 1 ~v3 ~v2 ~v1 ~v0 0 p1 p0 : opcode_byte -+ // : 1 1 d2 d1 d0 s2 s1 s0 -+ *p++ = 0xC4; // 3-byte VEX -+ *p++ = ((((~d)>>3)&1)<<7) | (1<<6) | ((((~s)>>3)&1)<<5) | m; -+ *p++ = (1<<7)|((~v&0x0f) << 3) | pp; -+ *p++ = opcode; -+ *p++ = (1<<7) | (1<<6) | ((d&7) << 3) | ((s&7) << 0); -+ goto done; -+ } -+ - case Ain_EvCheck: { - /* We generate: - (3 bytes) decl 8(%rbp) 8 == offsetof(host_EvC_COUNTER) -diff --git a/VEX/priv/host_amd64_defs.h b/VEX/priv/host_amd64_defs.h -index e2ed2613bf67..eae878e312d7 100644 ---- a/VEX/priv/host_amd64_defs.h -+++ b/VEX/priv/host_amd64_defs.h -@@ -347,6 +347,8 @@ typedef - // Only for F16C capable hosts: - Asse_F32toF16, // F32 to F16 conversion, aka vcvtps2ph - Asse_F16toF32, // F16 to F32 conversion, aka vcvtph2ps -+ // Only for FMA (FMA3) capable hosts: -+ Asse_VFMADD213, // Fused Multiply-Add, aka vfmadd213ss - } - AMD64SseOp; - -@@ -412,6 +414,8 @@ typedef - //uu Ain_AvxLdSt, /* AVX load/store 256 bits, - //uu no alignment constraints */ - //uu Ain_AvxReRg, /* AVX binary general reg-reg, Re, Rg */ -+ Ain_Avx32FLo, /* AVX binary 3 operand, 32F in lowest lane only */ -+ Ain_Avx64FLo, /* AVX binary 3 operand, 64F in lowest lane only */ - Ain_EvCheck, /* Event check */ - Ain_ProfInc /* 64-bit profile counter increment */ - } -@@ -729,6 +733,18 @@ typedef - //uu HReg src; - //uu HReg dst; - //uu } AvxReRg; -+ struct { -+ AMD64SseOp op; -+ HReg src1; -+ HReg src2; -+ HReg dst; -+ } Avx32FLo; -+ struct { -+ AMD64SseOp op; -+ HReg src1; -+ HReg src2; -+ HReg dst; -+ } Avx64FLo; - struct { - AMD64AMode* amCounter; - AMD64AMode* amFailAddr; -@@ -803,6 +819,8 @@ extern AMD64Instr* AMD64Instr_SseShiftN ( AMD64SseOp, - extern AMD64Instr* AMD64Instr_SseMOVQ ( HReg gpr, HReg xmm, Bool toXMM ); - //uu extern AMD64Instr* AMD64Instr_AvxLdSt ( Bool isLoad, HReg, AMD64AMode* ); - //uu extern AMD64Instr* AMD64Instr_AvxReRg ( AMD64SseOp, HReg, HReg ); -+extern AMD64Instr* AMD64Instr_Avx32FLo ( AMD64SseOp, HReg, HReg, HReg ); -+extern AMD64Instr* AMD64Instr_Avx64FLo ( AMD64SseOp, HReg, HReg, HReg ); - extern AMD64Instr* AMD64Instr_EvCheck ( AMD64AMode* amCounter, - AMD64AMode* amFailAddr ); - extern AMD64Instr* AMD64Instr_ProfInc ( void ); -diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c -index e15e1e60fb85..21d20c77f090 100644 ---- a/VEX/priv/host_amd64_isel.c -+++ b/VEX/priv/host_amd64_isel.c -@@ -42,6 +42,7 @@ - #include "host_generic_simd64.h" - #include "host_generic_simd128.h" - #include "host_generic_simd256.h" -+#include "host_amd64_maddf.h" - #include "host_generic_maddf.h" - #include "host_amd64_defs.h" - -@@ -2832,6 +2833,13 @@ static HReg iselFltExpr_wrk ( ISelEnv* env, const IRExpr* e ) - HReg argX = iselFltExpr(env, qop->arg2); - HReg argY = iselFltExpr(env, qop->arg3); - HReg argZ = iselFltExpr(env, qop->arg4); -+ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA3) { -+ vassert(dst.u32 != argY.u32 && dst.u32 != argZ.u32); -+ if (dst.u32 != argX.u32) -+ addInstr(env, AMD64Instr_SseReRg(Asse_MOV, argX, dst)); -+ addInstr(env, AMD64Instr_Avx32FLo(Asse_VFMADD213, argY, argZ, dst)); -+ return dst; -+ } - /* XXXROUNDINGFIXME */ - /* set roundingmode here */ - /* subq $16, %rsp -- make a space*/ -@@ -2861,10 +2869,22 @@ static HReg iselFltExpr_wrk ( ISelEnv* env, const IRExpr* e ) - AMD64AMode_IR(0, hregAMD64_RDX()))); - addInstr(env, AMD64Instr_SseLdSt(False/*!isLoad*/, 4, argZ, - AMD64AMode_IR(0, hregAMD64_RCX()))); -- /* call the helper */ -- addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -- (ULong)(HWord)h_generic_calc_MAddF32, -- 4, mk_RetLoc_simple(RLPri_None) )); -+ -+ /* call the helper with priority order : fma4 -> fallback generic -+ remark: the fma3 case is handled before without helper*/ -+#if defined(VGA_amd64) -+ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA4) { -+ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -+ (ULong)(HWord)h_amd64_calc_MAddF32_fma4, -+ 4, mk_RetLoc_simple(RLPri_None) )); -+ }else -+#endif -+ { -+ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -+ (ULong)(HWord)h_generic_calc_MAddF32, -+ 4, mk_RetLoc_simple(RLPri_None) )); -+ } -+ - /* fetch the result from memory, using %r_argp, which the - register allocator will keep alive across the call. */ - addInstr(env, AMD64Instr_SseLdSt(True/*isLoad*/, 4, dst, -@@ -3024,6 +3044,14 @@ static HReg iselDblExpr_wrk ( ISelEnv* env, const IRExpr* e ) - HReg argX = iselDblExpr(env, qop->arg2); - HReg argY = iselDblExpr(env, qop->arg3); - HReg argZ = iselDblExpr(env, qop->arg4); -+ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA3) { -+ vassert(dst.u32 != argY.u32 && dst.u32 != argZ.u32); -+ if (dst.u32 != argX.u32) -+ addInstr(env, AMD64Instr_SseReRg(Asse_MOV, argX, dst)); -+ addInstr(env, AMD64Instr_Avx64FLo(Asse_VFMADD213, argY, argZ, dst)); -+ return dst; -+ } -+ - /* XXXROUNDINGFIXME */ - /* set roundingmode here */ - /* subq $32, %rsp -- make a space*/ -@@ -3053,10 +3081,22 @@ static HReg iselDblExpr_wrk ( ISelEnv* env, const IRExpr* e ) - AMD64AMode_IR(0, hregAMD64_RDX()))); - addInstr(env, AMD64Instr_SseLdSt(False/*!isLoad*/, 8, argZ, - AMD64AMode_IR(0, hregAMD64_RCX()))); -- /* call the helper */ -- addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -- (ULong)(HWord)h_generic_calc_MAddF64, -- 4, mk_RetLoc_simple(RLPri_None) )); -+ -+ /* call the helper with priority order : fma4 -> fallback generic -+ remark: the fma3 case is handled before without helper*/ -+#if defined(VGA_amd64) -+ if (env->hwcaps & VEX_HWCAPS_AMD64_FMA4) { -+ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -+ (ULong)(HWord)h_amd64_calc_MAddF64_fma4, -+ 4, mk_RetLoc_simple(RLPri_None) )); -+ }else -+#endif -+ { -+ addInstr(env, AMD64Instr_Call( Acc_ALWAYS, -+ (ULong)(HWord)h_generic_calc_MAddF64, -+ 4, mk_RetLoc_simple(RLPri_None) )); -+ } -+ - /* fetch the result from memory, using %r_argp, which the - register allocator will keep alive across the call. */ - addInstr(env, AMD64Instr_SseLdSt(True/*isLoad*/, 8, dst, -@@ -5372,7 +5412,9 @@ HInstrArray* iselSB_AMD64 ( const IRSB* bb, - | VEX_HWCAPS_AMD64_AVX2 - | VEX_HWCAPS_AMD64_F16C - | VEX_HWCAPS_AMD64_RDRAND -- | VEX_HWCAPS_AMD64_RDSEED))); -+ | VEX_HWCAPS_AMD64_RDSEED -+ | VEX_HWCAPS_AMD64_FMA3 -+ | VEX_HWCAPS_AMD64_FMA4))); - - /* Check that the host's endianness is as expected. */ - vassert(archinfo_host->endness == VexEndnessLE); -diff --git a/VEX/priv/host_amd64_maddf.c b/VEX/priv/host_amd64_maddf.c -new file mode 100644 -index 000000000000..579abb4389ac ---- /dev/null -+++ b/VEX/priv/host_amd64_maddf.c -@@ -0,0 +1,35 @@ -+ -+/*---------------------------------------------------------------*/ -+/*--- begin host_amd64_maddf.c ---*/ -+/*---------------------------------------------------------------*/ -+ -+/* -+ Compute x * y + z as ternary operation with intrinsics. -+*/ -+ -+ -+#include "libvex_basictypes.h" -+#include "host_amd64_maddf.h" -+ -+#if defined(VGA_amd64) -+void VEX_REGPARM(3) -+ h_amd64_calc_MAddF32_fma4 ( /*OUT*/Float* res, -+ Float* argX, Float* argY, Float* argZ ) -+{ -+ __asm__ ("vfmaddss %3,%2,%1,%0;" : -+ "=x"(*res): "x"(*argX),"x"(*argY), "x"(*argZ)); -+ return ; -+} -+ -+void VEX_REGPARM(3) -+ h_amd64_calc_MAddF64_fma4 ( /*OUT*/Double* res, -+ Double* argX, Double* argY, Double* argZ ) -+{ -+ __asm__ ("vfmaddsd %3,%2,%1,%0;" : -+ "=x"(*res): "x"(*argX),"x"(*argY), "x"(*argZ)); -+ return; -+} -+#endif -+/*---------------------------------------------------------------*/ -+/*--- end host_amd64_maddf.c --*/ -+/*---------------------------------------------------------------*/ -diff --git a/VEX/priv/host_amd64_maddf.h b/VEX/priv/host_amd64_maddf.h -new file mode 100644 -index 000000000000..b592a44e17d7 ---- /dev/null -+++ b/VEX/priv/host_amd64_maddf.h -@@ -0,0 +1,32 @@ -+ -+/*---------------------------------------------------------------*/ -+/*--- begin host_amd64_maddf.h ---*/ -+/*---------------------------------------------------------------*/ -+ -+/* -+ Compute x * y + z as ternary operation with intrinsics -+*/ -+ -+/* Generic helper functions for doing FMA, i.e. compute x * y + z -+ as ternary operation. -+ These are purely back-end entities and cannot be seen/referenced -+ from IR. */ -+ -+#ifndef __VEX_HOST_AMD64_MADDF_H -+#define __VEX_HOST_AMD64_MADDF_H -+ -+#include "libvex_basictypes.h" -+ -+#if defined(VGA_amd64) -+extern VEX_REGPARM(3) -+ void h_amd64_calc_MAddF32_fma4 ( /*OUT*/Float*, Float*, Float*, Float* ); -+ -+extern VEX_REGPARM(3) -+ void h_amd64_calc_MAddF64_fma4 ( /*OUT*/Double*, Double*, Double*, -+ Double* ); -+#endif -+#endif /* ndef __VEX_HOST_AMD64_MADDF_H */ -+ -+/*---------------------------------------------------------------*/ -+/*--- end host_amd64_maddf.h --*/ -+/*---------------------------------------------------------------*/ -diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c -index 482047c7aa1a..eda2fe6eeecd 100644 ---- a/VEX/priv/main_main.c -+++ b/VEX/priv/main_main.c -@@ -1650,6 +1650,8 @@ static const HChar* show_hwcaps_amd64 ( UInt hwcaps ) - { VEX_HWCAPS_AMD64_F16C, "f16c" }, - { VEX_HWCAPS_AMD64_RDRAND, "rdrand" }, - { VEX_HWCAPS_AMD64_RDSEED, "rdseed" }, -+ { VEX_HWCAPS_AMD64_FMA3, "fma" }, /*fma to keep the same naming as /proc/cpuinfo*/ -+ { VEX_HWCAPS_AMD64_FMA4, "fma4" }, - }; - /* Allocate a large enough buffer */ - static HChar buf[sizeof prefix + -diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h -index 42c013c1ece6..15e2d39deb10 100644 ---- a/VEX/pub/libvex.h -+++ b/VEX/pub/libvex.h -@@ -101,6 +101,8 @@ typedef - #define VEX_HWCAPS_AMD64_RDRAND (1<<13) /* RDRAND instructions */ - #define VEX_HWCAPS_AMD64_F16C (1<<14) /* F16C instructions */ - #define VEX_HWCAPS_AMD64_RDSEED (1<<15) /* RDSEED instructions */ -+#define VEX_HWCAPS_AMD64_FMA3 (1<<16) /* FMA3 instructions */ -+#define VEX_HWCAPS_AMD64_FMA4 (1<<17) /* FMA4 instructions */ - - /* ppc32: baseline capability is integer only */ - #define VEX_HWCAPS_PPC32_F (1<<8) /* basic (non-optional) FP */ -diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c -index 079383651226..81fb810643cf 100644 ---- a/coregrind/m_machine.c -+++ b/coregrind/m_machine.c -@@ -984,6 +984,7 @@ Bool VG_(machine_get_hwcaps)( void ) - #elif defined(VGA_amd64) - { Bool have_sse3, have_ssse3, have_cx8, have_cx16; - Bool have_lzcnt, have_avx, have_bmi, have_avx2; -+ Bool have_fma3, have_fma4; - Bool have_rdtscp, have_rdrand, have_f16c, have_rdseed; - UInt eax, ebx, ecx, edx, max_basic, max_extended; - ULong xgetbv_0 = 0; -@@ -992,7 +993,8 @@ Bool VG_(machine_get_hwcaps)( void ) - - have_sse3 = have_ssse3 = have_cx8 = have_cx16 - = have_lzcnt = have_avx = have_bmi = have_avx2 -- = have_rdtscp = have_rdrand = have_f16c = have_rdseed = False; -+ = have_rdtscp = have_rdrand = have_f16c = have_rdseed -+ = have_fma3 = have_fma4 = False; - - eax = ebx = ecx = edx = max_basic = max_extended = 0; - -@@ -1022,7 +1024,7 @@ Bool VG_(machine_get_hwcaps)( void ) - // we assume that SSE1 and SSE2 are available by default - have_sse3 = (ecx & (1<<0)) != 0; /* True => have sse3 insns */ - have_ssse3 = (ecx & (1<<9)) != 0; /* True => have Sup SSE3 insns */ -- // fma is ecx:12 -+ have_fma3 = (ecx & (1<<12))!= 0; /* True => have fma3 insns */ - // sse41 is ecx:19 - // sse42 is ecx:20 - // xsave is ecx:26 -@@ -1032,7 +1034,7 @@ Bool VG_(machine_get_hwcaps)( void ) - have_rdrand = (ecx & (1<<30)) != 0; /* True => have RDRAND insns */ - - have_avx = False; -- /* have_fma = False; */ -+ - if ( (ecx & ((1<<28)|(1<<27)|(1<<26))) == ((1<<28)|(1<<27)|(1<<26)) ) { - /* Processor supports AVX instructions and XGETBV is enabled - by OS and AVX instructions are enabled by the OS. */ -@@ -1059,9 +1061,6 @@ Bool VG_(machine_get_hwcaps)( void ) - if (ebx2 == 576 && eax2 == 256) { - have_avx = True; - } -- /* have_fma = (ecx & (1<<12)) != 0; */ -- /* have_fma: Probably correct, but gcc complains due to -- unusedness. */ - } - } - -@@ -1089,6 +1088,11 @@ Bool VG_(machine_get_hwcaps)( void ) - have_rdtscp = (edx & (1<<27)) != 0; /* True => have RDTSVCP */ - } - -+ if (max_extended >= 0x80000001) { -+ VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx); -+ have_fma4= (ecx & (1<<16)) != 0; /* True => have fma4 */ -+ } -+ - /* Check for BMI1 and AVX2. If we have AVX1 (plus OS support). */ - have_bmi = False; - have_avx2 = False; -@@ -1120,7 +1124,9 @@ Bool VG_(machine_get_hwcaps)( void ) - | (have_rdtscp ? VEX_HWCAPS_AMD64_RDTSCP : 0) - | (have_f16c ? VEX_HWCAPS_AMD64_F16C : 0) - | (have_rdrand ? VEX_HWCAPS_AMD64_RDRAND : 0) -- | (have_rdseed ? VEX_HWCAPS_AMD64_RDSEED : 0); -+ | (have_rdseed ? VEX_HWCAPS_AMD64_RDSEED : 0) -+ | (have_fma3 ? VEX_HWCAPS_AMD64_FMA3 : 0) -+ | (have_fma4 ? VEX_HWCAPS_AMD64_FMA4 : 0); - - VG_(machine_get_cache_info)(&vai); - diff --git a/valgrind-3.22.0-amd64-redir-strcmp.patch b/valgrind-3.22.0-amd64-redir-strcmp.patch deleted file mode 100644 index 6e37ba1..0000000 --- a/valgrind-3.22.0-amd64-redir-strcmp.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c -index cef241b4f85aad23..ce6073a62190a639 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 da96972323824bdb..716afb2121b84b57 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 54c575a7233a9451..c11060139e576616 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 UInt VG_(amd64_linux_REDIR_FOR_strcmp)( void*, void* ); - extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int ); - #endif - diff --git a/valgrind-3.22.0-fchmodat2.patch b/valgrind-3.22.0-fchmodat2.patch deleted file mode 100644 index b1ba313..0000000 --- a/valgrind-3.22.0-fchmodat2.patch +++ /dev/null @@ -1,206 +0,0 @@ -From a43e62dddcf51ec6578a90c5988a41e856b44b05 Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Sat, 18 Nov 2023 21:17:02 +0100 -Subject: [PATCH] Add fchmodat2 syscall on linux - -fchmodat2 is a new syscall on linux 6.6. It is a variant of fchmodat -that takes an extra flags argument. - -https://bugs.kde.org/show_bug.cgi?id=477198 - -(cherry picked from commit 372d09fd9a8d76847c81092ebff71c80fd6c145d) ---- - NEWS | 1 + - coregrind/m_syswrap/priv_syswrap-linux.h | 3 +++ - coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-linux.c | 11 +++++++++++ - coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + - coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + - coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ - coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ - include/vki/vki-scnums-shared-linux.h | 2 ++ - 14 files changed, 35 insertions(+) - -diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h -index 7c9decf5a..798c456c9 100644 ---- a/coregrind/m_syswrap/priv_syswrap-linux.h -+++ b/coregrind/m_syswrap/priv_syswrap-linux.h -@@ -331,6 +331,9 @@ DECL_TEMPLATE(linux, sys_openat2); - // Linux-specific (new in Linux 5.14) - DECL_TEMPLATE(linux, sys_memfd_secret); - -+// Since Linux 6.6 -+DECL_TEMPLATE(linux, sys_fchmodat2); -+ - /* --------------------------------------------------------------------- - Wrappers for sockets and ipc-ery. These are split into standalone - procedures because x86-linux hides them inside multiplexors -diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c -index 008600798..fe17d118b 100644 ---- a/coregrind/m_syswrap/syswrap-amd64-linux.c -+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c -@@ -886,6 +886,8 @@ static SyscallTableEntry syscall_table[] = { - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 -+ -+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c -index 9a7a1e0d2..811931d3b 100644 ---- a/coregrind/m_syswrap/syswrap-arm-linux.c -+++ b/coregrind/m_syswrap/syswrap-arm-linux.c -@@ -1059,6 +1059,8 @@ static SyscallTableEntry syscall_main_table[] = { - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ -+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - -diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c -index 6af7bab83..3307bc2ca 100644 ---- a/coregrind/m_syswrap/syswrap-arm64-linux.c -+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c -@@ -840,6 +840,8 @@ static SyscallTableEntry syscall_main_table[] = { - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 -+ -+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - -diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c -index d571fc327..efa47f2e6 100644 ---- a/coregrind/m_syswrap/syswrap-linux.c -+++ b/coregrind/m_syswrap/syswrap-linux.c -@@ -6059,6 +6059,17 @@ PRE(sys_fchmodat) - PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 ); - } - -+PRE(sys_fchmodat2) -+{ -+ PRINT("sys_fchmodat2 ( %ld, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" -+ FMT_REGWORD "u )", -+ SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4); -+ PRE_REG_READ4(long, "fchmodat2", -+ int, dfd, const char *, path, vki_mode_t, mode, -+ unsigned int, flags); -+ PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 ); -+} -+ - PRE(sys_faccessat) - { - PRINT("sys_faccessat ( %ld, %#" FMT_REGWORD "x(%s), %ld )", -diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c -index 6268a00dd..74a1f6eac 100644 ---- a/coregrind/m_syswrap/syswrap-mips32-linux.c -+++ b/coregrind/m_syswrap/syswrap-mips32-linux.c -@@ -1143,6 +1143,8 @@ static SyscallTableEntry syscall_main_table[] = { - LINX_ (__NR_faccessat2, sys_faccessat2), // 439 - - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ -+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) -diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c -index 6cdf25893..4e8508b7a 100644 ---- a/coregrind/m_syswrap/syswrap-mips64-linux.c -+++ b/coregrind/m_syswrap/syswrap-mips64-linux.c -@@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = { - LINXY (__NR_close_range, sys_close_range), - LINX_ (__NR_faccessat2, sys_faccessat2), - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), -+ LINX_ (__NR_fchmodat2, sys_fchmodat2), - }; - - SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c -index d724cde74..7859900c1 100644 ---- a/coregrind/m_syswrap/syswrap-nanomips-linux.c -+++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c -@@ -829,6 +829,7 @@ static SyscallTableEntry syscall_main_table[] = { - LINXY (__NR_close_range, sys_close_range), - LINX_ (__NR_faccessat2, sys_faccessat2), - LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), -+ LINX_ (__NR_fchmodat2, sys_fchmodat2), - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) -diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c -index c0cfef235..1e19116ee 100644 ---- a/coregrind/m_syswrap/syswrap-ppc32-linux.c -+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c -@@ -1063,6 +1063,8 @@ static SyscallTableEntry syscall_table[] = { - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - - LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ -+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c -index f5976f30c..1097212a4 100644 ---- a/coregrind/m_syswrap/syswrap-ppc64-linux.c -+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c -@@ -1032,6 +1032,8 @@ static SyscallTableEntry syscall_table[] = { - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - - LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ -+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c -index afba154e7..3588672c7 100644 ---- a/coregrind/m_syswrap/syswrap-s390x-linux.c -+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c -@@ -873,6 +873,8 @@ static SyscallTableEntry syscall_table[] = { - LINX_(__NR_faccessat2, sys_faccessat2), // 439 - - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 -+ -+ LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c -index da4fd8fa2..58badc6b0 100644 ---- a/coregrind/m_syswrap/syswrap-x86-linux.c -+++ b/coregrind/m_syswrap/syswrap-x86-linux.c -@@ -1658,6 +1658,8 @@ static SyscallTableEntry syscall_table[] = { - LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 - - LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 -+ -+ LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 - }; - - SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) -diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h -index 542382b53..a4cd87149 100644 ---- a/include/vki/vki-scnums-shared-linux.h -+++ b/include/vki/vki-scnums-shared-linux.h -@@ -50,4 +50,6 @@ - - #define __NR_memfd_secret 447 - -+#define __NR_fchmodat2 452 -+ - #endif --- -2.39.3 - diff --git a/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch b/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch deleted file mode 100644 index cbcf6e0..0000000 --- a/valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch +++ /dev/null @@ -1,355 +0,0 @@ -From 316ef0d22b6f41722cc71316a6b59e60e7c9576c Mon Sep 17 00:00:00 2001 -From: Julian Seward -Date: Mon, 11 Mar 2024 17:53:14 +0100 -Subject: [PATCH] Handle gcc __builtin_strcmp using 128/256 bit vectors with - sse4.1, avx/avx2 - -* amd64 front end: redo the translation into IR for PTEST, so as to - use only IROps which we know Memcheck can do exact instrumentation - for. Handling for both the 128- and 256-bit cases is has been - changed. - -* ir_opt.c: add some constant folding rules to support the above. In - particular, for the case `ptest %reg, %reg` (the same reg twice), we - want rflags.C to be set to a defined-1 even if %reg is completely - undefined. Doing that requires folding `x and not(x)` to zero when - x has type V128 or V256. - -* memcheck/tests/amd64/rh2257546_{128,256}.c: new test cases - -https://bugzilla.redhat.com/show_bug.cgi?id=2257546 ---- - VEX/priv/guest_amd64_toIR.c | 64 +++++++++---------- - VEX/priv/ir_opt.c | 34 ++++++++++ - memcheck/tests/amd64/Makefile.am | 7 +- - memcheck/tests/amd64/rh2257546_128.c | 32 ++++++++++ - memcheck/tests/amd64/rh2257546_128.stderr.exp | 0 - memcheck/tests/amd64/rh2257546_128.stdout.exp | 1 + - memcheck/tests/amd64/rh2257546_128.vgtest | 2 + - memcheck/tests/amd64/rh2257546_256.c | 32 ++++++++++ - memcheck/tests/amd64/rh2257546_256.stderr.exp | 0 - memcheck/tests/amd64/rh2257546_256.stdout.exp | 1 + - memcheck/tests/amd64/rh2257546_256.vgtest | 3 + - 11 files changed, 141 insertions(+), 35 deletions(-) - create mode 100644 memcheck/tests/amd64/rh2257546_128.c - create mode 100644 memcheck/tests/amd64/rh2257546_128.stderr.exp - create mode 100644 memcheck/tests/amd64/rh2257546_128.stdout.exp - create mode 100644 memcheck/tests/amd64/rh2257546_128.vgtest - create mode 100644 memcheck/tests/amd64/rh2257546_256.c - create mode 100644 memcheck/tests/amd64/rh2257546_256.stderr.exp - create mode 100644 memcheck/tests/amd64/rh2257546_256.stdout.exp - create mode 100644 memcheck/tests/amd64/rh2257546_256.vgtest - -diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c -index 0414aa5c5..d7c25042d 100644 ---- a/VEX/priv/guest_amd64_toIR.c -+++ b/VEX/priv/guest_amd64_toIR.c -@@ -16826,13 +16826,18 @@ static Long dis_VBLENDV_256 ( const VexAbiInfo* vbi, Prefix pfx, Long delta, - - static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) - { -- /* Set Z=1 iff (vecE & vecG) == 0 -- Set C=1 iff (vecE & not vecG) == 0 -+ /* Set Z=1 iff (vecE & vecG) == 0--(128)--0 -+ Set C=1 iff (vecE & not vecG) == 0--(128)--0 -+ -+ For the case `sign == 0`, be careful to use only IROps that can be -+ instrumented exactly by memcheck. This is because PTEST is used for -+ __builtin_strcmp in gcc14. See -+ https://bugzilla.redhat.com/show_bug.cgi?id=2257546 - */ - - /* andV, andnV: vecE & vecG, vecE and not(vecG) */ - -- /* andV resp. andnV, reduced to 64-bit values, by or-ing the top -+ /* andV resp. andnV, are reduced to 64-bit values by or-ing the top - and bottom 64-bits together. It relies on this trick: - - InterleaveLO64x2([a,b],[c,d]) == [b,d] hence -@@ -16862,11 +16867,13 @@ static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) - binop(Iop_InterleaveHI64x2, - mkexpr(andnV), mkexpr(andnV))))); - -+ // Make z64 and c64 be either all-0s or all-1s - IRTemp z64 = newTemp(Ity_I64); - IRTemp c64 = newTemp(Ity_I64); -+ - if (sign == 64) { -- /* When only interested in the most significant bit, just shift -- arithmetically right and negate. */ -+ /* When only interested in the most significant bit, just copy bit 63 -+ into all bit positions, then invert. */ - assign(z64, - unop(Iop_Not64, - binop(Iop_Sar64, mkexpr(and64), mkU8(63)))); -@@ -16874,37 +16881,28 @@ static void finish_xTESTy ( IRTemp andV, IRTemp andnV, Int sign ) - assign(c64, - unop(Iop_Not64, - binop(Iop_Sar64, mkexpr(andn64), mkU8(63)))); -- } else { -- if (sign == 32) { -- /* When interested in bit 31 and bit 63, mask those bits and -- fallthrough into the PTEST handling. */ -- IRTemp t0 = newTemp(Ity_I64); -- IRTemp t1 = newTemp(Ity_I64); -- IRTemp t2 = newTemp(Ity_I64); -- assign(t0, mkU64(0x8000000080000000ULL)); -- assign(t1, binop(Iop_And64, mkexpr(and64), mkexpr(t0))); -- assign(t2, binop(Iop_And64, mkexpr(andn64), mkexpr(t0))); -- and64 = t1; -- andn64 = t2; -- } -- /* Now convert and64, andn64 to all-zeroes or all-1s, so we can -- slice out the Z and C bits conveniently. We use the standard -- trick all-zeroes -> all-zeroes, anything-else -> all-ones -- done by "(x | -x) >>s (word-size - 1)". -- */ -+ } else if (sign == 32) { -+ /* If we're interested into bits 63 and 31, OR bit 31 into bit 63, copy -+ bit 63 into all bit positions, then invert. */ -+ IRTemp and3264 = newTemp(Ity_I64); -+ assign(and3264, binop(Iop_Or64, mkexpr(and64), -+ binop(Iop_Shl64, mkexpr(and64), mkU8(32)))); - assign(z64, - unop(Iop_Not64, -- binop(Iop_Sar64, -- binop(Iop_Or64, -- binop(Iop_Sub64, mkU64(0), mkexpr(and64)), -- mkexpr(and64)), mkU8(63)))); -+ binop(Iop_Sar64, mkexpr(and3264), mkU8(63)))); - -+ IRTemp andn3264 = newTemp(Ity_I64); -+ assign(andn3264, binop(Iop_Or64, mkexpr(andn64), -+ binop(Iop_Shl64, mkexpr(andn64), mkU8(32)))); - assign(c64, - unop(Iop_Not64, -- binop(Iop_Sar64, -- binop(Iop_Or64, -- binop(Iop_Sub64, mkU64(0), mkexpr(andn64)), -- mkexpr(andn64)), mkU8(63)))); -+ binop(Iop_Sar64, mkexpr(andn3264), mkU8(63)))); -+ } else { -+ vassert(sign == 0); -+ assign(z64, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(and64), mkU64(0)), -+ mkU64(~0ULL), mkU64(0ULL))); -+ assign(c64, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(andn64), mkU64(0)), -+ mkU64(~0ULL), mkU64(0ULL))); - } - - /* And finally, slice out the Z and C flags and set the flags -@@ -16966,9 +16964,7 @@ static Long dis_xTESTy_128 ( const VexAbiInfo* vbi, Prefix pfx, - IRTemp andnV = newTemp(Ity_V128); - assign(andV, binop(Iop_AndV128, mkexpr(vecE), mkexpr(vecG))); - assign(andnV, binop(Iop_AndV128, -- mkexpr(vecE), -- binop(Iop_XorV128, mkexpr(vecG), -- mkV128(0xFFFF)))); -+ mkexpr(vecE), unop(Iop_NotV128, mkexpr(vecG)))); - - finish_xTESTy ( andV, andnV, sign ); - return delta; -diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c -index f918e9f85..6453f4fdf 100644 ---- a/VEX/priv/ir_opt.c -+++ b/VEX/priv/ir_opt.c -@@ -1693,6 +1693,17 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) - break; - } - -+ /* Similarly .. */ -+ case Iop_V256toV128_0: case Iop_V256toV128_1: { -+ UInt v256 = e->Iex.Unop.arg->Iex.Const.con->Ico.V256; -+ if (v256 == 0x00000000) { -+ e2 = IRExpr_Const(IRConst_V128(0x0000)); -+ } else { -+ goto unhandled; -+ } -+ break; -+ } -+ - case Iop_ZeroHI64ofV128: { - /* Could do better here -- only need to look at the bottom 64 bits - of the argument, really. */ -@@ -2129,6 +2140,8 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) - } - - /* -- V128 stuff -- */ -+ case Iop_InterleaveLO64x2: // This, and the HI64, are created -+ case Iop_InterleaveHI64x2: // by the amd64 PTEST translation - case Iop_InterleaveLO8x16: { - /* This turns up a lot in Memcheck instrumentation of - Icc generated code. I don't know why. */ -@@ -2321,6 +2334,27 @@ static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) - break; - } - } -+ /* AndV128( x, NotV128( x ) ) ==> 0...0 and -+ AndV256( x, NotV256( x ) ) ==> 0...0 -+ This is generated by amd64 `ptest %xmmReg, %xmmReg` -+ (the same reg both times) -+ See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 */ -+ if (e->Iex.Binop.op == Iop_AndV128 -+ || e->Iex.Binop.op == Iop_AndV256) { -+ Bool isV256 = e->Iex.Binop.op == Iop_AndV256; -+ IRExpr* x1 = chase(env, e->Iex.Binop.arg1); -+ IRExpr* rhs = chase(env, e->Iex.Binop.arg2); -+ if (x1 && rhs -+ && rhs->tag == Iex_Unop -+ && rhs->Iex.Unop.op == (isV256 ? Iop_NotV256 -+ : Iop_NotV128)) { -+ IRExpr* x2 = chase(env, rhs->Iex.Unop.arg); -+ if (x2 && sameIRExprs(env, x1, x2)) { -+ e2 = mkZeroOfPrimopResultType(e->Iex.Binop.op); -+ break; -+ } -+ } -+ } - break; - - case Iop_OrV128: -diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am -index 0d2812dd8..906b8f393 100644 ---- a/memcheck/tests/amd64/Makefile.am -+++ b/memcheck/tests/amd64/Makefile.am -@@ -20,6 +20,10 @@ EXTRA_DIST = \ - insn-pmovmskb.stderr.exp-clang \ - more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \ - pcmpgt.stderr.exp pcmpgt.vgtest \ -+ rh2257546_128.vgtest \ -+ rh2257546_128.stderr.exp rh2257546_128.stdout.exp \ -+ rh2257546_256.vgtest \ -+ rh2257546_256.stderr.exp rh2257546_256.stdout.exp \ - sh-mem-vec128-plo-no.vgtest \ - sh-mem-vec128-plo-no.stderr.exp \ - sh-mem-vec128-plo-no.stdout.exp \ -@@ -46,12 +50,13 @@ check_PROGRAMS = \ - insn-bsfl \ - insn-pmovmskb \ - pcmpgt \ -+ rh2257546_128 \ - sh-mem-vec128 \ - sse_memory \ - xor-undef-amd64 - - if BUILD_AVX_TESTS -- check_PROGRAMS += sh-mem-vec256 xsave-avx -+ check_PROGRAMS += rh2257546_256 sh-mem-vec256 xsave-avx - endif - if HAVE_ASM_CONSTRAINT_P - check_PROGRAMS += insn-pcmpistri -diff --git a/memcheck/tests/amd64/rh2257546_128.c b/memcheck/tests/amd64/rh2257546_128.c -new file mode 100644 -index 000000000..a405aa775 ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_128.c -@@ -0,0 +1,32 @@ -+ -+// This should run on memcheck without reporting an undef-value error. -+// See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 -+ -+#include -+#include -+ -+int main ( void ) -+{ -+ char* c1 = malloc(16); -+ c1[0] = 'x'; c1[1] = 'y'; c1[2] = 'x'; c1[3] = 0; -+ -+ char* c2 = "foobarxyzzyfoobarzyzzy"; // strlen > 16 -+ -+ long long int res; -+ __asm__ __volatile__( -+ "movdqu (%1), %%xmm4" "\n\t" -+ "movdqu (%2), %%xmm5" "\n\t" -+ "pxor %%xmm4, %%xmm5" "\n\t" -+ "ptest %%xmm5, %%xmm5" "\n\t" -+ "je zzz1f" "\n\t" -+ "mov $99, %0" "\n\t" -+ "jmp zzzafter" "\n" -+ "zzz1f:" "\n\t" -+ "mov $88, %0" "\n" -+ "zzzafter:" "\n\t" -+ : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"xmm4","xmm5","cc" -+ ); -+ printf("res = %lld\n", res); -+ free(c1); -+ return 0; -+} -diff --git a/memcheck/tests/amd64/rh2257546_128.stderr.exp b/memcheck/tests/amd64/rh2257546_128.stderr.exp -new file mode 100644 -index 000000000..e69de29bb -diff --git a/memcheck/tests/amd64/rh2257546_128.stdout.exp b/memcheck/tests/amd64/rh2257546_128.stdout.exp -new file mode 100644 -index 000000000..454131089 ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_128.stdout.exp -@@ -0,0 +1 @@ -+res = 99 -diff --git a/memcheck/tests/amd64/rh2257546_128.vgtest b/memcheck/tests/amd64/rh2257546_128.vgtest -new file mode 100644 -index 000000000..94414cd6f ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_128.vgtest -@@ -0,0 +1,2 @@ -+prog: rh2257546_128 -+vgopts: -q -diff --git a/memcheck/tests/amd64/rh2257546_256.c b/memcheck/tests/amd64/rh2257546_256.c -new file mode 100644 -index 000000000..235005ca6 ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_256.c -@@ -0,0 +1,32 @@ -+ -+// This should run on memcheck without reporting an undef-value error. -+// See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 -+ -+#include -+#include -+ -+int main ( void ) -+{ -+ char* c1 = malloc(32); -+ c1[0] = 'x'; c1[1] = 'y'; c1[2] = 'x'; c1[3] = 0; -+ -+ char* c2 = "foobarxyzzyfoobarzyzzyandawholelotmoretoo"; // strlen > 32 -+ -+ long long int res; -+ __asm__ __volatile__( -+ "vmovdqu (%1), %%ymm4" "\n\t" -+ "vmovdqu (%2), %%ymm5" "\n\t" -+ "vpxor %%ymm4, %%ymm5, %%ymm5" "\n\t" -+ "vptest %%ymm5, %%ymm5" "\n\t" -+ "je zzz1f" "\n\t" -+ "mov $99, %0" "\n\t" -+ "jmp zzzafter" "\n" -+ "zzz1f:" "\n\t" -+ "mov $88, %0" "\n" -+ "zzzafter:" "\n\t" -+ : /*OUT*/"=r"(res) : /*IN*/"r"(c1),"r"(c2) : /*TRASH*/"ymm4","ymm5","cc" -+ ); -+ printf("res = %lld\n", res); -+ free(c1); -+ return 0; -+} -diff --git a/memcheck/tests/amd64/rh2257546_256.stderr.exp b/memcheck/tests/amd64/rh2257546_256.stderr.exp -new file mode 100644 -index 000000000..e69de29bb -diff --git a/memcheck/tests/amd64/rh2257546_256.stdout.exp b/memcheck/tests/amd64/rh2257546_256.stdout.exp -new file mode 100644 -index 000000000..454131089 ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_256.stdout.exp -@@ -0,0 +1 @@ -+res = 99 -diff --git a/memcheck/tests/amd64/rh2257546_256.vgtest b/memcheck/tests/amd64/rh2257546_256.vgtest -new file mode 100644 -index 000000000..86eef8fe2 ---- /dev/null -+++ b/memcheck/tests/amd64/rh2257546_256.vgtest -@@ -0,0 +1,3 @@ -+prereq: test -e rh2257546_256 -+prog: rh2257546_256 -+vgopts: -q --- -2.43.0 - diff --git a/valgrind-3.22.0-gdb-thread-exited.patch b/valgrind-3.22.0-gdb-thread-exited.patch deleted file mode 100644 index 4a4d451..0000000 --- a/valgrind-3.22.0-gdb-thread-exited.patch +++ /dev/null @@ -1,23 +0,0 @@ -commit 7aa63de01a3cda2a346f90be16bd29fd7b410c63 -Author: Mark Wielaard -Date: Mon Jan 22 14:08:30 2024 +0100 - - gdbserver_tests/filter_gdb.in: delete thread exiting - - The hginfo testcase would fail with GDB 14.1 because it would output - an extra line saying: [Thread .... exited] - -diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in -index 16186dfe2c9b..6c85284b7531 100755 ---- a/gdbserver_tests/filter_gdb.in -+++ b/gdbserver_tests/filter_gdb.in -@@ -65,6 +65,9 @@ s/Thread [0-9][0-9]*/Thread ..../g - # delete thread switches - /\[Switching to Thread ....\]/d - -+# delete thread exiting -+/\[Thread .... exited\]/d -+ - # ??? Probably we had a 'Switching ' message in front of - # a frame line ? - s/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/ diff --git a/valgrind-3.22.0-pth_mempcpy_false_races.patch b/valgrind-3.22.0-pth_mempcpy_false_races.patch deleted file mode 100644 index d1d426d..0000000 --- a/valgrind-3.22.0-pth_mempcpy_false_races.patch +++ /dev/null @@ -1,33 +0,0 @@ -commit f47109d30ca319a3bcd4288803e30a473d1506d2 -Author: Mark Wielaard -Date: Fri Apr 12 15:18:51 2024 +0200 - - Add new helgrind race suppression for pth_mempcpy_false_races - - In glibc 2.39+ the internal __printf_buffer_write might use memmove - instead of a memcpy variant. Add an extra suppression variant using - memmove. - - This makes pth_mempcpy_false_races pass again. - - See also https://bugs.kde.org/show_bug.cgi?id=450962 - -diff --git a/glibc-2.X-helgrind.supp.in b/glibc-2.X-helgrind.supp.in -index 2b576b982e42..dce611a09e38 100644 ---- a/glibc-2.X-helgrind.supp.in -+++ b/glibc-2.X-helgrind.supp.in -@@ -63,6 +63,14 @@ - fun:__printf_buffer_write - } - -+{ -+ helgrind-glibc-__printf_buffer_write2 -+ Helgrind:Race -+ fun:*memmove* -+ ... -+ fun:__printf_buffer_write -+} -+ - { - helgrind-glibc2X-005 - Helgrind:Race diff --git a/valgrind-3.22.0-rodata.patch b/valgrind-3.22.0-rodata.patch deleted file mode 100644 index 47f31ed..0000000 --- a/valgrind-3.22.0-rodata.patch +++ /dev/null @@ -1,122 +0,0 @@ -commit 1d00e5ce0fb069911c4b525ec38289fb5d9021b0 -Author: Paul Floyd -Date: Sat Nov 18 08:49:34 2023 +0100 - - Bug 476548 - valgrind 3.22.0 fails on assertion when loading debuginfo file produced by mold - - (cherry picked from commit 9ea4ae66707a4dcc6f4328e11911652e4418c585) - -diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c -index 02e509071..445f95555 100644 ---- a/coregrind/m_debuginfo/image.c -+++ b/coregrind/m_debuginfo/image.c -@@ -1221,6 +1221,20 @@ Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2) - } - } - -+Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n) -+{ -+ ensure_valid(img, off1, 1, "ML_(img_strcmp_c)"); -+ while (n) { -+ UChar c1 = get(img, off1); -+ UChar c2 = *(const UChar*)str2; -+ if (c1 < c2) return -1; -+ if (c1 > c2) return 1; -+ if (c1 == 0) return 0; -+ off1++; str2++; --n; -+ } -+ return 0; -+} -+ - UChar ML_(img_get_UChar)(DiImage* img, DiOffT offset) - { - ensure_valid(img, offset, 1, "ML_(img_get_UChar)"); -diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h -index a49846f14..c91e49f01 100644 ---- a/coregrind/m_debuginfo/priv_image.h -+++ b/coregrind/m_debuginfo/priv_image.h -@@ -115,6 +115,10 @@ Int ML_(img_strcmp)(DiImage* img, DiOffT off1, DiOffT off2); - cast to HChar before comparison. */ - Int ML_(img_strcmp_c)(DiImage* img, DiOffT off1, const HChar* str2); - -+/* Do strncmp of a C string in the image vs a normal one. Chars are -+ cast to HChar before comparison. */ -+Int ML_(img_strcmp_n)(DiImage* img, DiOffT off1, const HChar* str2, Word n); -+ - /* Do strlen of a C string in the image. */ - SizeT ML_(img_strlen)(DiImage* img, DiOffT off); - -diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c -index fb64ed976..46f8c8343 100644 ---- a/coregrind/m_debuginfo/readelf.c -+++ b/coregrind/m_debuginfo/readelf.c -@@ -2501,8 +2501,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) - di->rodata_avma += inrw1->bias; - di->rodata_bias = inrw1->bias; - di->rodata_debug_bias = inrw1->bias; -- } -- else { -+ } else { - BAD(".rodata"); /* should not happen? */ - } - di->rodata_present = True; -@@ -2977,6 +2976,46 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) - return retval; - } - -+static void find_rodata(Word i, Word shnum, DiImage* dimg, struct _DebugInfo* di, DiOffT shdr_dioff, -+ UWord shdr_dent_szB, DiOffT shdr_strtab_dioff, PtrdiffT rw_dbias) -+{ -+ ElfXX_Shdr a_shdr; -+ ElfXX_Shdr a_extra_shdr; -+ ML_(img_get)(&a_shdr, dimg, -+ INDEX_BIS(shdr_dioff, i, shdr_dent_szB), -+ sizeof(a_shdr)); -+ if (di->rodata_present && -+ 0 == ML_(img_strcmp_c)(dimg, shdr_strtab_dioff -+ + a_shdr.sh_name, ".rodata")) { -+ Word sh_size = a_shdr.sh_size; -+ Word j; -+ Word next_addr = a_shdr.sh_addr + a_shdr.sh_size; -+ for (j = i + 1; j < shnum; ++j) { -+ ML_(img_get)(&a_extra_shdr, dimg, -+ INDEX_BIS(shdr_dioff, j, shdr_dent_szB), -+ sizeof(a_shdr)); -+ if (0 == ML_(img_strcmp_n)(dimg, shdr_strtab_dioff -+ + a_extra_shdr.sh_name, ".rodata", 7)) { -+ if (a_extra_shdr.sh_addr == -+ VG_ROUNDUP(next_addr, a_extra_shdr.sh_addralign)) { -+ sh_size = VG_ROUNDUP(sh_size, a_extra_shdr.sh_addralign) + a_extra_shdr.sh_size; -+ } -+ next_addr = a_extra_shdr.sh_addr + a_extra_shdr.sh_size; -+ } else { -+ break; -+ } -+ } -+ vg_assert(di->rodata_size == sh_size); -+ vg_assert(di->rodata_avma + a_shdr.sh_addr + rw_dbias); -+ di->rodata_debug_svma = a_shdr.sh_addr; -+ di->rodata_debug_bias = di->rodata_bias + -+ di->rodata_svma - di->rodata_debug_svma; -+ TRACE_SYMTAB("acquiring .rodata debug svma = %#lx .. %#lx\n", -+ di->rodata_debug_svma, -+ di->rodata_debug_svma + di->rodata_size - 1); -+ TRACE_SYMTAB("acquiring .rodata debug bias = %#lx\n", (UWord)di->rodata_debug_bias); -+ } -+} - Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) - { - Word i, j; -@@ -3391,7 +3430,11 @@ Bool ML_(read_elf_debug) ( struct _DebugInfo* di ) - FIND(text, rx) - FIND(data, rw) - FIND(sdata, rw) -- FIND(rodata, rw) -+ // https://bugs.kde.org/show_bug.cgi?id=476548 -+ // special handling for rodata as adjacent -+ // rodata sections may have been merged in ML_(read_elf_object) -+ //FIND(rodata, rw) -+ find_rodata(i, ehdr_dimg.e_shnum, dimg, di, shdr_dioff, shdr_dent_szB, shdr_strtab_dioff, rw_dbias); - FIND(bss, rw) - FIND(sbss, rw) - diff --git a/valgrind-3.22.0-set_vma_name-supp.patch b/valgrind-3.22.0-set_vma_name-supp.patch deleted file mode 100644 index 42b39a0..0000000 --- a/valgrind-3.22.0-set_vma_name-supp.patch +++ /dev/null @@ -1,24 +0,0 @@ -commit 5505e7b371f26f9f9588f4aa3a156dfa6856b90a -Author: Mark Wielaard -Date: Thu Apr 11 19:48:22 2024 +0200 - - Add __set_vma_name suppression to drd/tests/std_thread2.supp - - glibc uses a atomic var to set whether the kernel supports - PR_SET_VMA_ANON_NAME. This looks like a conflicting access to drd. - Suppress it for this testcase. - -diff --git a/drd/tests/std_thread2.supp b/drd/tests/std_thread2.supp -index 4f30560cb924..22052cf2c935 100644 ---- a/drd/tests/std_thread2.supp -+++ b/drd/tests/std_thread2.supp -@@ -44,4 +44,9 @@ - drd:ConflictingAccess - obj:/libexec/ld-elf*.so.1 - } -+{ -+ drd-glibc-set-vma-name -+ drd:ConflictingAccess -+ fun:__set_vma_name -+} - diff --git a/valgrind-3.22.0-valgrind-monitor-python-re.patch b/valgrind-3.22.0-valgrind-monitor-python-re.patch deleted file mode 100644 index 61d26cd..0000000 --- a/valgrind-3.22.0-valgrind-monitor-python-re.patch +++ /dev/null @@ -1,32 +0,0 @@ -commit 0fbfbe05028ad18efda786a256a2738d2c231ed4 -Author: Mark Wielaard -Date: Fri Nov 17 13:31:52 2023 +0100 - - valgrind-monitor.py regular expressions should use raw strings - - With python 3.12 gdb will produce the following SyntaxWarning when - loading valgrind-monitor-def.py: - - /usr/share/gdb/auto-load/valgrind-monitor-def.py:214: - SyntaxWarning: invalid escape sequence '\[' - if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): - - In a future python version this will become an SyntaxError. - - Use a raw strings for the regular expression. - - https://bugs.kde.org/show_bug.cgi?id=476708 - -diff --git a/coregrind/m_gdbserver/valgrind-monitor-def.py b/coregrind/m_gdbserver/valgrind-monitor-def.py -index b4e7b992d..d74b1590c 100644 ---- a/coregrind/m_gdbserver/valgrind-monitor-def.py -+++ b/coregrind/m_gdbserver/valgrind-monitor-def.py -@@ -211,7 +211,7 @@ class Valgrind_ADDR_LEN_opt(Valgrind_Command): - For compatibility reason with the Valgrind gdbserver monitor command, - we detect and accept usages such as 0x1234ABCD[10].""" - def invoke(self, arg_str : str, from_tty : bool) -> None: -- if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): -+ if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str): - arg_str = arg_str.replace("[", " ") - arg_str = arg_str.replace("]", " ") - eval_execute_2(self, arg_str, diff --git a/valgrind-3.22.0-x86-nop.patch b/valgrind-3.22.0-x86-nop.patch deleted file mode 100644 index 421b291..0000000 --- a/valgrind-3.22.0-x86-nop.patch +++ /dev/null @@ -1,136 +0,0 @@ -From d35005cef8ad8207542738812705ceabf137d7e0 Mon Sep 17 00:00:00 2001 -From: Paul Floyd -Date: Sun, 17 Dec 2023 14:18:51 +0100 -Subject: [PATCH] Bug 478624 - Valgrind incompatibility with binutils-2.42 on - x86 with new nop patterns (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26) - -It was a bit of a struggle to get the testcase to build -with both clang and gcc (oddly enough gcc was more difficult) so -I just resorted to using .byte arrays. ---- - .gitignore | 1 + - NEWS | 2 ++ - VEX/priv/guest_x86_toIR.c | 22 +++++++++++++- - none/tests/x86/Makefile.am | 2 ++ - none/tests/x86/gnu_binutils_nop.c | 34 ++++++++++++++++++++++ - none/tests/x86/gnu_binutils_nop.stderr.exp | 0 - none/tests/x86/gnu_binutils_nop.vgtest | 2 ++ - 7 files changed, 62 insertions(+), 1 deletion(-) - create mode 100644 none/tests/x86/gnu_binutils_nop.c - create mode 100644 none/tests/x86/gnu_binutils_nop.stderr.exp - create mode 100644 none/tests/x86/gnu_binutils_nop.vgtest - -diff --git a/VEX/priv/guest_x86_toIR.c b/VEX/priv/guest_x86_toIR.c -index 5d6e6dc64..3b6efb387 100644 ---- a/VEX/priv/guest_x86_toIR.c -+++ b/VEX/priv/guest_x86_toIR.c -@@ -8198,7 +8198,7 @@ DisResult disInstr_X86_WRK ( - delta += 5; - goto decode_success; - } -- /* Don't barf on recent binutils padding, -+ /* Don't barf on recent (2010) binutils padding, - all variants of which are: nopw %cs:0x0(%eax,%eax,1) - 66 2e 0f 1f 84 00 00 00 00 00 - 66 66 2e 0f 1f 84 00 00 00 00 00 -@@ -8223,6 +8223,26 @@ DisResult disInstr_X86_WRK ( - } - } - -+ /* bug478624 GNU binutils uses a leal of esi into itself with -+ a zero offset and CS prefix as an 8 byte no-op (Dec 2023). -+ Since the CS prefix is hardly ever used we don't do much -+ to decode it, just a few cases for conditional branches. -+ So add handling here with other pseudo-no-ops. -+ */ -+ if (code[0] == 0x2E && code[1] == 0x8D) { -+ if (code[2] == 0x74 && code[3] == 0x26 && code[4] == 0x00) { -+ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n"); -+ delta += 5; -+ goto decode_success; -+ } -+ if (code[2] == 0xB4 && code[3] == 0x26 && code[4] == 0x00 -+ && code[5] == 0x00 && code[6] == 0x00 && code[7] == 0x00) { -+ DIP("leal %%cs:0(%%esi,%%eiz,1),%%esi\n"); -+ delta += 8; -+ goto decode_success; -+ } -+ } -+ - // Intel CET requires the following opcodes to be treated as NOPs - // with any prefix and ModRM, SIB and disp combination: - // "0F 19", "0F 1C", "0F 1D", "0F 1E", "0F 1F" -diff --git a/none/tests/x86/Makefile.am b/none/tests/x86/Makefile.am -index 3ecd1ad3c..dbae86571 100644 ---- a/none/tests/x86/Makefile.am -+++ b/none/tests/x86/Makefile.am -@@ -52,6 +52,7 @@ EXTRA_DIST = \ - fxtract.stdout.exp fxtract.stderr.exp fxtract.vgtest \ - fxtract.stdout.exp-older-glibc \ - getseg.stdout.exp getseg.stderr.exp getseg.vgtest \ -+ gnu_binutils_nop.stderr.exp gnu_binutils_nop.vgtest \ - incdec_alt.stdout.exp incdec_alt.stderr.exp incdec_alt.vgtest \ - int.stderr.exp int.stdout.exp int.disabled \ - $(addsuffix .stderr.exp,$(INSN_TESTS)) \ -@@ -100,6 +101,7 @@ check_PROGRAMS = \ - fpu_lazy_eflags \ - fxtract \ - getseg \ -+ gnu_binutils_nop \ - incdec_alt \ - $(INSN_TESTS) \ - int \ -diff --git a/none/tests/x86/gnu_binutils_nop.c b/none/tests/x86/gnu_binutils_nop.c -new file mode 100644 -index 000000000..412a4c2cb ---- /dev/null -+++ b/none/tests/x86/gnu_binutils_nop.c -@@ -0,0 +1,34 @@ -+int main(void) -+{ -+ // GNU binutils uses various opcodes as alternatives for nop -+ // the idea is that it is faster to execute one large opcode -+ // with no side-effects than multiple repetitions of the -+ // single byte 'nop'. This gives more choice when code -+ // needs to be padded. -+ -+ // the following is based on -+ // https://sourceware.org/cgit/binutils-gdb/tree/gas/config/tc-i386.c#n1256 -+ -+ // one byte -+ __asm__ __volatile__("nop"); -+ // two bytes -+ __asm__ __volatile__("xchg %ax,%ax"); -+ // three bytes -+ //__asm__ __volatile__("leal 0(%esi),%esi"); -+ __asm__ __volatile__(".byte 0x8d,0x76,0x00"); -+ // four bytes -+ //__asm__ __volatile__("leal 0(%esi,%eiz),%esi"); -+ __asm__ __volatile__(".byte 0x8d,0x74,0x26,0x00"); -+ // five bytes -+ //__asm__ __volatile__("leal %cs:0(%esi,%eiz),%esi"); -+ __asm__ __volatile__(".byte 0x2e,0x8d,0x74,0x26,0x00"); -+ // six bytes -+ //__asm__ __volatile__("leal 0L(%esi),%esi"); -+ __asm__ __volatile__(".byte 0x8d,0xb6,0x00,0x00,0x00,0x00"); -+ // seven bytes -+ //__asm__ __volatile__("leal 0L(%esi,%eiz),%esi"); -+ __asm__ __volatile__(".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00"); -+ // eight bytes -+ //__asm__ __volatile__("leal %cs:0L(%esi,%eiz),%esi"); -+ __asm__ __volatile__(".byte 0x2e,0x8d,0xb4,0x26,0x00,0x00,0x00,0x00"); -+} -diff --git a/none/tests/x86/gnu_binutils_nop.stderr.exp b/none/tests/x86/gnu_binutils_nop.stderr.exp -new file mode 100644 -index 000000000..e69de29bb -diff --git a/none/tests/x86/gnu_binutils_nop.vgtest b/none/tests/x86/gnu_binutils_nop.vgtest -new file mode 100644 -index 000000000..7f378dd53 ---- /dev/null -+++ b/none/tests/x86/gnu_binutils_nop.vgtest -@@ -0,0 +1,2 @@ -+prog: gnu_binutils_nop -+vgopts: -q --- -2.43.0 - diff --git a/valgrind.spec b/valgrind.spec index 766d77f..f264430 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -2,8 +2,8 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind -Version: 3.22.0 -Release: 8%{?dist} +Version: 3.23.0 +Release: 0.1.RC1%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -71,7 +71,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -85,47 +85,6 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch -# valgrind-monitor.py regular expressions should use raw strings -# https://bugs.kde.org/show_bug.cgi?id=476708 -Patch5: valgrind-3.22.0-valgrind-monitor-python-re.patch - -# valgrind 3.22.0 fails on assertion when loading debuginfo -# https://bugs.kde.org/show_bug.cgi?id=476548 -Patch6: valgrind-3.22.0-rodata.patch - -# Add fchmodat2 syscall on linux -# https://bugs.kde.org/show_bug.cgi?id=477198 -Patch7: valgrind-3.22.0-fchmodat2.patch - -# Valgrind incompatibility with binutils-2.42 on x86 with new nop patterns -# (unhandled instruction bytes: 0x2E 0x8D 0xB4 0x26) -# https://bugs.kde.org/show_bug.cgi?id=478624 -Patch8: valgrind-3.22.0-x86-nop.patch - -# Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2 -# https://bugzilla.redhat.com/show_bug.cgi?id=2257546 -Patch9: valgrind-3.22.0-gcc-builtin_strcmp-128-256-bit-vector.patch - -# Upstream commit 7aa63de01a3cda2a346f90be16bd29fd7b410c63 -# Testsuite fix gdbserver_tests/filter_gdb.in: delete thread exiting -Patch10: valgrind-3.22.0-gdb-thread-exited.patch - -# Upstream commit 5505e7b371f26f9f9588f4aa3a156dfa6856b90a -# Add __set_vma_name suppression to drd/tests/std_thread2.supp -Patch11: valgrind-3.22.0-set_vma_name-supp.patch - -# Upstream commit f47109d30ca319a3bcd4288803e30a473d1506d2 -# Add new helgrind race suppression for pth_mempcpy_false_races -Patch12: valgrind-3.22.0-pth_mempcpy_false_races.patch - -# amd64: Implement VFMADD213 for Iop_MAddF32 and Iop_MAddF64 -# https://bugs.kde.org/show_bug.cgi?id=481127 -Patch13: valgrind-3.22.0-amd64-VFMADD213.patch - -# glibc built with -march=x86-64-v3 does not work due to ld.so strcmp -# https://bugs.kde.org/show_bug.cgi?id=485487 -Patch14: valgrind-3.22.0-amd64-redir-strcmp.patch - BuildRequires: make BuildRequires: glibc-devel @@ -257,23 +216,13 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 %patch -P1 -p1 %patch -P2 -p1 %patch -P3 -p1 %patch -P4 -p1 -%patch -P5 -p1 -%patch -P6 -p1 -%patch -P7 -p1 -%patch -P8 -p1 -%patch -P9 -p1 -%patch -P10 -p1 -%patch -P11 -p1 -%patch -P12 -p1 -%patch -P13 -p1 -%patch -P14 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -490,6 +439,10 @@ echo ===============END TESTING=============== %endif %changelog +* Sat Apr 20 2024 Mark Wielaard - 3.23.0-0.1.RC1 ++- Upstream 3.23.0-RC1 ++- Remove all upstreamed patches + * Sat Apr 13 2024 Mark Wielaard - 3.22.0-8 - Add BuildRequires: python3-devel for running testsuite. - Add valgrind-3.22.0-gdb-thread-exited.patch From 39592cc3ae8303ecbeb355e1dd41ac78b16b9fca Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 25 Apr 2024 01:19:54 +0200 Subject: [PATCH 48/86] 3.23.0-0.1.RC2 - Upstream 3.23.0-RC2 --- .gitignore | 1 + sources | 2 +- valgrind.spec | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 27bdf5b..c5466af 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ /valgrind-3.22.0.RC2.tar.bz2 /valgrind-3.22.0.tar.bz2 /valgrind-3.23.0.RC1.tar.bz2 +/valgrind-3.23.0.RC2.tar.bz2 diff --git a/sources b/sources index b1c83bf..27e9604 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.23.0.RC1.tar.bz2) = 6d9b95ce919ffa1993265c2972b407beb2879b87f84efd61ada4e75f334b332917a726b053c5dbc64b970a55334189c48ccae9231934c9474b65eb6ec1e2c18f +SHA512 (valgrind-3.23.0.RC2.tar.bz2) = 36d20c08442bd00ae560693517d69ab5cc1665b210cb7510e6ab7cfa7ce7a35e0f289fdbedc0b1c682ad2698586e49c8c65e52bbe699eef3aec6b7b1fdb5b961 diff --git a/valgrind.spec b/valgrind.spec index f264430..67acdcc 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.23.0 -Release: 0.1.RC1%{?dist} +Release: 0.1.RC2%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -71,7 +71,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC1.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -216,7 +216,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC1 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 %patch -P1 -p1 %patch -P2 -p1 @@ -439,6 +439,9 @@ echo ===============END TESTING=============== %endif %changelog +* Wed Apr 25 2024 Mark Wielaard - 3.23.0-0.1.RC2 +- Upstream 3.23.0-RC2 + * Sat Apr 20 2024 Mark Wielaard - 3.23.0-0.1.RC1 +- Upstream 3.23.0-RC1 +- Remove all upstreamed patches From 06fc3212101489bb9469bc677bd8786e209ac9f1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 25 Apr 2024 13:48:20 +0200 Subject: [PATCH 49/86] 3.23.0-0.2.RC2 - configure --enable-lto --- valgrind.spec | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/valgrind.spec b/valgrind.spec index 67acdcc..f86136a 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.23.0 -Release: 0.1.RC2%{?dist} +Release: 0.2.RC2%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -225,9 +225,8 @@ Valgrind User Manual for details. %build -# LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto -# configure time option, but that doesn't seem to help. -# Disable LTO for now. +# LTO triggers undefined symbols in valgrind. But valgrind has a +# --enable-lto configure time option that we will use instead. %define _lto_cflags %{nil} # Some patches (might) touch Makefile.am or configure.ac files. @@ -288,7 +287,8 @@ export LDFLAGS --with-mpicc=%{mpiccpath} \ %{only_arch} \ GDB=%{_bindir}/gdb \ - --with-gdbscripts-dir=%{_datadir}/gdb/auto-load + --with-gdbscripts-dir=%{_datadir}/gdb/auto-load \ + --enable-lto %make_build @@ -439,7 +439,10 @@ echo ===============END TESTING=============== %endif %changelog -* Wed Apr 25 2024 Mark Wielaard - 3.23.0-0.1.RC2 +* Thu Apr 25 2024 Mark Wielaard - 3.23.0-0.2.RC2 +- configure --enable-lto + +* Wed Apr 24 2024 Mark Wielaard - 3.23.0-0.1.RC2 - Upstream 3.23.0-RC2 * Sat Apr 20 2024 Mark Wielaard - 3.23.0-0.1.RC1 From 133f5f27a5f72438a9bf548cbe03dd0701b9e4df Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 27 Apr 2024 00:42:17 +0200 Subject: [PATCH 50/86] 3.23.0-1 - Upstream 3.23.0 final --- .gitignore | 1 + sources | 2 +- valgrind.spec | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c5466af..cf1eb9f 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ /valgrind-3.22.0.tar.bz2 /valgrind-3.23.0.RC1.tar.bz2 /valgrind-3.23.0.RC2.tar.bz2 +/valgrind-3.23.0.tar.bz2 diff --git a/sources b/sources index 27e9604..11b4f21 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (valgrind-3.23.0.RC2.tar.bz2) = 36d20c08442bd00ae560693517d69ab5cc1665b210cb7510e6ab7cfa7ce7a35e0f289fdbedc0b1c682ad2698586e49c8c65e52bbe699eef3aec6b7b1fdb5b961 +SHA512 (valgrind-3.23.0.tar.bz2) = 27d038faaaf6154cace2df18c3573291393548ba0738dbb6aba58eab6324c5beaa95fc5f3c0271663ca071baf829b15d806f7e81074f7cf087bef20ea0ed3117 diff --git a/valgrind.spec b/valgrind.spec index f86136a..58f7dcf 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.23.0 -Release: 0.2.RC2%{?dist} +Release: 1%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -71,7 +71,7 @@ URL: https://www.valgrind.org/ # So those will already have their full symbol table. %undefine _include_minidebuginfo -Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.RC2.tar.bz2 +Source0: https://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 # Needs investigation and pushing upstream Patch1: valgrind-3.9.0-cachegrind-improvements.patch @@ -216,7 +216,7 @@ Valgrind User Manual for details. %endif %prep -%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version}.RC2 +%setup -q -n %{?scl:%{pkg_name}}%{!?scl:%{name}}-%{version} %patch -P1 -p1 %patch -P2 -p1 @@ -439,6 +439,9 @@ echo ===============END TESTING=============== %endif %changelog +* Fri Apr 26 2024 Mark Wielaard - 3.23.0-1 +- Upstream 3.23.0 final + * Thu Apr 25 2024 Mark Wielaard - 3.23.0-0.2.RC2 - configure --enable-lto From 15d202a6456e4c731389312a878bc913d1654f8d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 10 Jun 2024 00:47:11 +0200 Subject: [PATCH 51/86] 3.23.0-2 - Add upstream VALGRIND_3_23_BRANCH patches --- 0001-Prepare-NEWS-for-branch-3.23-fixes.patch | 31 ++ ...uestArchState-has-no-member-named-gu.patch | 83 ++++++ 0003-Bug-486293-memccpy-false-positives.patch | 96 ++++++ ...-inotify_init-syscall-wrapper-missin.patch | 138 +++++++++ ...rinta-and-frinta-vector-instructions.patch | 282 ++++++++++++++++++ ...ng-shared-syscall-numbers-for-mips32.patch | 169 +++++++++++ ...ninitialized-err-in-handle_extension.patch | 45 +++ ...st_IP_AT_SYSCALL-in-handle_extension.patch | 31 ++ ...90x-Minor-fixes-in-extension-s390x.c.patch | 66 ++++ ...4-gbserver_tests-failures-in-aarch64.patch | 38 +++ ...-regtest-reallocarray-needs-malloc.h.patch | 56 ++++ valgrind.spec | 29 +- 12 files changed, 1063 insertions(+), 1 deletion(-) create mode 100644 0001-Prepare-NEWS-for-branch-3.23-fixes.patch create mode 100644 0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch create mode 100644 0003-Bug-486293-memccpy-false-positives.patch create mode 100644 0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch create mode 100644 0005-aarch64-frinta-and-frinta-vector-instructions.patch create mode 100644 0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch create mode 100644 0007-Fix-uninitialized-err-in-handle_extension.patch create mode 100644 0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch create mode 100644 0009-s390x-Minor-fixes-in-extension-s390x.c.patch create mode 100644 0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch create mode 100644 0011-Linux-regtest-reallocarray-needs-malloc.h.patch diff --git a/0001-Prepare-NEWS-for-branch-3.23-fixes.patch b/0001-Prepare-NEWS-for-branch-3.23-fixes.patch new file mode 100644 index 0000000..327fb04 --- /dev/null +++ b/0001-Prepare-NEWS-for-branch-3.23-fixes.patch @@ -0,0 +1,31 @@ +From 2afcd730a10d61c318289bc4c39c42eebd4b35a6 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Mon, 29 Apr 2024 15:15:46 +0200 +Subject: [PATCH 01/11] Prepare NEWS for branch 3.23 fixes + +--- + NEWS | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/NEWS b/NEWS +index 11c67410fb6f..8bdd3753f7bb 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,14 @@ ++Branch 3.23 ++~~~~~~~~~~~ ++ ++* ==================== FIXED BUGS ==================== ++ ++The following bugs have been fixed or resolved on this branch. ++ ++To see details of a given bug, visit ++ https://bugs.kde.org/show_bug.cgi?id=XXXXXX ++where XXXXXX is the bug number as listed above. ++ + Release 3.23.0 (26 Apr 2024) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-- +2.45.2 + diff --git a/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch b/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch new file mode 100644 index 0000000..b8ab417 --- /dev/null +++ b/0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch @@ -0,0 +1,83 @@ +From 2e26af756d69c53026bf2d6d61589f754796340d Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sat, 27 Apr 2024 13:07:07 +0200 +Subject: [PATCH 02/11] 486180 [MIPS] 'VexGuestArchState' has no member named + 'guest_IP_AT_SYSCALL' + +(cherry picked from commit 7214886886bce9029f325214156c02dcfff760d5) +--- + NEWS | 2 ++ + VEX/priv/guest_mips_helpers.c | 4 ++++ + VEX/pub/libvex_guest_mips32.h | 6 +++--- + VEX/pub/libvex_guest_mips64.h | 2 ++ + 4 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/NEWS b/NEWS +index 8bdd3753f7bb..c40e00cce46b 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,8 @@ Branch 3.23 + + The following bugs have been fixed or resolved on this branch. + ++486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' ++ + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX + where XXXXXX is the bug number as listed above. +diff --git a/VEX/priv/guest_mips_helpers.c b/VEX/priv/guest_mips_helpers.c +index 74cfb9c34caa..79197378cc74 100644 +--- a/VEX/priv/guest_mips_helpers.c ++++ b/VEX/priv/guest_mips_helpers.c +@@ -187,6 +187,8 @@ void LibVEX_GuestMIPS32_initialise( /*OUT*/ VexGuestMIPS32State * vex_state) + vex_state->guest_w1.w64[1] = 0; + vex_state->guest_w2.w64[0] = 0; + vex_state->guest_w2.w64[1] = 0; ++ ++ vex_state->guest_IP_AT_SYSCALL = 0; + } + + void LibVEX_GuestMIPS64_initialise ( /*OUT*/ VexGuestMIPS64State * vex_state ) +@@ -294,6 +296,8 @@ void LibVEX_GuestMIPS64_initialise ( /*OUT*/ VexGuestMIPS64State * vex_state ) + vex_state->guest_LLaddr = 0xFFFFFFFFFFFFFFFFULL; + vex_state->guest_LLdata = 0; + ++ vex_state->guest_IP_AT_SYSCALL = 0; ++ + vex_state->guest_MSACSR = 0; + } + +diff --git a/VEX/pub/libvex_guest_mips32.h b/VEX/pub/libvex_guest_mips32.h +index 214f63cdbe8c..e769819d75ae 100644 +--- a/VEX/pub/libvex_guest_mips32.h ++++ b/VEX/pub/libvex_guest_mips32.h +@@ -188,10 +188,10 @@ typedef + + /* 1016 */ UInt guest_MSACSR; + +- /* 1020 */ UInt _padding3; ++ /* 1020 */ UInt guest_IP_AT_SYSCALL; + +- /* 1020 */ ULong guest_LLdata64; +- /* 1028 */ ULong _padding4; ++ /* 1024 */ ULong guest_LLdata64; ++ /* 1032 */ ULong _padding3; + } VexGuestMIPS32State; + /*---------------------------------------------------------------*/ + /*--- Utility functions for MIPS32 guest stuff. ---*/ +diff --git a/VEX/pub/libvex_guest_mips64.h b/VEX/pub/libvex_guest_mips64.h +index 657fe6fa3343..a953f0ab86a2 100644 +--- a/VEX/pub/libvex_guest_mips64.h ++++ b/VEX/pub/libvex_guest_mips64.h +@@ -184,6 +184,8 @@ typedef + /* 1144 */ UInt guest_MSACSR; + + /* 1148 */ UInt _padding2; ++ /* 1152 */ ULong guest_IP_AT_SYSCALL; ++ /* 1160 */ ULong _padding3; + + } VexGuestMIPS64State; + +-- +2.45.2 + diff --git a/0003-Bug-486293-memccpy-false-positives.patch b/0003-Bug-486293-memccpy-false-positives.patch new file mode 100644 index 0000000..10c7d5e --- /dev/null +++ b/0003-Bug-486293-memccpy-false-positives.patch @@ -0,0 +1,96 @@ +From 14141bb4a6ea528b4c0b9295aa64348f7a675735 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Wed, 1 May 2024 09:24:14 +0200 +Subject: [PATCH 03/11] Bug 486293 - memccpy false positives + +(cherry picked from commit 805c020c6e5161966e6eb0099ebe937a510cea9e) +--- + NEWS | 1 + + memcheck/tests/memccpy2.c | 20 ++++++++++++++++++++ + memcheck/tests/memccpy2.stderr.exp | 4 ++-- + shared/vg_replace_strmem.c | 4 ++-- + 4 files changed, 25 insertions(+), 4 deletions(-) + +diff --git a/NEWS b/NEWS +index c40e00cce46b..f674191a286a 100644 +--- a/NEWS ++++ b/NEWS +@@ -6,6 +6,7 @@ Branch 3.23 + The following bugs have been fixed or resolved on this branch. + + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' ++486293 memccpy false positives + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/memcheck/tests/memccpy2.c b/memcheck/tests/memccpy2.c +index a5a1dfc9f0af..947324581715 100644 +--- a/memcheck/tests/memccpy2.c ++++ b/memcheck/tests/memccpy2.c +@@ -1,6 +1,8 @@ + #include + #include + #include ++#include ++#include + + int main(void) + { +@@ -9,5 +11,23 @@ int main(void) + memccpy(astring+10, astring, '#', len-10); + sprintf(astring, "this is a string # with something to seek"); + memccpy(astring, astring+10, '#', len); ++ ++ sprintf(astring, "this is a string # with something to seek"); ++ /* ++ * space is earlier than len, no overlap ++ * "this " gets copied (up to and including the first ' ') ++ * and it overwrites the destination starting with the 's' of "string" ++ * so res will point to the 'g' of "string" ++ */ ++ char* res = memccpy(astring+10, astring, ' ', len-10); ++ assert(res && *res == 'g'); ++ sprintf(astring, "this is a string # with something to seek"); ++ /* length is 0, nothing copied, returns NULL */ ++ res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0); ++ assert(NULL == res); ++ /* 'z' not found so 20 bytes copied, returns NULL */ ++ res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20); ++ assert(NULL == res); ++ free(astring); + } + +diff --git a/memcheck/tests/memccpy2.stderr.exp b/memcheck/tests/memccpy2.stderr.exp +index 0132ef06c56a..240ce925c182 100644 +--- a/memcheck/tests/memccpy2.stderr.exp ++++ b/memcheck/tests/memccpy2.stderr.exp +@@ -1,8 +1,8 @@ + Source and destination overlap in memccpy(0x........, 0x........, 31) + at 0x........: memccpy (vg_replace_strmem.c:...) +- by 0x........: main (memccpy2.c:9) ++ by 0x........: main (memccpy2.c:11) + + Source and destination overlap in memccpy(0x........, 0x........, 41) + at 0x........: memccpy (vg_replace_strmem.c:...) +- by 0x........: main (memccpy2.c:11) ++ by 0x........: main (memccpy2.c:13) + +diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c +index 737abbf67898..ae13a2a5f87a 100644 +--- a/shared/vg_replace_strmem.c ++++ b/shared/vg_replace_strmem.c +@@ -2364,9 +2364,9 @@ static inline void my_exit ( int x ) + \ + while (i-- > 0) \ + if ((*d++ = *s++) == x) { \ +- SizeT srclen = (i < len) ? i : len; \ ++ SizeT srclen = len - i; \ + RECORD_COPY(srclen); \ +- if (is_overlap(dst, src, srclen, srclen)) \ ++ if (is_overlap(dst, src, len, srclen)) \ + RECORD_OVERLAP_ERROR("memccpy", dst, src, len); \ + return d; \ + } \ +-- +2.45.2 + diff --git a/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch b/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch new file mode 100644 index 0000000..0b34908 --- /dev/null +++ b/0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch @@ -0,0 +1,138 @@ +From 3795a011eeb9730cda9f0beadce70aab8aa71e68 Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sat, 4 May 2024 15:03:11 +0200 +Subject: [PATCH 04/11] Bug 486569 - linux inotify_init syscall wrapper missing + POST entry in syscall_table + +(cherry picked from commit b38115cc6087f30f872c533f93c7c31a6d73eb24) +--- + NEWS | 1 + + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-arm-linux.c | 2 +- + coregrind/m_syswrap/syswrap-mips32-linux.c | 2 +- + coregrind/m_syswrap/syswrap-mips64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 +- + coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 +- + coregrind/m_syswrap/syswrap-s390x-linux.c | 2 +- + coregrind/m_syswrap/syswrap-x86-linux.c | 2 +- + 9 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/NEWS b/NEWS +index f674191a286a..b65f9206679b 100644 +--- a/NEWS ++++ b/NEWS +@@ -7,6 +7,7 @@ The following bugs have been fixed or resolved on this branch. + + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives ++486569 linux inotify_init syscall wrapper missing POST entry in syscall_table + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c +index a59e01826ca2..86a47d9c2811 100644 +--- a/coregrind/m_syswrap/syswrap-amd64-linux.c ++++ b/coregrind/m_syswrap/syswrap-amd64-linux.c +@@ -773,7 +773,7 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_keyctl, sys_keyctl), // 250 + LINX_(__NR_ioprio_set, sys_ioprio_set), // 251 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 252 +- LINX_(__NR_inotify_init, sys_inotify_init), // 253 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 253 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 254 + + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 255 +diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c +index 217b1c49dc9d..7b536e52cb2e 100644 +--- a/coregrind/m_syswrap/syswrap-arm-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm-linux.c +@@ -922,7 +922,7 @@ static SyscallTableEntry syscall_main_table[] = { + // LINX_(__NR_ioprio_set, sys_ioprio_set), // 289 + + // LINX_(__NR_ioprio_get, sys_ioprio_get), // 290 +- LINX_(__NR_inotify_init, sys_inotify_init), // 291 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 291 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 292 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 293 + // LINX_(__NR_migrate_pages, sys_migrate_pages), // 294 +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index 3f991da0a18d..e2f499eb80f8 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1037,7 +1037,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY (__NR_mq_timedreceive, sys_mq_timedreceive), // 274 + LINX_ (__NR_mq_notify, sys_mq_notify), // 275 + LINXY (__NR_mq_getsetattr, sys_mq_getsetattr), // 276 +- LINX_ (__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY (__NR_inotify_init, sys_inotify_init), // 275 + LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + LINXY (__NR_waitid, sys_waitid), // 278 +diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c +index 9899a21cfa78..24f2bcc93956 100644 +--- a/coregrind/m_syswrap/syswrap-mips64-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips64-linux.c +@@ -759,7 +759,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_ (__NR_request_key, sys_request_key), + LINXY (__NR_keyctl, sys_keyctl), + PLAX_ (__NR_set_thread_area, sys_set_thread_area), +- LINX_ (__NR_inotify_init, sys_inotify_init), ++ LINXY (__NR_inotify_init, sys_inotify_init), + LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch), + LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch), + LINXY (__NR_openat, sys_openat), +diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c +index 0aabfbb179ec..74ba68564cd8 100644 +--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c +@@ -944,7 +944,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 273 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 274 + +- LINX_(__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 275 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + PLAXY(__NR_spu_run, sys_spu_run), // 278 +diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c +index 35e3f8ec4ee4..4609e10df363 100644 +--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c ++++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c +@@ -928,7 +928,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 273 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 274 + +- LINX_(__NR_inotify_init, sys_inotify_init), // 275 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 275 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 276 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277 + +diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c +index f941bdd1907a..9ed2fa46888f 100644 +--- a/coregrind/m_syswrap/syswrap-s390x-linux.c ++++ b/coregrind/m_syswrap/syswrap-s390x-linux.c +@@ -751,7 +751,7 @@ static SyscallTableEntry syscall_table[] = { + LINXY(__NR_waitid, sys_waitid), // 281 + LINX_(__NR_ioprio_set, sys_ioprio_set), // 282 + LINX_(__NR_ioprio_get, sys_ioprio_get), // 283 +- LINX_(__NR_inotify_init, sys_inotify_init), // 284 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 284 + + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 285 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 286 +diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c +index c6cf682e797c..ea930bafe3ec 100644 +--- a/coregrind/m_syswrap/syswrap-x86-linux.c ++++ b/coregrind/m_syswrap/syswrap-x86-linux.c +@@ -1508,7 +1508,7 @@ static SyscallTableEntry syscall_table[] = { + LINX_(__NR_ioprio_set, sys_ioprio_set), // 289 + + LINX_(__NR_ioprio_get, sys_ioprio_get), // 290 +- LINX_(__NR_inotify_init, sys_inotify_init), // 291 ++ LINXY(__NR_inotify_init, sys_inotify_init), // 291 + LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 292 + LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 293 + // LINX_(__NR_migrate_pages, sys_migrate_pages), // 294 +-- +2.45.2 + diff --git a/0005-aarch64-frinta-and-frinta-vector-instructions.patch b/0005-aarch64-frinta-and-frinta-vector-instructions.patch new file mode 100644 index 0000000..9a9c7d9 --- /dev/null +++ b/0005-aarch64-frinta-and-frinta-vector-instructions.patch @@ -0,0 +1,282 @@ +From f5d1c336e9276dd5947ef94c9831d9d53673b75b Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Thu, 9 May 2024 21:01:52 +0200 +Subject: [PATCH 05/11] aarch64 frinta and frinta vector instructions + +The initial fix for Bug 484426 only corrected frinta and frintn +scalar instructions. This adds support for the vector variants. + +(cherry picked from commit 7b66a5b58219ac1a4865da8e371edbdb8d765f32) +--- + NEWS | 1 + + VEX/priv/guest_arm64_toIR.c | 47 ++++++---- + none/tests/arm64/frinta_frintn.cpp | 141 +++++++++++++++++++++++++++++ + 3 files changed, 171 insertions(+), 18 deletions(-) + +diff --git a/NEWS b/NEWS +index b65f9206679b..adb52169dd87 100644 +--- a/NEWS ++++ b/NEWS +@@ -8,6 +8,7 @@ The following bugs have been fixed or resolved on this branch. + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table ++n-i-bz aarch64 frinta and frinta vector instructions + + To see details of a given bug, visit + https://bugs.kde.org/show_bug.cgi?id=XXXXXX +diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c +index c7e395b4b63d..27d945d6328d 100644 +--- a/VEX/priv/guest_arm64_toIR.c ++++ b/VEX/priv/guest_arm64_toIR.c +@@ -13821,46 +13821,57 @@ Bool dis_AdvSIMD_two_reg_misc(/*MB_OUT*/DisResult* dres, UInt insn) + /* -------- 1,1x,11000 (apparently unassigned) (7) -------- */ + /* -------- 1,1x,11001 FRINTI 2d_2d, 4s_4s, 2s_2s (8) -------- */ + /* rm plan: +- FRINTN: tieeven -- !! FIXME KLUDGED !! ++ FRINTN: tieeven + FRINTM: -inf + FRINTP: +inf + FRINTZ: zero +- FRINTA: tieaway -- !! FIXME KLUDGED !! ++ FRINTA: tieaway + FRINTX: per FPCR + "exact = TRUE" + FRINTI: per FPCR + */ + Bool isD = (size & 1) == 1; + if (bitQ == 0 && isD) return False; // implied 1d case + +- IRTemp irrmRM = mk_get_IR_rounding_mode(); +- +- UChar ch = '?'; +- IRTemp irrm = newTemp(Ity_I32); ++ UChar ch = '?'; ++ IROp op = isD ? Iop_RoundF64toInt : Iop_RoundF32toInt; ++ Bool isBinop = True; ++ IRExpr* irrmE = NULL; + switch (ix) { +- case 1: ch = 'n'; assign(irrm, mkU32(Irrm_NEAREST)); break; +- case 2: ch = 'm'; assign(irrm, mkU32(Irrm_NegINF)); break; +- case 3: ch = 'p'; assign(irrm, mkU32(Irrm_PosINF)); break; +- case 4: ch = 'z'; assign(irrm, mkU32(Irrm_ZERO)); break; ++ case 1: ch = 'n'; isBinop = False; op = isD ? Iop_RoundF64toIntE : Iop_RoundF32toIntE; break; ++ case 2: ch = 'm'; irrmE = mkU32(Irrm_NegINF); break; ++ case 3: ch = 'p'; irrmE = mkU32(Irrm_PosINF); break; ++ case 4: ch = 'z'; irrmE = mkU32(Irrm_ZERO); break; + // The following is a kludge. Should be: Irrm_NEAREST_TIE_AWAY_0 +- case 5: ch = 'a'; assign(irrm, mkU32(Irrm_NEAREST)); break; ++ case 5: ch = 'a'; isBinop = False; op = isD ? Iop_RoundF64toIntA0 : Iop_RoundF32toIntA0; break; + // I am unsure about the following, due to the "integral exact" + // description in the manual. What does it mean? (frintx, that is) +- case 6: ch = 'x'; assign(irrm, mkexpr(irrmRM)); break; +- case 8: ch = 'i'; assign(irrm, mkexpr(irrmRM)); break; ++ case 6: ch = 'x'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; ++ case 8: ch = 'i'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; + default: vassert(0); + } + +- IROp opRND = isD ? Iop_RoundF64toInt : Iop_RoundF32toInt; + if (isD) { + for (UInt i = 0; i < 2; i++) { +- putQRegLane(dd, i, binop(opRND, mkexpr(irrm), +- getQRegLane(nn, i, Ity_F64))); ++ if (isBinop) { ++ IRTemp irrm = newTemp(Ity_I32); ++ assign(irrm, irrmE); ++ putQRegLane(dd, i, binop(op, mkexpr(irrm), ++ getQRegLane(nn, i, Ity_F64))); ++ } else { ++ putQRegLane(dd, i, unop(op, getQRegLane(nn, i, Ity_F64))); ++ } + } + } else { + UInt n = bitQ==1 ? 4 : 2; + for (UInt i = 0; i < n; i++) { +- putQRegLane(dd, i, binop(opRND, mkexpr(irrm), +- getQRegLane(nn, i, Ity_F32))); ++ if (isBinop) { ++ IRTemp irrm = newTemp(Ity_I32); ++ assign(irrm, irrmE); ++ putQRegLane(dd, i, binop(op, mkexpr(irrm), ++ getQRegLane(nn, i, Ity_F32))); ++ } else { ++ putQRegLane(dd, i, unop(op, getQRegLane(nn, i, Ity_F32))); ++ } + } + if (bitQ == 0) + putQRegLane(dd, 1, mkU64(0)); // zero out lanes 2 and 3 +diff --git a/none/tests/arm64/frinta_frintn.cpp b/none/tests/arm64/frinta_frintn.cpp +index 8e13761eb966..c0803688f698 100644 +--- a/none/tests/arm64/frinta_frintn.cpp ++++ b/none/tests/arm64/frinta_frintn.cpp +@@ -36,6 +36,55 @@ void test_frinta(T input, T expected) + } + } + ++template ++void test_frinta_fullvec(T* input, T* expected) ++{ ++ T result[2*sizeof(double)/sizeof(T)]; ++ T* rp = result; ++ if constexpr (std::is_same_v == true) ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frinta v22.2d, v23.2d;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ } ++ else ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frinta v22.4s, v23.4s;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ assert(result[2] == expected[2]); ++ assert(result[3] == expected[3]); ++ } ++} ++ ++void test_frinta_halfvec(float* input, float* expected) ++{ ++ float result[2]; ++ float* rp = result; ++ __asm__ __volatile__( ++ "ldr d23, [%1];\n" ++ "frinta v22.2s, v23.2s;\n" ++ "str d22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++} ++ ++ + template + void test_frintn(T input, T expected) + { +@@ -66,6 +115,54 @@ void test_frintn(T input, T expected) + } + } + ++template ++void test_frintn_fullvec(T* input, T* expected) ++{ ++ T result[2*sizeof(double)/sizeof(T)]; ++ T* rp = result; ++ if constexpr (std::is_same_v == true) ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frintn v22.2d, v23.2d;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ } ++ else ++ { ++ __asm__ __volatile__( ++ "ldr q23, [%1];\n" ++ "frintn v22.4s, v23.4s;\n" ++ "str q22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++ assert(result[2] == expected[2]); ++ assert(result[3] == expected[3]); ++ } ++} ++ ++void test_frintn_halfvec(float* input, float* expected) ++{ ++ float result[2]; ++ float* rp = result; ++ __asm__ __volatile__( ++ "ldr d23, [%1];\n" ++ "frintn v22.2s, v23.2s;\n" ++ "str d22, [%0];\n" ++ : "+rm" (rp) ++ : "r" (input) ++ : "memory", "v22", "v23"); ++ assert(result[0] == expected[0]); ++ assert(result[1] == expected[1]); ++} ++ + int main() + { + // round "away from zero" +@@ -78,6 +175,36 @@ int main() + test_frinta(-1.5F, -2.0F); + test_frinta(-2.5F, -3.0F); + ++ double in1[] = {1.5, 1.5}; ++ double out1[] = {2.0, 2,0}; ++ test_frinta_fullvec(in1, out1); ++ double in2[] = {2.5, 2.5}; ++ double out2[] = {3.0, 3,0}; ++ test_frinta_fullvec(in2, out2); ++ double in3[] = {-1.5, -1.5}; ++ double out3[] = {-2.0, -2,0}; ++ test_frinta_fullvec(in3, out3); ++ double in4[] = {-2.5, -2.5}; ++ double out4[] = {-3.0, -3,0}; ++ test_frinta_fullvec(in4, out4); ++ ++ float in1f[] = {1.5F, 1.5F, 1.5F, 1.5F}; ++ float out1f[] = {2.0F, 2.0F, 2.0F, 2.0F}; ++ test_frinta_fullvec(in1f, out1f); ++ test_frinta_halfvec(in1f, out1f); ++ float in2f[] = {2.5F, 2.5F, 2.5F, 2.5F}; ++ float out2f[] = {3.0F, 3.0F, 3.0F, 3.0F}; ++ test_frinta_fullvec(in2f, out2f); ++ test_frinta_halfvec(in2f, out2f); ++ float in3f[] = {-1.5F, -1.5F, -1.5F, -1.5F}; ++ float out3f[] = {-2.0F, -2.0F, -2.0F, -2.0F}; ++ test_frinta_fullvec(in3f, out3f); ++ test_frinta_halfvec(in3f, out3f); ++ float in4f[] = {-2.5F, -2.5F, -2.5F, -2.5F}; ++ float out4f[] = {-3.0F, -3.0F, -3.0F, -3.0F}; ++ test_frinta_fullvec(in4f, out4f); ++ test_frinta_halfvec(in4f, out4f); ++ + // round "to even" + test_frintn(1.5, 2.0); + test_frintn(2.5, 2.0); +@@ -87,5 +214,19 @@ int main() + test_frintn(2.5F, 2.0F); + test_frintn(-1.5F, -2.0F); + test_frintn(-2.5F, -2.0F); ++ ++ test_frintn_fullvec(in1, out1); ++ test_frintn_fullvec(in2, out1); ++ test_frintn_fullvec(in3, out3); ++ test_frintn_fullvec(in4, out3); ++ ++ test_frintn_fullvec(in1f, out1f); ++ test_frintn_halfvec(in1f, out1f); ++ test_frintn_fullvec(in2f, out1f); ++ test_frintn_halfvec(in2f, out1f); ++ test_frintn_fullvec(in3f, out3f); ++ test_frintn_halfvec(in3f, out3f); ++ test_frintn_fullvec(in4f, out3f); ++ test_frintn_halfvec(in4f, out3f); + } + +-- +2.45.2 + diff --git a/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch b/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch new file mode 100644 index 0000000..d393c9c --- /dev/null +++ b/0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch @@ -0,0 +1,169 @@ +From 726f930355ca74b4aa4c656979224c9b7a706244 Mon Sep 17 00:00:00 2001 +From: Aleksandar Rikalo +Date: Fri, 10 May 2024 17:59:28 +0200 +Subject: [PATCH 06/11] mips: skip using shared syscall numbers for mips32 + +mips does not use shared syscall numbers, so we can not use +vki-scnums-shared-linux.h. + +This partially fixes KDE #444781. + +Signed-off-by: Hauke Mehrtens +Signed-off-by: Aleksandar Rikalo +(cherry picked from commit 54d6ad3348fb50f5b972fe9c05d0d8757bfe73ba) +--- + coregrind/m_syswrap/syswrap-mips32-linux.c | 1 + + include/pub_tool_vkiscnums_asm.h | 2 - + include/vki/vki-scnums-mips32-linux.h | 105 ++++++++++++++++----- + 3 files changed, 83 insertions(+), 25 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c +index e2f499eb80f8..e3498cd96f9b 100644 +--- a/coregrind/m_syswrap/syswrap-mips32-linux.c ++++ b/coregrind/m_syswrap/syswrap-mips32-linux.c +@@ -1110,6 +1110,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINX_ (__NR_pwritev2, sys_pwritev2), // 362 + //.. + LINXY(__NR_statx, sys_statx), // 366 ++ GENX_(__NR_rseq, sys_ni_syscall), // 367 + + LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403 + LINX_(__NR_clock_settime64, sys_clock_settime64), // 404 +diff --git a/include/pub_tool_vkiscnums_asm.h b/include/pub_tool_vkiscnums_asm.h +index 8a26f834a93e..d3d7dc19be9d 100644 +--- a/include/pub_tool_vkiscnums_asm.h ++++ b/include/pub_tool_vkiscnums_asm.h +@@ -63,8 +63,6 @@ + # include "vki/vki-scnums-arm64-linux.h" + + #elif defined(VGP_mips32_linux) +-# include "vki/vki-scnums-shared-linux.h" +-# include "vki/vki-scnums-32bit-linux.h" + # include "vki/vki-scnums-mips32-linux.h" + + #elif defined(VGP_nanomips_linux) +diff --git a/include/vki/vki-scnums-mips32-linux.h b/include/vki/vki-scnums-mips32-linux.h +index e452a2e6c8d0..d4f8de15aac7 100644 +--- a/include/vki/vki-scnums-mips32-linux.h ++++ b/include/vki/vki-scnums-mips32-linux.h +@@ -380,35 +380,94 @@ + #define __NR_setns (__NR_Linux + 343) + #define __NR_process_vm_readv (__NR_Linux + 345) + #define __NR_process_vm_writev (__NR_Linux + 346) +-#define __NR_kcmp (__NR_Linux + 347) +-#define __NR_finit_module (__NR_Linux + 348) +-#define __NR_sched_setattr (__NR_Linux + 349) +-#define __NR_sched_getattr (__NR_Linux + 350) +-#define __NR_renameat2 (__NR_Linux + 351) +-#define __NR_seccomp (__NR_Linux + 352) +-#define __NR_getrandom (__NR_Linux + 353) +-#define __NR_memfd_create (__NR_Linux + 354) +-#define __NR_bpf (__NR_Linux + 355) +-#define __NR_execveat (__NR_Linux + 356) +-#define __NR_userfaultfd (__NR_Linux + 357) +-#define __NR_membarrier (__NR_Linux + 358) +-#define __NR_mlock2 (__NR_Linux + 359) +-#define __NR_copy_file_range (__NR_Linux + 360) +-#define __NR_preadv2 (__NR_Linux + 361) +-#define __NR_pwritev2 (__NR_Linux + 362) +-#define __NR_pkey_mprotect (__NR_Linux + 363) +-#define __NR_pkey_alloc (__NR_Linux + 364) +-#define __NR_pkey_free (__NR_Linux + 365) +-#define __NR_statx (__NR_Linux + 366) +- ++#define __NR_kcmp (__NR_Linux + 347) ++#define __NR_finit_module (__NR_Linux + 348) ++#define __NR_sched_setattr (__NR_Linux + 349) ++#define __NR_sched_getattr (__NR_Linux + 350) ++#define __NR_renameat2 (__NR_Linux + 351) ++#define __NR_seccomp (__NR_Linux + 352) ++#define __NR_getrandom (__NR_Linux + 353) ++#define __NR_memfd_create (__NR_Linux + 354) ++#define __NR_bpf (__NR_Linux + 355) ++#define __NR_execveat (__NR_Linux + 356) ++#define __NR_userfaultfd (__NR_Linux + 357) ++#define __NR_membarrier (__NR_Linux + 358) ++#define __NR_mlock2 (__NR_Linux + 359) ++#define __NR_copy_file_range (__NR_Linux + 360) ++#define __NR_preadv2 (__NR_Linux + 361) ++#define __NR_pwritev2 (__NR_Linux + 362) ++#define __NR_pkey_mprotect (__NR_Linux + 363) ++#define __NR_pkey_alloc (__NR_Linux + 364) ++#define __NR_pkey_free (__NR_Linux + 365) ++#define __NR_statx (__NR_Linux + 366) ++#define __NR_rseq (__NR_Linux + 367) ++#define __NR_io_pgetevents (__NR_Linux + 368) ++#define __NR_semget (__NR_Linux + 393) ++#define __NR_semctl (__NR_Linux + 394) ++#define __NR_shmget (__NR_Linux + 395) ++#define __NR_shmctl (__NR_Linux + 396) ++#define __NR_shmat (__NR_Linux + 397) ++#define __NR_shmdt (__NR_Linux + 398) ++#define __NR_msgget (__NR_Linux + 399) ++#define __NR_msgsnd (__NR_Linux + 400) ++#define __NR_msgrcv (__NR_Linux + 401) ++#define __NR_msgctl (__NR_Linux + 402) ++#define __NR_clock_gettime64 (__NR_Linux + 403) ++#define __NR_clock_settime64 (__NR_Linux + 404) ++#define __NR_clock_adjtime64 (__NR_Linux + 405) ++#define __NR_clock_getres_time64 (__NR_Linux + 406) ++#define __NR_clock_nanosleep_time64 (__NR_Linux + 407) ++#define __NR_timer_gettime64 (__NR_Linux + 408) ++#define __NR_timer_settime64 (__NR_Linux + 409) ++#define __NR_timerfd_gettime64 (__NR_Linux + 410) ++#define __NR_timerfd_settime64 (__NR_Linux + 411) ++#define __NR_utimensat_time64 (__NR_Linux + 412) ++#define __NR_pselect6_time64 (__NR_Linux + 413) ++#define __NR_ppoll_time64 (__NR_Linux + 414) ++#define __NR_io_pgetevents_time64 (__NR_Linux + 416) ++#define __NR_recvmmsg_time64 (__NR_Linux + 417) ++#define __NR_mq_timedsend_time64 (__NR_Linux + 418) ++#define __NR_mq_timedreceive_time64 (__NR_Linux + 419) ++#define __NR_semtimedop_time64 (__NR_Linux + 420) ++#define __NR_rt_sigtimedwait_time64 (__NR_Linux + 421) ++#define __NR_futex_time64 (__NR_Linux + 422) ++#define __NR_sched_rr_get_interval_time64 (__NR_Linux + 423) ++#define __NR_pidfd_send_signal (__NR_Linux + 424) ++#define __NR_io_uring_setup (__NR_Linux + 425) ++#define __NR_io_uring_enter (__NR_Linux + 426) ++#define __NR_io_uring_register (__NR_Linux + 427) ++#define __NR_open_tree (__NR_Linux + 428) ++#define __NR_move_mount (__NR_Linux + 429) ++#define __NR_fsopen (__NR_Linux + 430) ++#define __NR_fsconfig (__NR_Linux + 431) ++#define __NR_fsmount (__NR_Linux + 432) ++#define __NR_fspick (__NR_Linux + 433) ++#define __NR_pidfd_open (__NR_Linux + 434) ++#define __NR_clone3 (__NR_Linux + 435) ++#define __NR_close_range (__NR_Linux + 436) ++#define __NR_openat2 (__NR_Linux + 437) ++#define __NR_pidfd_getfd (__NR_Linux + 438) ++#define __NR_faccessat2 (__NR_Linux + 439) ++#define __NR_process_madvise (__NR_Linux + 440) ++#define __NR_epoll_pwait2 (__NR_Linux + 441) ++#define __NR_mount_setattr (__NR_Linux + 442) ++#define __NR_quotactl_fd (__NR_Linux + 443) ++#define __NR_landlock_create_ruleset (__NR_Linux + 444) ++#define __NR_landlock_add_rule (__NR_Linux + 445) ++#define __NR_landlock_restrict_self (__NR_Linux + 446) ++#define __NR_process_mrelease (__NR_Linux + 448) ++#define __NR_futex_waitv (__NR_Linux + 449) ++#define __NR_set_mempolicy_home_node (__NR_Linux + 450) ++#define __NR_cachestat (__NR_Linux + 451) ++#define __NR_fchmodat2 (__NR_Linux + 452) + /* + * Offset of the last Linux o32 flavoured syscall + */ +-#define __NR_Linux_syscalls 366 ++#define __NR_Linux_syscalls 366 + + + #define __NR_O32_Linux 4000 +-#define __NR_O32_Linux_syscalls 366 ++#define __NR_O32_Linux_syscalls 366 + + + #endif /* __VKI_SCNUMS_MIPS32_LINUX_H */ +-- +2.45.2 + diff --git a/0007-Fix-uninitialized-err-in-handle_extension.patch b/0007-Fix-uninitialized-err-in-handle_extension.patch new file mode 100644 index 0000000..84efe6f --- /dev/null +++ b/0007-Fix-uninitialized-err-in-handle_extension.patch @@ -0,0 +1,45 @@ +From 468933f9765449c1e353c38e88555a2f1603b9ce Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 07/11] Fix uninitialized `err' in handle_extension() + +In handle_extension(), in the case of a second return from SCHEDSETJMP the +variable `err' would be used uninitialized. Fix this by avoiding any +access to `err' in this case. + +(cherry picked from commit 94c2e5c6be23c6323f24deacdad5f98fb9f0b1c2) +--- + coregrind/m_scheduler/scheduler.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c +index fc8cf7c9cb1d..29751bb28283 100644 +--- a/coregrind/m_scheduler/scheduler.c ++++ b/coregrind/m_scheduler/scheduler.c +@@ -1233,7 +1233,10 @@ static void handle_extension(ThreadId tid) + SCHEDSETJMP(tid, jumped, err = VG_(client_extension)(tid)); + vg_assert(VG_(is_running_thread)(tid)); + +- if (err != ExtErr_OK) { ++ if (jumped != (UWord)0) { ++ block_signals(); ++ VG_(poll_signals)(tid); ++ } else if (err != ExtErr_OK) { + ThreadState* tst = VG_(get_ThreadState)(tid); + Addr addr = tst->arch.vex.guest_IP_AT_SYSCALL; + switch (err) { +@@ -1244,11 +1247,6 @@ static void handle_extension(ThreadId tid) + VG_(core_panic)("scheduler: bad return code from extension"); + } + } +- +- if (jumped != (UWord)0) { +- block_signals(); +- VG_(poll_signals)(tid); +- } + } + + /* tid just requested a jump to the noredir version of its current +-- +2.45.2 + diff --git a/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch b/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch new file mode 100644 index 0000000..8e5f4ae --- /dev/null +++ b/0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch @@ -0,0 +1,31 @@ +From 40b68ae8d6c869f098493e3a31d66f09170592e3 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 08/11] Avoid use of guest_IP_AT_SYSCALL in handle_extension() + +The guest state field guest_IP_AT_SYSCALL is referenced in +handle_extension(), even though it may not be defined by all +architectures. Avoid its use altogether. + +(cherry picked from commit 16249b21456d681b5d98400287b8dbd926050c75) +--- + coregrind/m_scheduler/scheduler.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c +index 29751bb28283..cc8d070b7930 100644 +--- a/coregrind/m_scheduler/scheduler.c ++++ b/coregrind/m_scheduler/scheduler.c +@@ -1237,8 +1237,7 @@ static void handle_extension(ThreadId tid) + block_signals(); + VG_(poll_signals)(tid); + } else if (err != ExtErr_OK) { +- ThreadState* tst = VG_(get_ThreadState)(tid); +- Addr addr = tst->arch.vex.guest_IP_AT_SYSCALL; ++ Addr addr = VG_(get_IP)(tid); + switch (err) { + case ExtErr_Illop: + VG_(synth_sigill)(tid, addr); +-- +2.45.2 + diff --git a/0009-s390x-Minor-fixes-in-extension-s390x.c.patch b/0009-s390x-Minor-fixes-in-extension-s390x.c.patch new file mode 100644 index 0000000..3bb1df0 --- /dev/null +++ b/0009-s390x-Minor-fixes-in-extension-s390x.c.patch @@ -0,0 +1,66 @@ +From ebe5fd9c0aae97767a4418d2f26f3281065b3e6a Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Wed, 15 May 2024 14:32:42 +0200 +Subject: [PATCH 09/11] s390x: Minor fixes in extension-s390x.c + +Some tracker names for registers are not consistent with the naming +scheme. Also, there is a dead assignment to orig_addr2 and orig_len2. +Fix both. + +(cherry picked from commit 76f2218924f85547f670969b1a0b59e5200e22ec) +--- + coregrind/m_extension/extension-s390x.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/coregrind/m_extension/extension-s390x.c b/coregrind/m_extension/extension-s390x.c +index fd45c7ee948f..735406e6e4c5 100644 +--- a/coregrind/m_extension/extension-s390x.c ++++ b/coregrind/m_extension/extension-s390x.c +@@ -37,9 +37,9 @@ + + #undef SYSNO + +-#define READ_FUNCTION_CODE(tst) \ ++#define READ_FUNCTION_CODE(tst, extname) \ + ({ \ +- PRE_REG_READ(tst, "func_code", r0, 7, sizeof(UChar)); \ ++ PRE_REG_READ(tst, extname "(func_code)", r0, 7, sizeof(UChar)); \ + tst->arch.vex.guest_r0 & 0xff; \ + }) + +@@ -141,10 +141,10 @@ static enum ExtensionError do_extension_PRNO(ThreadState* tst, ULong variant) + { + UChar r1 = variant & 0xf; + UChar r2 = (variant >> 4) & 0xf; +- UChar func = READ_FUNCTION_CODE(tst); ++ UChar func = READ_FUNCTION_CODE(tst, "PRNO"); + UChar fc = func & 0x7f; + UChar mflag = func & 128; +- ULong parms = READ_GPR(tst, "r1", 1); ++ ULong parms = READ_GPR(tst, "PRNO(r1)", 1); + ULong parms_len; + Int cc = 0; + ULong orig_addr1 = 0, orig_len1 = 0, orig_addr2 = 0, orig_len2 = 0; +@@ -175,8 +175,8 @@ static enum ExtensionError do_extension_PRNO(ThreadState* tst, ULong variant) + PRE_MEM_WRITE(tst, "PRNO(op1)", addr1, len1); + } else { + // Seed operation +- addr2 = orig_addr2 = READ_GPR(tst, "PRNO(op2_addr)", r2); +- len2 = orig_len2 = READ_GPR(tst, "PRNO(op2_len)", r2 + 1); ++ addr2 = READ_GPR(tst, "PRNO(op2_addr)", r2); ++ len2 = READ_GPR(tst, "PRNO(op2_len)", r2 + 1); + PRE_MEM_READ(tst, "PRNO(op2)", addr2, len2); + } + PRE_MEM_WRITE(tst, "PRNO(parms)", parms, parms_len); +@@ -474,7 +474,7 @@ static enum ExtensionError do_extension_NNPA(ThreadState* tst, ULong variant) + { + ULong gpr0 = READ_GPR(tst, "NNPA(r0)", 0); + UChar fc = gpr0 & 0x7f; +- ULong parms_addr = READ_GPR(tst, "r1", 1); ++ ULong parms_addr = READ_GPR(tst, "NNPA(r1)", 1); + Int cc = 0; + ULong parms_len; + +-- +2.45.2 + diff --git a/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch b/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch new file mode 100644 index 0000000..7cc4012 --- /dev/null +++ b/0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch @@ -0,0 +1,38 @@ +From 70d765faa162f2f12e7771db51877649637f2c12 Mon Sep 17 00:00:00 2001 +From: Jesus Checa +Date: Sat, 25 May 2024 12:40:30 +0200 +Subject: [PATCH 10/11] Bug 453044 - gbserver_tests failures in aarch64 + +(cherry picked from commit 790abdf7d3f3df0c968605b68ca765310689b7ce) +--- + NEWS | 1 + + gdbserver_tests/filter_gdb.in | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/NEWS b/NEWS +index adb52169dd87..c2ad6a207d96 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,7 @@ Branch 3.23 + + The following bugs have been fixed or resolved on this branch. + ++453044 gbserver_tests failures in aarch64 + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table +diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in +index 4118063f6bc6..497171732b25 100755 +--- a/gdbserver_tests/filter_gdb.in ++++ b/gdbserver_tests/filter_gdb.in +@@ -152,6 +152,7 @@ s/in _select ()/in syscall .../ + /sysv\/linux\/generic\/select.c/d + /return SYSCALL_CANCEL /d + /r = SYSCALL_CANCEL /d ++/result = SYSCALL_CANCEL /d + + # a more specialised system call select stack trace part + # (on 32 bits, we have an int_80, on 64 bits, directly select) +-- +2.45.2 + diff --git a/0011-Linux-regtest-reallocarray-needs-malloc.h.patch b/0011-Linux-regtest-reallocarray-needs-malloc.h.patch new file mode 100644 index 0000000..85f4415 --- /dev/null +++ b/0011-Linux-regtest-reallocarray-needs-malloc.h.patch @@ -0,0 +1,56 @@ +From 1c2cdfd790b3e26f47e709770bdefd456d83a7cb Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Tue, 4 Jun 2024 12:49:33 +0200 +Subject: [PATCH 11/11] Linux regtest: reallocarray needs malloc.h + +Seen on Rocky 8.9 + +(cherry picked from commit a015ad2e0db40076b4841220c7ab6d6853798936) +--- + memcheck/tests/amd64-linux/reallocarray.c | 1 + + memcheck/tests/amd64-linux/reallocarray.stderr.exp | 8 ++++---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/memcheck/tests/amd64-linux/reallocarray.c b/memcheck/tests/amd64-linux/reallocarray.c +index 8765ca4997cb..ce63b80100da 100644 +--- a/memcheck/tests/amd64-linux/reallocarray.c ++++ b/memcheck/tests/amd64-linux/reallocarray.c +@@ -2,6 +2,7 @@ + #include + #include + #include ++#include + #include "../../memcheck.h" + + int main(void) +diff --git a/memcheck/tests/amd64-linux/reallocarray.stderr.exp b/memcheck/tests/amd64-linux/reallocarray.stderr.exp +index a1c8439cc9ef..20a1c4e8b4f9 100644 +--- a/memcheck/tests/amd64-linux/reallocarray.stderr.exp ++++ b/memcheck/tests/amd64-linux/reallocarray.stderr.exp +@@ -12,19 +12,19 @@ To see them, rerun with: --leak-check=full --show-leak-kinds=all + + realloc() with size 0 + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:13) ++ by 0x........: main (reallocarray.c:14) + Address 0x........ is 0 bytes inside a block of size 40 alloc'd + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:11) ++ by 0x........: main (reallocarray.c:12) + + All heap blocks were freed -- no leaks are possible + + realloc() with size 0 + at 0x........: reallocarray (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:16) ++ by 0x........: main (reallocarray.c:17) + Address 0x........ is 0 bytes inside a block of size 10 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) +- by 0x........: main (reallocarray.c:15) ++ by 0x........: main (reallocarray.c:16) + + All heap blocks were freed -- no leaks are possible + +-- +2.45.2 + diff --git a/valgrind.spec b/valgrind.spec index 58f7dcf..cebb2a1 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.23.0 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: 1 # This ignores licenses that are only found in the test or perf sources @@ -85,6 +85,19 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch # Add some -Wl,z,now. Patch4: valgrind-3.16.0-some-Wl-z-now.patch +# Patches from upstream VALGRIND_3_23_BRANCH +Patch5: 0001-Prepare-NEWS-for-branch-3.23-fixes.patch +Patch6: 0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch +Patch7: 0003-Bug-486293-memccpy-false-positives.patch +Patch8: 0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch +Patch9: 0005-aarch64-frinta-and-frinta-vector-instructions.patch +Patch10: 0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch +Patch11: 0007-Fix-uninitialized-err-in-handle_extension.patch +Patch12: 0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch +Patch13: 0009-s390x-Minor-fixes-in-extension-s390x.c.patch +Patch14: 0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch +Patch15: 0011-Linux-regtest-reallocarray-needs-malloc.h.patch + BuildRequires: make BuildRequires: glibc-devel @@ -223,6 +236,17 @@ Valgrind User Manual for details. %patch -P3 -p1 %patch -P4 -p1 +%patch -P5 -p1 +%patch -P6 -p1 +%patch -P7 -p1 +%patch -P8 -p1 +%patch -P9 -p1 +%patch -P10 -p1 +%patch -P11 -p1 +%patch -P12 -p1 +%patch -P13 -p1 +%patch -P14 -p1 +%patch -P15 -p1 %build # LTO triggers undefined symbols in valgrind. But valgrind has a @@ -439,6 +463,9 @@ echo ===============END TESTING=============== %endif %changelog +* Mon Jun 10 2024 Mark Wielaard - 3.23.0-2 +- Add upstream VALGRIND_3_23_BRANCH patches + * Fri Apr 26 2024 Mark Wielaard - 3.23.0-1 - Upstream 3.23.0 final From 34c38e719f761bdd08f11d8e0056acb5f60cbe53 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 23 Jun 2024 22:16:52 +0200 Subject: [PATCH 52/86] 3.23.0-3 - Add more upstream VALGRIND_3_23_BRANCH patches 0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch 0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch 0014-Close-both-internal-pipe-fds-after-VG_-fork-in-paren.patch 0015-Don-t-allow-programs-calling-fnctl-on-valgrind-s-own.patch --- 0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch | 184 ++++++++++++++ ...created-with-log-file-xml-file-or-lo.patch | 226 ++++++++++++++++++ ...nal-pipe-fds-after-VG_-fork-in-paren.patch | 138 +++++++++++ ...rams-calling-fnctl-on-valgrind-s-own.patch | 58 +++++ valgrind.spec | 17 +- 5 files changed, 622 insertions(+), 1 deletion(-) create mode 100644 0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch create mode 100644 0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch create mode 100644 0014-Close-both-internal-pipe-fds-after-VG_-fork-in-paren.patch create mode 100644 0015-Don-t-allow-programs-calling-fnctl-on-valgrind-s-own.patch diff --git a/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch b/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch new file mode 100644 index 0000000..5254b37 --- /dev/null +++ b/0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch @@ -0,0 +1,184 @@ +From e62c7b4f9ee0a8c20c7211a92ad512f925e9515c Mon Sep 17 00:00:00 2001 +From: Paul Floyd +Date: Sun, 16 Jun 2024 09:25:51 +0200 +Subject: [PATCH 12/15] Bug 487439 - SIGILL in JDK11, JDK17 + +(cherry picked from commit c19d19d34a6dadaf4a9d590f516f813e9cbacdd0) +--- + .gitignore | 1 + + NEWS | 1 + + VEX/priv/guest_amd64_toIR.c | 2 +- + none/tests/amd64/Makefile.am | 3 + + none/tests/amd64/bug487439.cpp | 83 +++++++++++++++++++++++++++ + none/tests/amd64/bug487439.stderr.exp | 0 + none/tests/amd64/bug487439.stdout.exp | 1 + + none/tests/amd64/bug487439.vgtest | 2 + + 8 files changed, 92 insertions(+), 1 deletion(-) + create mode 100644 none/tests/amd64/bug487439.cpp + create mode 100644 none/tests/amd64/bug487439.stderr.exp + create mode 100644 none/tests/amd64/bug487439.stdout.exp + create mode 100644 none/tests/amd64/bug487439.vgtest + +diff --git a/NEWS b/NEWS +index c2ad6a207d96..fbe0f012ef0c 100644 +--- a/NEWS ++++ b/NEWS +@@ -9,6 +9,7 @@ The following bugs have been fixed or resolved on this branch. + 486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL' + 486293 memccpy false positives + 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table ++487439 SIGILL in JDK11, JDK17 + n-i-bz aarch64 frinta and frinta vector instructions + + To see details of a given bug, visit +diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c +index f0b1c5516267..28c37f092211 100644 +--- a/VEX/priv/guest_amd64_toIR.c ++++ b/VEX/priv/guest_amd64_toIR.c +@@ -14138,7 +14138,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, + goto decode_success; + } + /* 66 0F 73 /6 ib = PSLLQ by immediate */ +- if (have66noF2noF3(pfx) && sz == 2 ++ if (have66noF2noF3(pfx) && (sz == 2 || /* ignore redundant REX.W */ sz == 8) + && epartIsReg(getUChar(delta)) + && gregLO3ofRM(getUChar(delta)) == 6) { + delta = dis_SSE_shiftE_imm( pfx, delta, "psllq", Iop_ShlN64x2 ); +diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am +index dc0498018209..83029c15590c 100644 +--- a/none/tests/amd64/Makefile.am ++++ b/none/tests/amd64/Makefile.am +@@ -44,6 +44,7 @@ EXTRA_DIST = \ + bug156404-amd64.vgtest bug156404-amd64.stdout.exp \ + bug156404-amd64.stderr.exp \ + bug485148.vgtest bug485148.stdout.exp bug485148.stderr.exp \ ++ bug487439.vgtest bug487439.stdout.exp bug487439.stderr.exp \ + cet_nops.vgtest cet_nops.stdout.exp cet_nops.stderr.exp \ + clc.vgtest clc.stdout.exp clc.stderr.exp \ + crc32.vgtest crc32.stdout.exp crc32.stderr.exp \ +@@ -107,6 +108,7 @@ check_PROGRAMS = \ + amd64locked \ + bt_flags \ + bug127521-64 bug132813-amd64 bug132918 bug137714-amd64 \ ++ bug487439 \ + cet_nops \ + clc \ + cmpxchg \ +@@ -204,6 +206,7 @@ amd64locked_CFLAGS = $(AM_CFLAGS) -O + bug132918_LDADD = -lm + bug485148_CXXFLAGS = ${AM_CXXFLAGS} -mfma + bug485148_SOURCES = bug485148.cpp ++bug487439_SOURCES = bug487439.cpp + cmpxchg_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ + fb_test_amd64_CFLAGS = $(AM_CFLAGS) -O -fno-strict-aliasing + fb_test_amd64_LDADD = -lm +diff --git a/none/tests/amd64/bug487439.cpp b/none/tests/amd64/bug487439.cpp +new file mode 100644 +index 000000000000..f86bb65ce9eb +--- /dev/null ++++ b/none/tests/amd64/bug487439.cpp +@@ -0,0 +1,83 @@ ++// This is more or less a copy/paste from the generated insn_sse2.c ++// I didn't want to mess with the perl generator because ++// GCC and clang don't agree on the asm syntax ++// Using the rex prefix looks like a bug or misfeature in OpenJDK ++// so I'm assuming that this is a one-off and not a general issue ++ ++#include ++#include ++#include ++ ++union reg128_t { ++ char sb[16]; ++ unsigned char ub[16]; ++ short sw[8]; ++ unsigned short uw[8]; ++ int sd[4]; ++ unsigned int ud[4]; ++ long long int sq[2]; ++ unsigned long long int uq[2]; ++ float ps[4]; ++ double pd[2]; ++} __attribute__ ((aligned (16))); ++ ++static sigjmp_buf catchpoint; ++ ++static void handle_sigill(int signum) ++{ ++ siglongjmp(catchpoint, 1); ++} ++ ++/* with redundant rex.W */ ++static void psllq_4(void) ++{ ++ reg128_t arg1 = { .uq = { 0x0123456789abcdefULL, 0x0123456789abcdefULL } }; ++ reg128_t result0; ++ char state[108]; ++ ++ if (sigsetjmp(catchpoint, 1) == 0) ++ { ++ asm( ++ "ffree %%st(7)\n" ++ "ffree %%st(6)\n" ++ "ffree %%st(5)\n" ++ "ffree %%st(4)\n" ++ "movlps %2, %%xmm1\n" ++ "movhps %3, %%xmm1\n" ++ // only GCC ++ //".rex.W psllq $12, %%xmm1\n" ++ // only clang ++ //"data16 rex64 psllq $12, %mm1\n" ++ ".byte 0x66,0x48,0x0f,0x73,0xf1,0x0c\n" ++ "movlps %%xmm1, %0\n" ++ "movhps %%xmm1, %1\n" ++ "cld\n" ++ : "=m" (result0.uq[0]), "=m" (result0.uq[1]) ++ : "m" (arg1.uq[0]), "m" (arg1.uq[1]), "m" (state[0]) ++ : "xmm1" ++ ); ++ ++ if (result0.uq[0] == 0x3456789abcdef000ULL && result0.uq[1] == 0x3456789abcdef000ULL ) ++ { ++ std::cout << "psllq_4 ... ok\n"; ++ } ++ else ++ { ++ std::cout << "psllq_4 ... not ok\n"; ++ std::cout << " result0.uq[0] = " << result0.uq[0] << " (expected " << 0x3456789abcdef000ULL << ")\n"; ++ std::cout << " result0.uq[1] = " << result0.uq[1] << " (expected " << 0x3456789abcdef000ULL << ")\n"; ++ } ++ } ++ else ++ { ++ std::cout << "psllq_4 ... failed\n"; ++ } ++ ++ return; ++} ++ ++int main() ++{ ++ signal(SIGILL, handle_sigill); ++ psllq_4(); ++} +diff --git a/none/tests/amd64/bug487439.stderr.exp b/none/tests/amd64/bug487439.stderr.exp +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/none/tests/amd64/bug487439.stdout.exp b/none/tests/amd64/bug487439.stdout.exp +new file mode 100644 +index 000000000000..065b518a27d7 +--- /dev/null ++++ b/none/tests/amd64/bug487439.stdout.exp +@@ -0,0 +1 @@ ++psllq_4 ... ok +diff --git a/none/tests/amd64/bug487439.vgtest b/none/tests/amd64/bug487439.vgtest +new file mode 100644 +index 000000000000..3faa1ed6b014 +--- /dev/null ++++ b/none/tests/amd64/bug487439.vgtest +@@ -0,0 +1,2 @@ ++prog: bug487439 ++vgopts: -q +-- +2.45.2 + diff --git a/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch b/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch new file mode 100644 index 0000000..bdabc23 --- /dev/null +++ b/0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch @@ -0,0 +1,226 @@ +From 14cefe7c645a3148165f4b2fa6095d9446e378c7 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sun, 16 Jun 2024 21:23:08 +0200 +Subject: [PATCH 13/15] Don't leave fds created with --log-file, --xml-file or + --log-socket open +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +prepare_sink_fd and prepare_sink_socket will create a new file +descriptor for the output sink. finalize_sink_fd then copies the fd +to the safe range, so it doesn't conflict with any application fds. + +If we created the original fd ourselves, it was a VgLogTo_File or +VgLogTo_Socket, not VgLogTo_Fd, finalize_sink_fd should close it. + +Also close socket when connecting fails in VG_(connect_via_socket). + +Add a testcase for --log-file and --xml-file which prints output to +/dev/stderr + +https://bugs.kde.org/show_bug.cgi?id=202770 +https://bugs.kde.org/show_bug.cgi?id=311655 +https://bugs.kde.org/show_bug.cgi?id=488379 + +Co-authored-by: Alexandra Hájková fd = safe_fd; ++ /* If we created the new_fd (VgLogTo_File or VgLogTo_Socket), then we ++ don't need the original file descriptor open anymore. We only need ++ to keep it open if it was an existing fd given by the user (or ++ stderr). */ ++ if (sink->type != VgLogTo_Fd) ++ VG_(close)(new_fd); + } + } + +diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am +index 185993f204bb..532cc7632a8f 100644 +--- a/none/tests/Makefile.am ++++ b/none/tests/Makefile.am +@@ -86,6 +86,7 @@ dist_noinst_SCRIPTS = \ + filter_none_discards \ + filter_stderr \ + filter_timestamp \ ++ filter_xml \ + allexec_prepare_prereq + + noinst_HEADERS = fdleak.h +@@ -229,7 +230,9 @@ EXTRA_DIST = \ + sigprocmask.stderr.exp sigprocmask.vgtest \ + socket_close.stderr.exp socket_close.vgtest \ + file_dclose.stderr.exp file_dclose.vgtest \ +- double_close_range.stderr.exp double_close_range.vgtest ++ double_close_range.stderr.exp double_close_range.vgtest \ ++ log-track-fds.stderr.exp log-track-fds.vgtest \ ++ xml-track-fds.stderr.exp xml-track-fds.vgtest + + + check_PROGRAMS = \ +diff --git a/none/tests/filter_xml b/none/tests/filter_xml +new file mode 100755 +index 000000000000..d1ef570a05b0 +--- /dev/null ++++ b/none/tests/filter_xml +@@ -0,0 +1,25 @@ ++#! /bin/sh ++ ++dir=`dirname $0` ++ ++# FreeBSD adds this one extra line ++# but after filter_xml_frames it will just be ...<\/path> ++# which matches other lines, so get rid of it while we can ++# uniquely match it ++sed "/internet<\/path>/d" | ++ ++$dir/../../tests/filter_xml_frames | ++perl -p -e "s/