For the new version of the compilers, C code that does not explicitly
declare the section attribute may be split into sections other than
".text", such as ".text.unlikely" and ".text.hot". If unwind is enabled,
this will also split the ".ARM.exidx.text.*" sections.
As scripts/module.lds.S, ".text.[0-9a-zA-Z_]*" sections will be merged
into ".text" section. However, ".ARM.exidx.text.*" sections will not be
merged.
For the following module code, using the gcc-16 compiler and the
latest linux-next code, will result in dump_stack() failure.
```c
void noinline stack_func_issue(void)
{
dump_stack();
pr_emerg("dump stack finish!\n");
}
EXPORT_SYMBOL(stack_func_issue);
static int __init mmodule_init(void)
{
stack_func_issue();
return 0;
}
module_init(mmodule_init);
```
```log
root@(none):/# busybox/usr/bin/busybox insmod test2.ko
[ 10.846774] test: loading out-of-tree module taints kernel.
[ 10.851840] CPU: 0 UID: 0 PID: 93 Comm: busybox Tainted: G W O
7.2.0-rc6-next-20260805-00002-g3d7269e6e98c #3 VOLUNTARY
[ 10.852350] Tainted: [W]=WARN, [O]=OOT_MODULE
[ 10.852405] Hardware name: Generic DT based system
[ 10.852516] Call trace:
[ 10.852939] unwind_backtrace from show_stack+0x10/0x14
[ 10.853487] show_stack from dump_stack_lvl+0x54/0x68
[ 10.853512] dump_stack_lvl from stack_func_issue+0x8/0xc0 [test]
[ 10.854134] unwind: Index not found bf000008
[ 10.858157] dump stack finish!
```
Merge ".ARM.extab.text.[0-9a-z-A-Z_]*" sections into ".ARM.extab" section
and merge ".ARM.exidx.text.[0-9a-z-A-Z_]*" sections into ".ARM.exidx"
section to fix the issue.
Signed-off-by: Xiao Junzhe <[email protected]>
Signed-off-by: Xie Yuanbin <[email protected]>
---
scripts/module.lds.S | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index d0f200428957..0ccf0c205d00 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -39,6 +39,10 @@ SECTIONS {
.text 0 : {
*(.text .text.[0-9a-zA-Z_]*)
}
+#if defined(CONFIG_ARM) && defined(CONFIG_ARM_UNWIND)
+ .ARM.extab : {*(.ARM.extab .ARM.extab.text.[0-9a-z-A-Z_]*) }
+ .ARM.exidx : {*(.ARM.exidx .ARM.exidx.text.[0-9a-z-A-Z_]*) }
+#endif
#endif
.bss 0 : {
--
2.55.0