From: Xiao Junzhe <[email protected]>

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 <[email protected]>
---
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


Reply via email to