[PATCH] ARM: unwind: modules: Fix the mismatch between .ARM.exidx* and .text

Xie Yuanbin posted 1 patch 1 month, 3 weeks ago
scripts/module.lds.S | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] ARM: unwind: modules: Fix the mismatch between .ARM.exidx* and .text
Posted by Xie Yuanbin 1 month, 3 weeks ago
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 <xiaojunzhe1@h-partners.com>
Signed-off-by: Xie Yuanbin <xieyuanbin1@huawei.com>
---
 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
Re: [PATCH] ARM: unwind: modules: Fix the mismatch between .ARM.exidx* and .text
Posted by Petr Pavlu 1 month, 3 weeks ago
On 8/6/26 6:10 AM, Xie Yuanbin wrote:
> 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.

A fix for this issue was posted previously:

https://lore.kernel.org/linux-modules/tencent_08845B64E5F38EB7FA1779982A071AB4A607@qq.com/

-- 
Thanks,
Petr
Re: [PATCH] ARM: unwind: modules: Fix the mismatch between .ARM.exidx* and .text
Posted by Xie Yuanbin 1 month, 3 weeks ago
On Thu, 6 Aug 2026 11:40:23 +0200, Petr Pavlu wrote:
> A fix for this issue was posted previously:
> 
> https://lore.kernel.org/linux-modules/tencent_08845B64E5F38EB7FA1779982A071AB4A607@qq.com/

Oh, sorry, I didn't know about this. Let's discuss it on
previously posted patch. :)