Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1727374rdh; Tue, 26 Sep 2023 01:23:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpvnU9M0G3l4vwRWKoSQHD5NZCn3bI1P7X69XjVnzEZIXG4hFTA7Kt7m0scdm4An7DsUVb X-Received: by 2002:a05:6a20:1606:b0:152:4615:cb9d with SMTP id l6-20020a056a20160600b001524615cb9dmr3387348pzj.12.1695716585275; Tue, 26 Sep 2023 01:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695716585; cv=none; d=google.com; s=arc-20160816; b=cBZbNG1IZyQkwb1cP1Wjh+7BrUy7nsg6+ECcb4CYB99IS5hUAl80AbJDXLsAP8vsfy tTbaXtQd1XXJM1EQX5m1Ko2xEfuHClGIMD0oD3yJFGEHhrE+vblM5y58BtbKKKk8I1+r BYcmQXhCg2xQdZ1FlqxqOWT5Cs4nAoPl/CmWXghYZHroobauQSPiYfMX67bsYyagbDAk C4vgf4xFGbSnZ9vkVr9geayq2/jsAt1XFAMZ8tuOeohxglttWDdb4OMDA1ZCUT5345+U E6Erbr3E0C5C6ZdrLdsKJwl+mB3MtVR53245ioH04haSkdN6DvPU5+Gqh5sStFK91+1E b4GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=3vGzu1JsizV09Lx0xR5Eo73X+gCg/4s8eoTfir4guEQ=; fh=NSlpVmp9/EqeSZuKfEjg6u7FbKTTBBKQRa+lb1eLM7c=; b=DqxT1epBmECW2xTJrGjdCe6CbhdoaoBZ2jjmLz4EPUc8YIcnHDI+Kl88YFkg87VUag eigoL5a5MMQ1g7/IiH85ank2u85yk0BJdqxduAaSWHPK66WaijhN0vi5Xia1hORT+JMI n8slWSQxKa8fHPras8tckqUYnlJq5PmYY+bJuTQtoFU5YNLbXJnUqjQYHhOTSUkAEbih nDEHKx+T81Yo6ciSzJ7NbukNN76gAzspd+h+4KVqgDLWTuQaNJD7BK2fUlK8idvB9e6F 9AuSaq9ggJavtaKEBoU2mquByVQ5KG1JS/Lrvi25xqYpf3+3OlCthU5bv+QuG3hB8rsF Tuww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id br4-20020a056a00440400b006880a2ca0fasi11597398pfb.312.2023.09.26.01.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 01:23:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D268C819474E; Tue, 26 Sep 2023 01:11:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233877AbjIZILN (ORCPT + 99 others); Tue, 26 Sep 2023 04:11:13 -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== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 01:11:16 -0700 (PDT) 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=binutils-gdb.git;a=commit;h=ecb802d02eeb 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; } +static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_Addr v, + s64 *rela_stack, size_t *rela_stack_top, unsigned int type) +{ + ptrdiff_t offset = (void *)v - (void *)location; + + *(u64 *)location = 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[] = { [R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub, [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala, [R_LARCH_32_PCREL] = apply_r_larch_32_pcrel, + [R_LARCH_64_PCREL] = apply_r_larch_64_pcrel, }; int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, -- 2.1.0