[<prev] [next>] [day] [month] [year] [list]
Message-ID: <553D6FEA67820FC7+34b9da95a06acd3ee5ce0e9cc16cb60aa1aaad2f.1760463245.git.tanyuan@tinylab.org>
Date: Wed, 15 Oct 2025 14:17:17 +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 1/8] init/Kconfig: add CONFIG_TRIM_UNUSED_SYSCALLS and related options
From: Yuhang Zheng <z1652074432@...il.com>
Introduce configuration options to enable dead code/data elimination for
unused system calls.
This change adds the following Kconfig symbols:
- TRIM_UNUSED_SYSCALLS: user option to enable trimming of unused system
calls
- HAVE_TRIM_UNUSED_SYSCALLS: architecture capability symbol
- USED_SYSCALLS: string list of system calls to keep(separated by spaces)
These options integrate with scripts/Makefile.asm-headers and syscalltbl.sh
to generate syscall tables only for selected entries. The feature depends
on LD_DEAD_CODE_DATA_ELIMINATION and on architectures that use
syscalltbl.sh to generate their syscall tables.
Signed-off-by: Yuhang Zheng <z1652074432@...il.com>
Signed-off-by: Yuan Tan <tanyuan@...ylab.org>
Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
init/Kconfig | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig
index cab3ad28ca49..2c6f86c44d96 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1628,6 +1628,9 @@ config SYSFS_SYSCALL
config HAVE_PCSPKR_PLATFORM
bool
+config HAVE_TRIM_UNUSED_SYSCALLS
+ bool
+
menuconfig EXPERT
bool "Configure standard kernel features (expert users)"
# Unhide debug options, to make the on-by-default options visible
@@ -1932,6 +1935,36 @@ config CACHESTAT_SYSCALL
If unsure say Y here.
+config TRIM_UNUSED_SYSCALLS
+ bool "Trim unused syscalls" if EXPERT
+ default n
+ depends on HAVE_TRIM_UNUSED_SYSCALLS
+ depends on LD_DEAD_CODE_DATA_ELIMINATION
+ help
+ Enable this option to trim unused system calls from the final kernel
+ image. Only the syscalls explicitly listed in CONFIG_USED_SYSCALLS
+ will be kept.
+
+ Note that some unused syscalls may still be retained if their sections
+ are forcibly kept by other sections created with .pushsection and
+ preserved via KEEP() in the linker script.
+
+ If unsure, say N.
+
+config USED_SYSCALLS
+ string "Configure used syscalls" if EXPERT
+ depends on TRIM_UNUSED_SYSCALLS
+ default ""
+ help
+ Specify a list of system calls that should be kept when
+ TRIM_UNUSED_SYSCALLS is enabled.
+
+ The system calls should be listed one by one, separated by spaces.
+ For example, set CONFIG_USED_SYSCALLS="write exit reboot". If left
+ empty, all syscalls will be trimmed.
+
+ If unsure, please disable TRIM_UNUSED_SYSCALLS.
+
config KALLSYMS
bool "Load all symbols for debugging/ksymoops" if EXPERT
default y
--
2.43.0
Powered by blists - more mailing lists