From nobody Fri Feb 13 11:01:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE9B4E7D24D for ; Tue, 26 Sep 2023 08:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233818AbjIZILV (ORCPT ); Tue, 26 Sep 2023 04:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233864AbjIZILL (ORCPT ); Tue, 26 Sep 2023 04:11:11 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C48110A for ; Tue, 26 Sep 2023 01:11:02 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxyeoSkhJlRZUsAA--.10334S3; Tue, 26 Sep 2023 16:10:58 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxni8NkhJlnnoSAA--.37906S3; Tue, 26 Sep 2023 16:10:56 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v1 1/3] LoongArch: Define relocation types added in ABI v2.10 Date: Tue, 26 Sep 2023 16:10:50 +0800 Message-Id: <1695715852-15902-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> References: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Bxni8NkhJlnnoSAA--.37906S3 X-CM-SenderInfo: p1dqw3xlh2x3gn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VAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIev Ja73UjIFyTuYvjxU466zUUUUU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The relocation types from 101 to 109 are used by GNU binutils >=3D 2.41, add their definitions to use them in later patches. Link: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dblob;f=3Dinclude= /elf/loongarch.h#l230 Signed-off-by: Tiezhu Yang Cc: --- arch/loongarch/include/asm/elf.h | 9 +++++++++ arch/loongarch/kernel/module.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/include/asm/elf.h b/arch/loongarch/include/asm/= elf.h index 7af0ceb..b9a4ab5 100644 --- a/arch/loongarch/include/asm/elf.h +++ b/arch/loongarch/include/asm/elf.h @@ -111,6 +111,15 @@ #define R_LARCH_TLS_GD_HI20 98 #define R_LARCH_32_PCREL 99 #define R_LARCH_RELAX 100 +#define R_LARCH_DELETE 101 +#define R_LARCH_ALIGN 102 +#define R_LARCH_PCREL20_S2 103 +#define R_LARCH_CFA 104 +#define R_LARCH_ADD6 105 +#define R_LARCH_SUB6 106 +#define R_LARCH_ADD_ULEB128 107 +#define R_LARCH_SUB_ULEB128 108 +#define R_LARCH_64_PCREL 109 =20 #ifndef ELF_ARCH =20 diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c index b8b8608..c3f9d2f 100644 --- a/arch/loongarch/kernel/module.c +++ b/arch/loongarch/kernel/module.c @@ -382,7 +382,7 @@ typedef int (*reloc_rela_handler)(struct module *mod, u= 32 *location, Elf_Addr v, =20 /* The handlers for known reloc types */ static reloc_rela_handler reloc_rela_handlers[] =3D { - [R_LARCH_NONE ... R_LARCH_RELAX] =3D apply_r_larch_error, + [R_LARCH_NONE ... R_LARCH_64_PCREL] =3D apply_r_larch_error, =20 [R_LARCH_NONE] =3D apply_r_larch_none, [R_LARCH_32] =3D apply_r_larch_32, --=20 2.1.0 From nobody Fri Feb 13 11:01:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E1AFE7D24D for ; Tue, 26 Sep 2023 08:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233893AbjIZILS (ORCPT ); Tue, 26 Sep 2023 04:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233859AbjIZILK (ORCPT ); Tue, 26 Sep 2023 04:11:10 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E167FF for ; Tue, 26 Sep 2023 01:11:02 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxnusTkhJlSZUsAA--.17710S3; Tue, 26 Sep 2023 16:10:59 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxni8NkhJlnnoSAA--.37906S4; Tue, 26 Sep 2023 16:10:58 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v1 2/3] LoongArch: Add support for 32_PCREL relocation type Date: Tue, 26 Sep 2023 16:10:51 +0800 Message-Id: <1695715852-15902-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> References: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Bxni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W8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8EeHDUUUUU== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When build and update kernel with the latest upstream binutils and loongson3_defconfig, it can not start the system, the serial console shows "You are in emergency mode", there are more info like this: kmod: zsmalloc: Unsupport relocation type 99, please add its support. kmod: fuse: Unsupport relocation type 99, please add its support. kmod: ipmi_msghandler: Unsupport relocation type 99, please add its suppo= rt. kmod: ipmi_msghandler: Unsupport relocation type 99, please add its suppo= rt. kmod: pstore: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its su= pport. kmod: drm_display_helper: Unsupport relocation type 99, please add its su= pport. kmod: drm_display_helper: Unsupport relocation type 99, please add its su= pport. kmod: fuse: Unsupport relocation type 99, please add its support. kmod: fat: Unsupport relocation type 99, please add its support. This is because the latest upstream binutils replaces a pair of ADD32 and SUB32 with 32_PCREL, so add support for 32_PCREL relocation type. Link: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Decb80= 2d02eeb Co-developed-by: Youling Tang Signed-off-by: Youling Tang Signed-off-by: Tiezhu Yang Cc: --- arch/loongarch/kernel/module.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c index c3f9d2f..9e10c44 100644 --- a/arch/loongarch/kernel/module.c +++ b/arch/loongarch/kernel/module.c @@ -367,6 +367,15 @@ static int apply_r_larch_got_pc(struct module *mod, return apply_r_larch_pcala(mod, location, got, rela_stack, rela_stack_top= , type); } =20 +static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_A= ddr v, + s64 *rela_stack, size_t *rela_stack_top, unsigned int type) +{ + ptrdiff_t offset =3D (void *)v - (void *)location; + + *(u32 *)location =3D offset; + return 0; +} + /* * reloc_handlers_rela() - Apply a particular relocation to a module * @mod: the module to apply the reloc to @@ -396,6 +405,7 @@ static reloc_rela_handler reloc_rela_handlers[] =3D { [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] =3D apply_r_larch_so= p_imm_field, [R_LARCH_ADD32 ... R_LARCH_SUB64] =3D apply_r_larch_add_sub, [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] =3D apply_r_larch_pcala, + [R_LARCH_32_PCREL] =3D apply_r_larch_32_pcrel, }; =20 int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, --=20 2.1.0 From nobody Fri Feb 13 11:01:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEA7BE7D24D for ; Tue, 26 Sep 2023 08:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233881AbjIZILP (ORCPT ); Tue, 26 Sep 2023 04:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233853AbjIZILK (ORCPT ); Tue, 26 Sep 2023 04:11:10 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB9B5E4 for ; Tue, 26 Sep 2023 01:11:02 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxuOgUkhJlTZUsAA--.49546S3; Tue, 26 Sep 2023 16:11:00 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxni8NkhJlnnoSAA--.37906S5; Tue, 26 Sep 2023 16:10:59 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v1 3/3] LoongArch: Add support for 64_PCREL relocation type Date: Tue, 26 Sep 2023 16:10:52 +0800 Message-Id: <1695715852-15902-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> References: <1695715852-15902-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8Bxni8NkhJlnnoSAA--.37906S5 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxJr43Kryrury7ZrWDZr1xtFc_yoW8Zw43pr yfAwnxXa1fKFn7Xayqv3WkWw1rWaykW342ga9a9r97ArnxJFyj9w1xtryDtayjvrs5uF4r ZryIq3WrZanrAwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8EeHDUUUUU== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When build and update kernel with the latest upstream binutils and loongson3_defconfig, the serial console works well with the previous 32_PCREL patch, but it can not enter the graphical interface due to it failed to start lightdm service, there are more info like this: kmod: zsmalloc: Unknown relocation type 109 kmod: fuse: Unknown relocation type 109 kmod: fuse: Unknown relocation type 109 kmod: radeon: Unknown relocation type 109 kmod: nf_tables: Unknown relocation type 109 kmod: nf_tables: Unknown relocation type 109 This is because the latest upstream binutils replaces a pair of ADD64 and SUB64 with 64_PCREL, so add support for 64_PCREL relocation type. Link: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Decb80= 2d02eeb Signed-off-by: Tiezhu Yang Cc: --- arch/loongarch/kernel/module.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c index 9e10c44..b13b285 100644 --- a/arch/loongarch/kernel/module.c +++ b/arch/loongarch/kernel/module.c @@ -376,6 +376,15 @@ static int apply_r_larch_32_pcrel(struct module *mod, = u32 *location, Elf_Addr v, return 0; } =20 +static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_A= ddr v, + s64 *rela_stack, size_t *rela_stack_top, unsigned int type) +{ + ptrdiff_t offset =3D (void *)v - (void *)location; + + *(u64 *)location =3D offset; + return 0; +} + /* * reloc_handlers_rela() - Apply a particular relocation to a module * @mod: the module to apply the reloc to @@ -406,6 +415,7 @@ static reloc_rela_handler reloc_rela_handlers[] =3D { [R_LARCH_ADD32 ... R_LARCH_SUB64] =3D apply_r_larch_add_sub, [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] =3D apply_r_larch_pcala, [R_LARCH_32_PCREL] =3D apply_r_larch_32_pcrel, + [R_LARCH_64_PCREL] =3D apply_r_larch_64_pcrel, }; =20 int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, --=20 2.1.0