[<prev] [next>] [day] [month] [year] [list]
Message-ID: <B120EFEBD27B9B67+6751ec7c12d04aafe1de79502b984ed65013f6cf.1760463245.git.tanyuan@tinylab.org>
Date: Wed, 15 Oct 2025 14:17:49 +0800
From: Yuan Tan <tanyuan@...ylab.org>
To: arnd@...db.de,
masahiroy@...nel.org,
nathan@...nel.org,
palmer@...belt.com,
linux-kbuild@...r.kernel.org,
linux-riscv@...ts.infradead.org
Cc: linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org,
i@...kray.me,
tanyuan@...ylab.org,
falcon@...ylab.org,
ronbogo@...look.com,
z1652074432@...il.com,
lx24@....ynu.edu.cn
Subject: [PATCH v2 2/8] scripts/syscalltbl.sh: add optional --used-syscalls argument for syscall trimming
From: Yuhang Zheng <z1652074432@...il.com>
Add support for an optional `--used-syscalls` argument to
scripts/syscalltbl.sh. When provided, the argument takes a comma-separated
list of syscall names that should remain enabled in the generated syscall
table. Any syscall not present in the list will be replaced with a
`__SYSCALL(nr, sys_ni_syscall)` entry.
This enables selective system call table generation when
CONFIG_TRIM_UNUSED_SYSCALLS is set.
Signed-off-by: Yuhang Zheng <z1652074432@...il.com>
Signed-off-by: Yuan Tan <tanyuan@...ylab.org>
Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
scripts/syscalltbl.sh | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/scripts/syscalltbl.sh b/scripts/syscalltbl.sh
index 6a903b87a7c2..27d8dfce5748 100755
--- a/scripts/syscalltbl.sh
+++ b/scripts/syscalltbl.sh
@@ -22,12 +22,14 @@ usage() {
echo >&2 " OUTFILE output header file"
echo >&2
echo >&2 "options:"
- echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
+ echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
+ echo >&2 " --used-syscalls SYSCALLS Keep only the specified syscall; trim others"
exit 1
}
# default unless specified by options
abis=
+used_syscalls=
while [ $# -gt 0 ]
do
@@ -35,6 +37,14 @@ do
--abis)
abis=$(echo "($2)" | tr ',' '|')
shift 2;;
+ --used-syscalls=*)
+ used_syscalls_raw=${1#--used-syscalls=}
+ if [ -z "$used_syscalls_raw" ]; then
+ used_syscalls='^$'
+ else
+ used_syscalls=$(echo "$used_syscalls_raw" | tr ',' '|')
+ fi
+ shift;;
-*)
echo "$1: unknown option" >&2
usage;;
@@ -52,6 +62,7 @@ outfile="$2"
nxt=0
+
grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | {
while read nr abi name native compat noreturn; do
@@ -66,6 +77,12 @@ grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | {
nxt=$((nxt + 1))
done
+ if [ -n "$used_syscalls" ] && ! echo "$name" | grep -qwE "$used_syscalls"; then
+ echo "__SYSCALL($nr, sys_ni_syscall)"
+ nxt=$((nr + 1))
+ continue
+ fi
+
if [ "$compat" = "-" ]; then
unset compat
fi
--
2.43.0
Powered by blists - more mailing lists