mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41
@ 2023-07-10  5:00 Huacai Chen
  2023-08-10  3:20 ` Xi Ruoyao
  0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2023-07-10  5:00 UTC (permalink / raw)
  To: Arnd Bergmann, Huacai Chen
  Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, loongson-kernel, Huacai Chen,
	WANG Xuerui

Binutils 2.41 enables linker relaxation by default, but the kernel
module loader doesn't support that, so just disable it. Otherwise we
get such an error when loading modules:

"Unknown relocation type 102"

As an alternative, we could add linker relaxation support in the kernel
module loader. But it is relatively large complexity that may or may not
bring a similar gain, and we don't really want to include this linker
pass in the kernel.

Reviewed-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/loongarch/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 09ba338a64de..7466d3b15db8 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -68,6 +68,8 @@ LDFLAGS_vmlinux			+= -static -n -nostdlib
 ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
 cflags-y			+= $(call cc-option,-mexplicit-relocs)
 KBUILD_CFLAGS_KERNEL		+= $(call cc-option,-mdirect-extern-access)
+KBUILD_AFLAGS_MODULE		+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
+KBUILD_CFLAGS_MODULE		+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
 else
 cflags-y			+= $(call cc-option,-mno-explicit-relocs)
 KBUILD_AFLAGS_KERNEL		+= -Wa,-mla-global-with-pcrel
-- 
2.39.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41
  2023-07-10  5:00 [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41 Huacai Chen
@ 2023-08-10  3:20 ` Xi Ruoyao
  2023-08-10  3:21   ` Xi Ruoyao
  0 siblings, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2023-08-10  3:20 UTC (permalink / raw)
  To: Huacai Chen, Arnd Bergmann, Huacai Chen
  Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, loongson-kernel, WANG Xuerui, stable

Can we backport this patch into stable?  It fixes a build error with
binutils >= 2.41.

On Mon, 2023-07-10 at 13:00 +0800, Huacai Chen wrote:
> Binutils 2.41 enables linker relaxation by default, but the kernel
> module loader doesn't support that, so just disable it. Otherwise we
> get such an error when loading modules:
> 
> "Unknown relocation type 102"
> 
> As an alternative, we could add linker relaxation support in the kernel
> module loader. But it is relatively large complexity that may or may not
> bring a similar gain, and we don't really want to include this linker
> pass in the kernel.
> 
> Reviewed-by: WANG Xuerui <git@xen0n.name>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  arch/loongarch/Makefile | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> index 09ba338a64de..7466d3b15db8 100644
> --- a/arch/loongarch/Makefile
> +++ b/arch/loongarch/Makefile
> @@ -68,6 +68,8 @@ LDFLAGS_vmlinux                       += -static -n -nostdlib
>  ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
>  cflags-y                       += $(call cc-option,-mexplicit-relocs)
>  KBUILD_CFLAGS_KERNEL           += $(call cc-option,-mdirect-extern-access)
> +KBUILD_AFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
> +KBUILD_CFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
>  else
>  cflags-y                       += $(call cc-option,-mno-explicit-relocs)
>  KBUILD_AFLAGS_KERNEL           += -Wa,-mla-global-with-pcrel

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41
  2023-08-10  3:20 ` Xi Ruoyao
@ 2023-08-10  3:21   ` Xi Ruoyao
  2023-08-10  3:34     ` Huacai Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2023-08-10  3:21 UTC (permalink / raw)
  To: Huacai Chen, Arnd Bergmann, Huacai Chen
  Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, loongson-kernel, WANG Xuerui, stable

On Thu, 2023-08-10 at 11:20 +0800, Xi Ruoyao wrote:
> Can we backport this patch into stable?  It fixes a build error with
> binutils >= 2.41.

Correction: not a build error, but all modules won't load if built with
binutils >= 2.41 without the patch.

