[PATCH v2 5/8] kconfig: add CONFIG_PUSHSECTION_WITH_RELOC for relocation support
Yuan Tan
tanyuan at tinylab.org
Tue Oct 14 23:18:58 PDT 2025
If the assembler supports the '.reloc' directive with 'BFD_RELOC_NONE', we
can establish a reference between a section created by '.pushsection' and
its caller function by emitting a relocation in the caller.
Known toolchain minimums:
- GNU binutils (gas) >= 2.26
- LLVM integrated assembler (IAS) >= 13.0.0
All assemblers meeting the kernel's minimum toolchain requirements already
support it.
Signed-off-by: Yuan Tan <tanyuan at tinylab.org>
Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
Signed-off-by: Peihan Liu <ronbogo at outlook.com>
---
init/Kconfig | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig
index 2c6f86c44d96..3d1cf32d5407 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1631,6 +1631,10 @@ config HAVE_PCSPKR_PLATFORM
config HAVE_TRIM_UNUSED_SYSCALLS
bool
+config AS_HAS_BFD_RELOC_NONE
+ bool
+ def_bool $(as-instr,.reloc .$(comma) BFD_RELOC_NONE$(comma))
+
menuconfig EXPERT
bool "Configure standard kernel features (expert users)"
# Unhide debug options, to make the on-by-default options visible
@@ -1965,6 +1969,18 @@ config USED_SYSCALLS
If unsure, please disable TRIM_UNUSED_SYSCALLS.
+config PUSHSECTION_WITH_RELOC
+ bool "Trim more syscalls"
+ depends on TRIM_UNUSED_SYSCALLS && AS_HAS_BFD_RELOC_NONE
+ default y
+ help
+ Enable building relocation-based references between sections created
+ by '.pushsection' and their caller functions when the assembler
+ supports the '.reloc' directive.
+
+ This allows the linker to establish proper dependencies, remove the
+ need for KEEP().
+
config KALLSYMS
bool "Load all symbols for debugging/ksymoops" if EXPERT
default y
--
2.43.0
More information about the linux-riscv
mailing list