Message ID | 20230710050024.2519893-1-chenhuacai@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4792869vqx; Sun, 9 Jul 2023 22:22:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCGPwBlFYhIL/9tDQscbSmyqBuoXL0R6iRRRpfHTJoNZJjQbfsVKpYi7HIeXIJSGfZoFB+ X-Received: by 2002:a92:d492:0:b0:346:8b3:7aca with SMTP id p18-20020a92d492000000b0034608b37acamr11017787ilg.21.1688966577337; Sun, 09 Jul 2023 22:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688966577; cv=none; d=google.com; s=arc-20160816; b=lTledWzIUAJsrkBd0N89X74YIa/+ow+v+21vbJqvGej5T2xoM/LgLWVGqsUNOs5oS2 /W8CYJUJUs8rGopB8Usd4ji7eyr1JswCSozak+0VfZwPr6zBkXcSylsATqXUGb7Z4nfN HNhzR2aqA1142HfiWtCTieda1MI/94EOlYafI+FKavhv/PTeICAzfIzCEdXdg2+KImDg 9ijwj0rmahwDFgbRI0dyNw9a3KjPFyqnwts5g0pCvF2tzJX+MysB6AoFep3xjRqWRbBF 3A4+IaUnpDmDcUA3I0qFsid9Ap6OfQxEev7mPQlRZ+E7uiF7b7Cvu1S/krkw21J8fO9Y UiKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hiEc2NX8GSmkzQovw26WDLgx+s6NrhQxGUW8I/DI88c=; fh=9srzircU042t1leULFVTFCAnjtIpxGD2sOXDf0x4B6Q=; b=YfRqSaCpU83tMqc6ipPfxDySfMrPiwyWz7CWi1fQ3z3hwbvyj9bOuL57/8NDZJYzU8 B2GaaPYiXt3m/bMF7IeWEYNtdGF499SHUjQgdtVWliM3r+bree+bajCR2bhFwOiB1GnT +1hf+Oi841OB/H7zeqaEZEBtAMDxn13Yz3ZDM6Hcmw0uz2A4ikYf1q323gm8V3BSYNdU bPTrWa+69xMY4bmIOqlfcgkRbM+EEBBVaSYWLbAKt6pdvmJTrjeDv5pRPG77vbcWTlwE bW5JEf6JFs759EhycBzmZ83QG1J9CO6x8LucJ9QeqxsA6a77DnBtEaRmPVEQNDjuR2bw 7nPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a170903200c00b001b8946f3f95si7660063pla.312.2023.07.09.22.22.41; Sun, 09 Jul 2023 22:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjGJFAj (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Mon, 10 Jul 2023 01:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGJFAh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 10 Jul 2023 01:00:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8C3BC; Sun, 9 Jul 2023 22:00:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9EC0B60B90; Mon, 10 Jul 2023 05:00:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4498CC433C7; Mon, 10 Jul 2023 05:00:31 +0000 (UTC) From: Huacai Chen <chenhuacai@loongson.cn> To: Arnd Bergmann <arnd@arndb.de>, Huacai Chen <chenhuacai@kernel.org> Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>, Xuerui Wang <kernel@xen0n.name>, Jiaxun Yang <jiaxun.yang@flygoat.com>, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen <chenhuacai@loongson.cn>, WANG Xuerui <git@xen0n.name> Subject: [PATCH V2] LoongArch: Fix module relocation error with binutils 2.41 Date: Mon, 10 Jul 2023 13:00:24 +0800 Message-Id: <20230710050024.2519893-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771009817859961056 X-GMAIL-MSGID: 1771009817859961056 |
Series |
[V2] LoongArch: Fix module relocation error with binutils 2.41
|
|
Commit Message
Huacai Chen
July 10, 2023, 5 a.m. UTC
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(+)
Comments
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
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 >
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
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.
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