diff mbox series

[v1,08/14] DCE/DSE: add choice of methods to build reference for orphan sections

Message ID c1c9913c0974b96faaab664ef354cf8775cd7554.1699025537.git.tanyuan@tinylab.org (mailing list archive)
State Changes Requested, archived
Headers show
Series DCE/DSE: Add Dead Syscalls Elimination support, part2 | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Yuan Tan Nov. 3, 2023, 4:01 p.m. UTC
Due to .pushsection producing orphan sections, the kernel currently uses
`KEEP()` in the linker script to address this issue.

Here we purpose two methods to build reference for pushed section,
SHF_LINK_ORDER method and SECTION_SHF_GROUP method.

The binary files compiled using both methods turn out to be identical,
and it doesn't produce any side effects.

Signed-off-by: Yuan Tan <tanyuan@tinylab.org>
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 init/Kconfig | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
diff mbox series

Patch

diff --git a/init/Kconfig b/init/Kconfig
index 9834dbb0ddae..9599d2de44e8 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1740,6 +1740,56 @@  config USED_SYSCALLS
 
 	  If unsure, please disable TRIM_UNUSED_SYSCALLS.
 
+choice
+	prompt "Trim methods" if EXPERT
+	default RESTRICTED_TRIM_UNUSED_SYSCALLS
+	depends on TRIM_UNUSED_SYSCALLS
+	help
+	  This option selects the method to trim unused syscall wrongly kept.
+
+	  The binary files compiled using both methods are identical.
+
+	  If the trim methods is not specified, some syscalls are kept by
+	  linker script and can not be trimmed.
+
+config RESTRICTED_TRIM_UNUSED_SYSCALLS
+	bool "Leave some kept syscalls (EXPERIMENTAL)" if EXPERT
+	help
+	  Say Y here to trim 'unused' syscalls wrongly kept by __ex_table
+	  like sections in kernel space.
+
+	  Some syscalls are kept by linker script and can not be trimmed.
+
+	  If unsure, choose this.
+
+config SECTION_SHF_LINK_ORDER_SUPPORT
+	bool "Using SHF_LINK_ORDER attribute (EXPERIMENTAL)" if EXPERT
+	depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT
+	help
+	  Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table
+	  like sections in kernel space.
+
+	  This option uses the SHF_LINK_ORDER attribute to build references for
+	  orphan sections. Therefore, these sections are no longer kept in the
+	  linker script.
+
+	  If unsure, not choose this.
+
+config SECTION_SHF_GROUP_SUPPORT
+	bool "Using SHF_GROUP attribute (EXPERIMENTAL)" if EXPERT
+	depends on HAVE_SECTION_SHF_GROUP_SUPPORT
+	help
+	  Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table
+	  like sections in kernel space.
+
+	  This option uses the SHF_GROUP attribute to build references for
+	  orphan sections. Therefore, these sections are no longer kept in the
+	  linker script.
+
+	  If unsure, not choose this.
+
+endchoice
+
 config KALLSYMS
 	bool "Load all symbols for debugging/ksymoops" if EXPERT
 	default y