Skip to contentSkip to conversation

module.lds.S: Fix modules on 32-bit parisc architecture

PATCH Superseded Helge Deller 3 participants 3 messages Apr 4 – Apr 7 Module support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module.lds.S: Fix modules on 32-bit parisc architecture

On the 32-bit parisc architecture, we always used the -ffunction-sections compiler option to tell the compiler to put the functions into seperate text sections. This is necessary, otherwise "big" kernel modules like ext4 or ipv6 fail to load because some branches won't be able to reach their stubs.

Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros") broke this for parisc because all text sections will get unconditionally merged now.

Fix the issue by avoiding the text section merge for 32-bit parisc while still allowing it for all other architectures.

Fixes 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Cc Josh Poimboeuf <[email protected]>
Cc [email protected] # v6.19+
scripts/module.lds.S +2 -0
index 054ef99e8288..41e13e9cbb9d 100644
@@ -41,9 +41,11 @@ SECTIONS {
 	__kcfi_traps		: { KEEP(*(.kcfi_traps)) }
 #endif
 
+#if !defined(CONFIG_PARISC) || defined(CONFIG_64BIT)
 	.text : {
 		*(.text .text.[0-9a-zA-Z_]*)
 	}
+#endif
 
 	.bss : {
 		*(.bss .bss.[0-9a-zA-Z_]*)
maintainer
#1 lore raw

Hi Helge,

Quoted 24 lines · Helge Deller

On the 32-bit parisc architecture, we always used the -ffunction-sections compiler option to tell the compiler to put the functions into seperate text sections. This is necessary, otherwise "big" kernel modules like ext4 or ipv6 fail to load because some branches won't be able to reach their stubs.

Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros") broke this for parisc because all text sections will get unconditionally merged now.

Fix the issue by avoiding the text section merge for 32-bit parisc while still allowing it for all other architectures.

Fixes 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Cc Josh Poimboeuf <[email protected]>
Cc [email protected] # v6.19+
scripts/module.lds.S +0 -0
index 054ef99e8288..41e13e9cbb9d 100644

scripts/module.lds.S SECTIONS { · line 44

Quoted 4 lines
scripts/module.lds.S +1 -0
@@ -41,9 +41,11 @@ SECTIONS {
        __kcfi_traps            : { KEEP(*(.kcfi_traps)) }
 #endif
 
+#if !defined(CONFIG_PARISC) || defined(CONFIG_64BIT)

Instead of adding parisc-specific policies to the main module linker script, could we add a separate config flag for this and have parisc select that in its own Kconfig for !64BIT? Perhaps something like ARCH_WANTS_MODULE_TEXT_SECTIONS?

Sami

#2 lore raw
Quoted 30 lines · Sami Tolvanen

Hi Helge,

Quoted 27 lines · Helge Deller

On the 32-bit parisc architecture, we always used the -ffunction-sections compiler option to tell the compiler to put the functions into seperate text sections. This is necessary, otherwise "big" kernel modules like ext4 or ipv6 fail to load because some branches won't be able to reach their stubs.

Commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros") broke this for parisc because all text sections will get unconditionally merged now.

Fix the issue by avoiding the text section merge for 32-bit parisc while still allowing it for all other architectures.

Fixes 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros")
Cc Josh Poimboeuf <[email protected]>
Cc [email protected] # v6.19+
scripts/module.lds.S +0 -0
index 054ef99e8288..41e13e9cbb9d 100644
@@ -41,9 +41,11 @@ SECTIONS {
         __kcfi_traps            : { KEEP(*(.kcfi_traps)) }
  #endif
 
Quoted 6 lines

scripts/module.lds.S SECTIONS { · line 44

Quoted 1 line
scripts/module.lds.S +1 -0
+#if !defined(CONFIG_PARISC) || defined(CONFIG_64BIT)

Instead of adding parisc-specific policies to the main module linker script, could we add a separate config flag for this and have parisc select that in its own Kconfig for !64BIT? Perhaps something like ARCH_WANTS_MODULE_TEXT_SECTIONS?

Yes, good idea!
I will send a v2 patch.

Helge