module: force sh_addr=0 for arch-specific sections
Subsystems (4)
cover module: force sh_addr=0 for arch-specific sections
When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Joe Lawrence previously addressed the same issue in the main scripts/module.lds.S file [2] and we discussed that the same fix should be also applied to architecture-specific module sections. This series implements these changes.
The series can later be merged through the modules tree, or individual patches can be applied through the architecture-specific trees.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33958
[2] https://lore.kernel.org/linux-modules/[email protected]/
Petr Pavlu (4):
module, arm: force sh_addr=0 for arch-specific sections module, arm64: force sh_addr=0 for arch-specific sections module, m68k: force sh_addr=0 for arch-specific sections module, riscv: force sh_addr=0 for arch-specific sections
arch/arm/include/asm/module.lds.h | 4 ++-- arch/arm64/include/asm/module.lds.h | 4 ++-- arch/m68k/include/asm/module.lds.h | 2 +- arch/riscv/include/asm/module.lds.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-)
base-commit: c369299895a591d96745d6492d4888259b004a9e
Signature · 1 line
2.53.0
PATCH 1/4 module, arm: force sh_addr=0 for arch-specific sections
When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Force sh_addr=0 for all arm-specific module sections.
--- arch/arm/include/asm/module.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/module.lds.h +2 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifdef CONFIG_ARM_MODULE_PLTS SECTIONS { - .plt : { BYTE(0) } - .init.plt : { BYTE(0) } + .plt 0 : { BYTE(0) } + .init.plt 0 : { BYTE(0) } }#endif
Signature · 1 line
2.53.0
PATCH 2/4 module, arm64: force sh_addr=0 for arch-specific sections
In reply to Petr PavluWhen linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Force sh_addr=0 for all arm64-specific module sections.
---
Note that the definition of .text.hot hasn't matched any input sections since commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros"), and even before that with CONFIG_LTO_CLANG=y.
The preceding comment also explains that the directive is necessary to merge section groups. However, this approach seems suboptimal. A better method would be to link modules using --force-group-allocation to retain only one copy of each group.
I plan to look at this separately.
--- arch/arm64/include/asm/module.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/module.lds.h +2 -2
@@ -14,7 +14,7 @@ SECTIONS {* directive to force them into a single section and silence the * warning. */ - .text.hot : { *(.text.hot) } + .text.hot 0 : { *(.text.hot) }#endif #ifdef CONFIG_UNWIND_TABLES
@@ -22,6 +22,6 @@ SECTIONS {* Currently, we only use unwind info at module load time, so we can * put it into the .init allocation. */ - .init.eh_frame : { *(.eh_frame) } + .init.eh_frame 0 : { *(.eh_frame) }#endif }
Signature · 1 line
2.53.0
PATCH 3/4 module, m68k: force sh_addr=0 for arch-specific sections
In reply to Petr PavluWhen linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Force sh_addr=0 for all m68k-specific module sections.
--- arch/m68k/include/asm/module.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/include/asm/module.lds.h +1 -1
@@ -1,5 +1,5 @@ SECTIONS { - .m68k_fixup : { + .m68k_fixup 0 : { __start_fixup = .; *(.m68k_fixup) __stop_fixup = .;
Signature · 1 line
2.53.0
PATCH 4/4 module, riscv: force sh_addr=0 for arch-specific sections
In reply to Petr PavluWhen linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero sh_addr values in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Force sh_addr=0 for all riscv-specific module sections.
--- arch/riscv/include/asm/module.lds.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/include/asm/module.lds.h +3 -3
@@ -2,8 +2,8 @@/* Copyright (C) 2017 Andes Technology Corporation */ #ifdef CONFIG_MODULE_SECTIONS SECTIONS { - .plt : { BYTE(0) } - .got : { BYTE(0) } - .got.plt : { BYTE(0) } + .plt 0 : { BYTE(0) } + .got 0 : { BYTE(0) } + .got.plt 0 : { BYTE(0) } } #endif
Signature · 1 line
2.53.0
Sami Tolvanen
AppliedQuoted 6 lines · Petr Pavlu
When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero
sh_addrvalues in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Quoted 6 lines
Joe Lawrence previously addressed the same issue in the main
scripts/module.lds.Sfile [2] and we discussed that the same fix should be also applied to architecture-specific module sections. This series implements these changes.[...]
Applied to modules-next, thanks!
[1/4] module, arm: force sh_addr=0 for arch-specific sections
commit: ffe1545ce8a0a7bb698d5f68cbbdef8f93d1fce6
[2/4] module, arm64: force sh_addr=0 for arch-specific sections
commit: c5553deb577fe433f770e270fd9582b8325f12d9
[3/4] module, m68k: force sh_addr=0 for arch-specific sections
commit: 9cb4d4dc82272538de1b7edb6e8cf91597ed00b0
[4/4] module, riscv: force sh_addr=0 for arch-specific sections
commit: 04e17ca3f77e1722a5db068fbcd7b93c51656013Best regards,
Sami
This series was applied to riscv/linux.git (fixes) by Sami Tolvanen <[email protected]>:
Hello:
This series was applied to riscv/linux.git (fixes) by Sami Tolvanen <[email protected]>:
Quoted 6 lines · On Fri, 27 Mar 2026 08:58:59 +0100 you wrote:
When linking modules with 'ld.bfd -r', sections defined without an address inherit the location counter, resulting in non-zero
sh_addrvalues in the resulting .ko files. Relocatable objects are expected to have sh_addr=0 for all sections. Non-zero addresses are confusing in this context, typically worse compressible, and may cause tools to misbehave [1].
Quoted 6 lines
Joe Lawrence previously addressed the same issue in the main
scripts/module.lds.Sfile [2] and we discussed that the same fix should be also applied to architecture-specific module sections. This series implements these changes.[...]
Here is the summary with links:
- [1/4] module, arm: force sh_addr=0 for arch-specific sections
https://git.kernel.org/riscv/c/ffe1545ce8a0 - [2/4] module, arm64: force sh_addr=0 for arch-specific sections https://git.kernel.org/riscv/c/c5553deb577f - [3/4] module, m68k: force sh_addr=0 for arch-specific sections https://git.kernel.org/riscv/c/9cb4d4dc8227 - [4/4] module, riscv: force sh_addr=0 for arch-specific sections https://git.kernel.org/riscv/c/04e17ca3f77e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html