> On Mon, 2023-07-10 at 13:00 +0800, Huacai Chen wrote:
> > Binutils 2.41 enables linker relaxation by default, but the kernel
> > module loader doesn't support that, so just disable it. Otherwise we
> > get such an error when loading modules:
> > 
> > "Unknown relocation type 102"
> > 
> > As an alternative, we could add linker relaxation support in the kernel
> > module loader. But it is relatively large complexity that may or may not
> > bring a similar gain, and we don't really want to include this linker
> > pass in the kernel.
> > 
> > Reviewed-by: WANG Xuerui <git@xen0n.name>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >  arch/loongarch/Makefile | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> > index 09ba338a64de..7466d3b15db8 100644
> > --- a/arch/loongarch/Makefile
> > +++ b/arch/loongarch/Makefile
> > @@ -68,6 +68,8 @@ LDFLAGS_vmlinux                       += -static -n -nostdlib
> >  ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
> >  cflags-y                       += $(call cc-option,-mexplicit-relocs)
> >  KBUILD_CFLAGS_KERNEL           += $(call cc-option,-mdirect-extern-access)
> > +KBUILD_AFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
> > +KBUILD_CFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
> >  else
> >  cflags-y                       += $(call cc-option,-mno-explicit-relocs)
> >  KBUILD_AFLAGS_KERNEL           += -Wa,-mla-global-with-pcrel
> 

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41
  2023-08-10  3:21   ` Xi Ruoyao
@ 2023-08-10  3:34     ` Huacai Chen
  2023-08-10  3:54       ` Xi Ruoyao
  0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2023-08-10  3:34 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: Huacai Chen, Arnd Bergmann, loongarch, linux-arch, Xuefeng Li,
	Guo Ren, Xuerui Wang, Jiaxun Yang, linux-kernel, loongson-kernel,
	WANG Xuerui, stable

Hi, Ruoyao,

On Thu, Aug 10, 2023 at 11:21 AM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Thu, 2023-08-10 at 11:20 +0800, Xi Ruoyao wrote:
> > Can we backport this patch into stable?  It fixes a build error with
> > binutils >= 2.41.
>
> Correction: not a build error, but all modules won't load if built with
> binutils >= 2.41 without the patch.
Generally we can backport, but I don't think there are users who use
the old kernels. :)

Huacai
>
> > On Mon, 2023-07-10 at 13:00 +0800, Huacai Chen wrote:
> > > Binutils 2.41 enables linker relaxation by default, but the kernel
> > > module loader doesn't support that, so just disable it. Otherwise we
> > > get such an error when loading modules:
> > >
> > > "Unknown relocation type 102"
> > >
> > > As an alternative, we could add linker relaxation support in the kernel
> > > module loader. But it is relatively large complexity that may or may not
> > > bring a similar gain, and we don't really want to include this linker
> > > pass in the kernel.
> > >
> > > Reviewed-by: WANG Xuerui <git@xen0n.name>
> > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > > ---
> > >  arch/loongarch/Makefile | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> > > index 09ba338a64de..7466d3b15db8 100644
> > > --- a/arch/loongarch/Makefile
> > > +++ b/arch/loongarch/Makefile
> > > @@ -68,6 +68,8 @@ LDFLAGS_vmlinux                       += -static -n -nostdlib
> > >  ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
> > >  cflags-y                       += $(call cc-option,-mexplicit-relocs)
> > >  KBUILD_CFLAGS_KERNEL           += $(call cc-option,-mdirect-extern-access)
> > > +KBUILD_AFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
> > > +KBUILD_CFLAGS_MODULE           += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
> > >  else
> > >  cflags-y                       += $(call cc-option,-mno-explicit-relocs)
> > >  KBUILD_AFLAGS_KERNEL           += -Wa,-mla-global-with-pcrel
> >
>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41
  2023-08-10  3:34     ` Huacai Chen
@ 2023-08-10  3:54       ` Xi Ruoyao
  0 siblings, 0 replies; 5+ messages in thread
From: Xi Ruoyao @ 2023-08-10  3:54 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, Arnd Bergmann, loongarch, linux-arch, Xuefeng Li,
	Guo Ren, Xuerui Wang, Jiaxun Yang, linux-kernel, loongson-kernel,
	WANG Xuerui, stable

On Thu, 2023-08-10 at 11:34 +0800, Huacai Chen wrote:
> On Thu, Aug 10, 2023 at 11:21 AM Xi Ruoyao <xry111@xry111.site> wrote:
> > 
> > On Thu, 2023-08-10 at 11:20 +0800, Xi Ruoyao wrote:
> > > Can we backport this patch into stable?  It fixes a build error with
> > > binutils >= 2.41.
> > 
> > Correction: not a build error, but all modules won't load if built with
> > binutils >= 2.41 without the patch.
> Generally we can backport, but I don't think there are users who use
> the old kernels. :)

The problem is 6.4.x is not "so old": 6.4.9 is actually the latest
kernel release.  6.5.0 is not released yet.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-10  3:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10  5:00 [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41 Huacai Chen
2023-08-10  3:20 ` Xi Ruoyao
2023-08-10  3:21   ` Xi Ruoyao
2023-08-10  3:34     ` Huacai Chen
2023-08-10  3:54       ` Xi Ruoyao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®