]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Allow for patching LTP sources
authorMartin Cermak <mcermak@redhat.com>
Tue, 5 Aug 2025 16:06:08 +0000 (18:06 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 6 Aug 2025 14:39:34 +0000 (16:39 +0200)
Sometimes there's an upstream LTP patch that helps testing
valgrind, but it's not yet part of the official LTP tarball.
In such cases it's helpful to be able to patch the LTP sources.
Attached patch allows for that.  It comes with a real life
example patch: LTP commit b62b831cf.

NEWS
auxprogs/Makefile.am
auxprogs/ltp-apply-patches.sh [new file with mode: 0755]
auxprogs/ltp-patches/0001-Make-sure-32-bit-powerpc-syscall-defs-don-t-leak-to-.patch [new file with mode: 0644]
auxprogs/ltp-patches/README [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index ef5af7c6685bbf625b12602091a04c7db2ebd41e..cecbd6db7b947d4796d73faff997d1187cefccea 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 506967  Implement and override mallinfo2
 506970  mmap needs an EBADF fd_allowed check
 507173  s390x: Crash when constant folding is disabled
+507897  Allow for patching LTP sources
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 97eb9501eb212a5695614c4e910ff688f28f1bf1..5542111db60d6c684ee5a44527d26f16426b825a 100644 (file)
@@ -199,6 +199,7 @@ $(LTP_SRC_DIR): $(LTP_TAR)
        echo "$(LTP_SHA256_SUM)  $(LTP_TAR)" | @SHA256SUM@ --check -
        (cd $(AUX_CHECK_DIR) && \
         tar Jxf $(LTP_TAR_NAME) && \
+        $(abs_top_srcdir)/auxprogs/ltp-apply-patches.sh $(LTP_SRC_DIR) && \
         cd $(LTP_SRC_DIR) && \
         ./configure CC="${CC}" CXX="${CXX}" CFLAGS="$(LTP_CFLAGS)" && \
         ${MAKE} -j $(nproc) -C testcases/kernel/syscalls)
diff --git a/auxprogs/ltp-apply-patches.sh b/auxprogs/ltp-apply-patches.sh
new file mode 100755 (executable)
index 0000000..150dd2a
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -xe
+
+LTP_SRC_DIR=$1
+cd $(dirname $(readlink -f $0))
+echo "applying LTP patches ..."
+if compgen -G "ltp-patches/*.patch"; then
+    for i in ltp-patches/*.patch; do
+        patch -d "$LTP_SRC_DIR"  -p1 < "$i"
+    done
+    echo "applying LTP patches finished"
+else
+    echo "no patches found, nothing to do"
+fi
diff --git a/auxprogs/ltp-patches/0001-Make-sure-32-bit-powerpc-syscall-defs-don-t-leak-to-.patch b/auxprogs/ltp-patches/0001-Make-sure-32-bit-powerpc-syscall-defs-don-t-leak-to-.patch
new file mode 100644 (file)
index 0000000..bd1fb1d
--- /dev/null
@@ -0,0 +1,41 @@
+From a90b2aac69028bd6b9e0fcc1e36760639b937b99 Mon Sep 17 00:00:00 2001
+From: Martin Cermak <mcermak@redhat.com>
+Date: Mon, 4 Aug 2025 21:46:52 +0200
+Subject: [PATCH] Make sure 32-bit powerpc syscall defs don't leak to 64-bit
+ powerpc systems
+
+generate_syscalls.sh generates the syscalls.h header at the configure
+time.  At the moment, that header has a set of 32-bit syscalls defined
+with the __powerpc__ gate, plus another set of 64-bit syscalls defined
+with the __powerpc64__ gate.  For 32-bit powerpc systems that's fine.
+But for a 64-bit powerpc system this means that both sets of syscalls
+become defined, which isn't right.
+
+Thing is that on a 64-bit powerpc system, both __powerpc__ and
+__powerpc64__ are defined compiler macros, while on a 32-bit powerpc
+system, only the former is defined while the latter is not.
+
+That said, the correct gate for a 32-bit only powerpc code is:
+  #if defined(__powerpc__) && !defined(__powerpc64__)
+
+Without this patch, e.g. __NR_clock_gettime64 def leaks to
+64-bit powerpc systems, which is wrong.  This patch fixes it.
+---
+ include/lapi/syscalls/generate_syscalls.sh | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/include/lapi/syscalls/generate_syscalls.sh b/include/lapi/syscalls/generate_syscalls.sh
+index b17c72ddf..19f280dfb 100755
+--- a/include/lapi/syscalls/generate_syscalls.sh
++++ b/include/lapi/syscalls/generate_syscalls.sh
+@@ -78,6 +78,7 @@ while IFS= read -r arch; do
+               parisc) echo "#ifdef __hppa__" ;;
+               loongarch64) echo "#ifdef __loongarch__" ;;
+               arm64) echo "#ifdef __aarch64__" ;;
++              powerpc) echo "#if defined(__powerpc__) && !defined(__powerpc64__)" ;;
+               *) echo "#ifdef __${arch}__" ;;
+               esac
+-- 
+2.48.1
+
diff --git a/auxprogs/ltp-patches/README b/auxprogs/ltp-patches/README
new file mode 100644 (file)
index 0000000..89df4bf
--- /dev/null
@@ -0,0 +1,5 @@
+This directory contains LTP patches that are not included in the official LTP
+tarball. After a new version of LTP is adopted for Valgrind testing, this patch
+set should be reviewed and cleaned up. Patch filenames are expected to have the
+.patch suffix.
+