From: Martin Cermak Date: Tue, 5 Aug 2025 16:06:08 +0000 (+0200) Subject: Allow for patching LTP sources X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=03ea5d11d3832fb83a434408a5ea7049392fd4bd;p=thirdparty%2Fvalgrind.git Allow for patching LTP sources 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. --- diff --git a/NEWS b/NEWS index ef5af7c66..cecbd6db7 100644 --- 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 diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am index 97eb9501e..5542111db 100644 --- a/auxprogs/Makefile.am +++ b/auxprogs/Makefile.am @@ -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 index 000000000..150dd2a9b --- /dev/null +++ b/auxprogs/ltp-apply-patches.sh @@ -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 index 000000000..bd1fb1dd6 --- /dev/null +++ b/auxprogs/ltp-patches/0001-Make-sure-32-bit-powerpc-syscall-defs-don-t-leak-to-.patch @@ -0,0 +1,41 @@ +From a90b2aac69028bd6b9e0fcc1e36760639b937b99 Mon Sep 17 00:00:00 2001 +From: Martin Cermak +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 index 000000000..89df4bff1 --- /dev/null +++ b/auxprogs/ltp-patches/README @@ -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. +