* [PATCH 0/4] module: force sh_addr=0 for arch-specific sections
@ 2026-03-27 7:58 Petr Pavlu
2026-03-27 7:59 ` [PATCH 1/4] module, arm: " Petr Pavlu
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Petr Pavlu @ 2026-03-27 7:58 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Sami Tolvanen
Cc: Alexandre Ghiti, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Aaron Tomlin, Joe Lawrence, linux-arm-kernel, linux-m68k,
linux-riscv, linux-modules, linux-kernel
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/20260305015237.299727-1-joe.lawrence@redhat.com/
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
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] module, arm: force sh_addr=0 for arch-specific sections
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
@ 2026-03-27 7:59 ` Petr Pavlu
2026-03-27 7:59 ` [PATCH 2/4] module, arm64: " Petr Pavlu
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Petr Pavlu @ 2026-03-27 7:59 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Sami Tolvanen
Cc: Alexandre Ghiti, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Aaron Tomlin, Joe Lawrence, linux-arm-kernel, linux-m68k,
linux-riscv, linux-modules, linux-kernel
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.
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1]
Signed-off-by: Petr Pavlu <petr.pavlu@suse•com>
---
arch/arm/include/asm/module.lds.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/module.lds.h b/arch/arm/include/asm/module.lds.h
index 0e7cb4e314b4..f9ad774b2889 100644
--- a/arch/arm/include/asm/module.lds.h
+++ b/arch/arm/include/asm/module.lds.h
@@ -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
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] module, arm64: force sh_addr=0 for arch-specific sections
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
2026-03-27 7:59 ` [PATCH 1/4] module, arm: " Petr Pavlu
@ 2026-03-27 7:59 ` Petr Pavlu
2026-03-27 7:59 ` [PATCH 3/4] module, m68k: " Petr Pavlu
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Petr Pavlu @ 2026-03-27 7:59 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Sami Tolvanen
Cc: Alexandre Ghiti, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Aaron Tomlin, Joe Lawrence, linux-arm-kernel, linux-m68k,
linux-riscv, linux-modules, linux-kernel
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 arm64-specific module sections.
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1]
Signed-off-by: Petr Pavlu <petr.pavlu@suse•com>
---
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(-)
diff --git a/arch/arm64/include/asm/module.lds.h b/arch/arm64/include/asm/module.lds.h
index fb944b46846d..0b3aacd22c59 100644
--- a/arch/arm64/include/asm/module.lds.h
+++ b/arch/arm64/include/asm/module.lds.h
@@ -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
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] module, m68k: force sh_addr=0 for arch-specific sections
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
2026-03-27 7:59 ` [PATCH 1/4] module, arm: " Petr Pavlu
2026-03-27 7:59 ` [PATCH 2/4] module, arm64: " Petr Pavlu
@ 2026-03-27 7:59 ` Petr Pavlu
2026-03-27 7:59 ` [PATCH 4/4] module, riscv: " Petr Pavlu
2026-05-26 23:40 ` [PATCH 0/4] module: " Sami Tolvanen
4 siblings, 0 replies; 6+ messages in thread
From: Petr Pavlu @ 2026-03-27 7:59 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Sami Tolvanen
Cc: Alexandre Ghiti, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Aaron Tomlin, Joe Lawrence, linux-arm-kernel, linux-m68k,
linux-riscv, linux-modules, linux-kernel
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 m68k-specific module sections.
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1]
Signed-off-by: Petr Pavlu <petr.pavlu@suse•com>
---
arch/m68k/include/asm/module.lds.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/m68k/include/asm/module.lds.h b/arch/m68k/include/asm/module.lds.h
index fda94fa38243..fcd08689b282 100644
--- a/arch/m68k/include/asm/module.lds.h
+++ b/arch/m68k/include/asm/module.lds.h
@@ -1,5 +1,5 @@
SECTIONS {
- .m68k_fixup : {
+ .m68k_fixup 0 : {
__start_fixup = .;
*(.m68k_fixup)
__stop_fixup = .;
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] module, riscv: force sh_addr=0 for arch-specific sections
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
` (2 preceding siblings ...)
2026-03-27 7:59 ` [PATCH 3/4] module, m68k: " Petr Pavlu
@ 2026-03-27 7:59 ` Petr Pavlu
2026-05-26 23:40 ` [PATCH 0/4] module: " Sami Tolvanen
4 siblings, 0 replies; 6+ messages in thread
From: Petr Pavlu @ 2026-03-27 7:59 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Sami Tolvanen
Cc: Alexandre Ghiti, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Aaron Tomlin, Joe Lawrence, linux-arm-kernel, linux-m68k,
linux-riscv, linux-modules, linux-kernel
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 riscv-specific module sections.
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33958 [1]
Signed-off-by: Petr Pavlu <petr.pavlu@suse•com>
---
arch/riscv/include/asm/module.lds.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/include/asm/module.lds.h b/arch/riscv/include/asm/module.lds.h
index 1075beae1ac6..9ced27c8ccb6 100644
--- a/arch/riscv/include/asm/module.lds.h
+++ b/arch/riscv/include/asm/module.lds.h
@@ -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
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] module: force sh_addr=0 for arch-specific sections
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
` (3 preceding siblings ...)
2026-03-27 7:59 ` [PATCH 4/4] module, riscv: " Petr Pavlu
@ 2026-05-26 23:40 ` Sami Tolvanen
4 siblings, 0 replies; 6+ messages in thread
From: Sami Tolvanen @ 2026-05-26 23:40 UTC (permalink / raw)
To: Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Petr Pavlu
Cc: Alexandre Ghiti, Luis Chamberlain, Daniel Gomez, Aaron Tomlin,
Joe Lawrence, linux-arm-kernel, linux-m68k, linux-riscv,
linux-modules, linux-kernel
On Fri, 27 Mar 2026 08:58:59 +0100, Petr Pavlu wrote:
> 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.
>
> [...]
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: 04e17ca3f77e1722a5db068fbcd7b93c51656013
Best regards,
Sami
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-26 23:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 7:58 [PATCH 0/4] module: force sh_addr=0 for arch-specific sections Petr Pavlu
2026-03-27 7:59 ` [PATCH 1/4] module, arm: " Petr Pavlu
2026-03-27 7:59 ` [PATCH 2/4] module, arm64: " Petr Pavlu
2026-03-27 7:59 ` [PATCH 3/4] module, m68k: " Petr Pavlu
2026-03-27 7:59 ` [PATCH 4/4] module, riscv: " Petr Pavlu
2026-05-26 23:40 ` [PATCH 0/4] module: " Sami Tolvanen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox