* [PATCH] ARM: module.lds: fix unwind metadata for merged .text sections
@ 2026-05-21 15:57 Egg12138
2026-05-28 12:44 ` Petr Pavlu
2026-05-29 16:46 ` [PATCH v2] " Egg12138
0 siblings, 2 replies; 4+ messages in thread
From: Egg12138 @ 2026-05-21 15:57 UTC (permalink / raw)
To: Russell King
Cc: Josh Poimboeuf, Petr Mladek, linux-arm-kernel, linux-modules,
linux-kernel, Egg12138
Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN,
and related macros") made scripts/module.lds.S merge module input
.text.* sections into the output .text section.
On ARM, the paired unwind input sections keep their original names. A
module can therefore contain .ARM.exidx.text.unlikely with sh_link
pointing at .text, while .text.unlikely no longer exists.
This is a valid ELF relationship, but ARM module_finalize() does not use
sh_link when registering module unwind tables. It derives the target
text section from the exidx section name instead:
.ARM.exidx.text.unlikely -> .text.unlikely
The lookup fails and the unwind table is not registered for the actual
.text range. This can make module stack unwinding fail with:
unwind: Index not found
Keep the ARM module unwind output names in sync with the text sections
that scripts/module.lds.S now produces. Coalesce the .ARM.exidx/.ARM.extab
sections associated with .text.*, into the
stable output names expected by the existing ARM module unwind code.
Fixes: 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Signed-off-by: Egg12138 <egg12138@foxmail.com>
---
arch/arm/include/asm/module.lds.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
index 0e7cb4e314b4..dc9adf8fa50e 100644
--- a/arch/arm/include/asm/module.lds.h
+++ b/arch/arm/include/asm/module.lds.h
@@ -1,4 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef CONFIG_ARCH_WANTS_MODULES_TEXT_SECTIONS
+SECTIONS {
+ .ARM.extab 0 : { *(.ARM.extab .ARM.extab.text .ARM.extab.text.[0-9a-zA-Z_]*) }
+ .ARM.exidx 0 : { *(.ARM.exidx .ARM.exidx.text .ARM.exidx.text.[0-9a-zA-Z_]*) }
+}
+#endif
+
#ifdef CONFIG_ARM_MODULE_PLTS
SECTIONS {
.plt : { BYTE(0) }
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ARM: module.lds: fix unwind metadata for merged .text sections
2026-05-21 15:57 [PATCH] ARM: module.lds: fix unwind metadata for merged .text sections Egg12138
@ 2026-05-28 12:44 ` Petr Pavlu
2026-05-29 16:46 ` [PATCH v2] " Egg12138
1 sibling, 0 replies; 4+ messages in thread
From: Petr Pavlu @ 2026-05-28 12:44 UTC (permalink / raw)
To: Egg12138
Cc: Russell King, Josh Poimboeuf, Petr Mladek, linux-arm-kernel,
linux-modules, linux-kernel
On 5/21/26 5:57 PM, Egg12138 wrote:
> Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN,
> and related macros") made scripts/module.lds.S merge module input
> .text.* sections into the output .text section.
>
> On ARM, the paired unwind input sections keep their original names. A
> module can therefore contain .ARM.exidx.text.unlikely with sh_link
> pointing at .text, while .text.unlikely no longer exists.
>
> This is a valid ELF relationship, but ARM module_finalize() does not use
> sh_link when registering module unwind tables. It derives the target
> text section from the exidx section name instead:
>
> .ARM.exidx.text.unlikely -> .text.unlikely
>
> The lookup fails and the unwind table is not registered for the actual
> .text range. This can make module stack unwinding fail with:
>
> unwind: Index not found
>
> Keep the ARM module unwind output names in sync with the text sections
> that scripts/module.lds.S now produces. Coalesce the .ARM.exidx/.ARM.extab
> sections associated with .text.*, into the
> stable output names expected by the existing ARM module unwind code.
>
> Fixes: 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
> Signed-off-by: Egg12138 <egg12138@foxmail.com>
A Signed-off-by tag should use a known identity, see
Documentation/process/submitting-patches.rst, Developer's Certificate of
Origin 1.1 [1].
> ---
> arch/arm/include/asm/module.lds.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
> index 0e7cb4e314b4..dc9adf8fa50e 100644
> --- a/arch/arm/include/asm/module.lds.h
> +++ b/arch/arm/include/asm/module.lds.h
> @@ -1,4 +1,12 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef CONFIG_ARCH_WANTS_MODULES_TEXT_SECTIONS
The Arm architecture support doesn't select
CONFIG_ARCH_WANTS_MODULES_TEXT_SECTIONS, so this #ifndef is not really
necessary. I suggest leaving these linker definitions unconditional, or
alternatively use '#ifdef CONFIG_ARM_UNWIND'.
> +SECTIONS {
> + .ARM.extab 0 : { *(.ARM.extab .ARM.extab.text .ARM.extab.text.[0-9a-zA-Z_]*) }
> + .ARM.exidx 0 : { *(.ARM.exidx .ARM.exidx.text .ARM.exidx.text.[0-9a-zA-Z_]*) }
> +}
> +#endif
> +
> #ifdef CONFIG_ARM_MODULE_PLTS
> SECTIONS {
> .plt : { BYTE(0) }
Besides the above nits, the patch looks ok to me. Please don't forget to
put it in Russell's patch tracker [2].
[1] https://github.com/torvalds/linux/blob/v7.1-rc5/Documentation/process/submitting-patches.rst#developers-certificate-of-origin-11
[2] https://www.arm.linux.org.uk/developer/patches/
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] ARM: module.lds: fix unwind metadata for merged .text sections
2026-05-21 15:57 [PATCH] ARM: module.lds: fix unwind metadata for merged .text sections Egg12138
2026-05-28 12:44 ` Petr Pavlu
@ 2026-05-29 16:46 ` Egg12138
2026-05-29 17:12 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Egg12138 @ 2026-05-29 16:46 UTC (permalink / raw)
To: Russell King
Cc: Josh Poimboeuf, Petr Mladek, linux-arm-kernel, linux-modules,
linux-kernel, Xiao Junzhe
From: Xiao Junzhe <egg12138@foxmail.com>
Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN,
and related macros") made scripts/module.lds.S merge module input
.text.* sections into the output .text section.
On ARM, the paired unwind input sections keep their original names. A
module can therefore contain .ARM.exidx.text.unlikely with sh_link
pointing at .text, while .text.unlikely no longer exists.
This is a valid ELF relationship, but ARM module_finalize() does not use
sh_link when registering module unwind tables. It derives the target
text section from the exidx section name instead:
.ARM.exidx.text.unlikely -> .text.unlikely
The lookup fails and the unwind table is not registered for the actual
.text range. This can make module stack unwinding fail with:
unwind: Index not found
Keep the ARM module unwind output names in sync with the text sections
that scripts/module.lds.S now produces. Coalesce the .ARM.exidx/.ARM.extab
section associated with .text.*, into the
stable output names expected by the existing ARM module unwind code.
Fixes: 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Signed-off-by: Xiao Junzhe <egg12138@foxmail.com>
---
Changes in v2:
- Quote ARM unwind input section patterns and split them across separate
linker-script entries to avoid checkpatch false positives on wildcard
syntax.
- No functional change: the script still folds .ARM.extab.text.* and
.ARM.exidx.text.* into the stable .ARM.extab/.ARM.exidx output sections.
arch/arm/include/asm/module.lds.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
index 0e7cb4e314b4..19ceb8cf235f 100644
--- a/arch/arm/include/asm/module.lds.h
+++ b/arch/arm/include/asm/module.lds.h
@@ -1,4 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef CONFIG_ARM_UNWIND
+SECTIONS {
+ .ARM.extab 0 : {
+ *(.ARM.extab)
+ * (".ARM.extab.text")
+ * (".ARM.extab.text.[0-9a-zA-Z_]*")
+ }
+ .ARM.exidx 0 : {
+ *(.ARM.exidx)
+ * (".ARM.exidx.text")
+ * (".ARM.exidx.text.[0-9a-zA-Z_]*")
+ }
+}
+#endif
+
#ifdef CONFIG_ARM_MODULE_PLTS
SECTIONS {
.plt : { BYTE(0) }
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] ARM: module.lds: fix unwind metadata for merged .text sections
2026-05-29 16:46 ` [PATCH v2] " Egg12138
@ 2026-05-29 17:12 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-05-29 17:12 UTC (permalink / raw)
To: Egg12138; +Cc: linux-modules
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The linker script fix is wrapped in an inverted configuration conditional (`#ifndef CONFIG_ARM_UNWIND`), applying the fix only when unwinding is disabled.
- [High] The wildcard patterns are enclosed in double quotes, which disables wildcard matching in GNU ld.
- [Low] Non-standard linker script syntax with a space between the wildcard asterisk and the section name list.
--
commit 165574ad9cf92e77eac788d811caa72c990e0b3d
Author: Xiao Junzhe <egg12138@foxmail.com>
Subject: ARM: module.lds: fix unwind metadata for merged .text sections
This commit attempts to fix a module stack unwinding failure on ARM by
coalescing .ARM.exidx and .ARM.extab input sections that belong to merged
.text.* sections. This is intended to keep the output names in sync with
what the ARM module unwind code expects.
> diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
> --- a/arch/arm/include/asm/module.lds.h
> +++ b/arch/arm/include/asm/module.lds.h
> @@ -1,4 +1,20 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef CONFIG_ARM_UNWIND
[Severity: High]
Does this exclude the fix in the exact configuration it is intended for?
The patch aims to fix module stack unwinding, which is controlled by
CONFIG_ARM_UNWIND. Because this block is wrapped in an #ifndef, the section
coalescing will be skipped when unwinding is enabled, leaving the unwind
tables unmerged and the issue unresolved.
> +SECTIONS {
> + .ARM.extab 0 : {
> + *(.ARM.extab)
> + * (".ARM.extab.text")
> + * (".ARM.extab.text.[0-9a-zA-Z_]*")
[Severity: Low]
This isn't a bug, but there is a space between the asterisk wildcard and
the section name list. While GNU ld ignores this whitespace, standard kernel
linker script conventions typically omit it.
[Severity: High]
Will GNU ld expand the wildcard patterns when they are enclosed in double
quotes?
Enclosing a section name in double quotes causes wildcard characters like
the asterisk and brackets to lose their special meaning and be treated as
literal characters. The linker will try to match a section literally named
".ARM.extab.text.[0-9a-zA-Z_]*" instead of expanding the glob to match
sections like ".ARM.extab.text.unlikely".
> + }
> + .ARM.exidx 0 : {
> + *(.ARM.exidx)
> + * (".ARM.exidx.text")
> + * (".ARM.exidx.text.[0-9a-zA-Z_]*")
> + }
> +}
> +#endif
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_D9CDCA221D0AF5EDF260559734464D39B708@qq.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-29 17:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 15:57 [PATCH] ARM: module.lds: fix unwind metadata for merged .text sections Egg12138
2026-05-28 12:44 ` Petr Pavlu
2026-05-29 16:46 ` [PATCH v2] " Egg12138
2026-05-29 17:12 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox