From nobody Fri Feb 13 12:33:05 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: p1dqw3xlh2x3g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VAFwI0_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