Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1727274rdh; Tue, 26 Sep 2023 01:22:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXfEowMklw4jnSw7QA2rYBlF/UW44PNvIcPe0eUf8S+oHJ4aRFdJmw38xBdApE5ihpI2B7 X-Received: by 2002:a17:902:694b:b0:1c4:636:51ef with SMTP id k11-20020a170902694b00b001c4063651efmr7419019plt.30.1695716568920; Tue, 26 Sep 2023 01:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695716568; cv=none; d=google.com; s=arc-20160816; b=G9hPbyO9a0VdACbVXFFCsP3N+Q872Yr9gTf0k9LpmPrzEhaRhd9+DkHECPngyfl3fk LkgkkPWyBknoUbGn8CarB61FB1R4IL+jnXIupJZ/zRhNu/j51WyN98STfB1ev9q3cW/G YxlyZm1SXBX6UbVxLkUhlEzk8G+drCyDZ2YHK/m9Yj9s78gsCGgbV5RRuOPhq8nE+UBZ o1hcjQdpCV1wuzI0D3FR9DmqEPGik8W7+veFpacWQKwaJlCiWCLsTA+0C7YfVWP/Fbnk UXhh51hGQtnsL28t2E77QcVWBeUwA7Qgeb7JrJRUydeVvecEql7iK9O5QojySjCevTgM Gziw== 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=2GHhr4LC/Z5N+hinfHDvs7Kw3qOw8aH1tvfDvrdY6po=; fh=NSlpVmp9/EqeSZuKfEjg6u7FbKTTBBKQRa+lb1eLM7c=; b=1CjuuFvCjccpdWhVrLcRfuv9LOgrZYWQrREvplXRSuS4t1+KM1btRuuG46oynw8I0C UJ1XJBjDaP2Vqy/nwALevkNg1eZMzfYzwXX9MShrO5CyoLuL2bJodXAGG8V/U/pkTd/H BbmKyu4KQJI21iK0VTNMqJNQ6hRvVbdhAEdz+/GRE3as1SXSTe3rhgfVmTEwp/D6EM7y 1Kvv9jLSRqB6g4vXHI4wsQXAaaKsPDHAEEtyXC5et2MB71+kVtzX6PAt5x4ojpuJJu5O I/yKEnhJt/IYFcyy0KXjQRb6Twbyy1Zkw8gNUwy6Kn/9DqnA4Mmcu3YjNRH7L/WjiOtd dqkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n13-20020a170902d2cd00b001bc553d16e0si12520648plc.507.2023.09.26.01.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 01:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 12901836E5E6; Tue, 26 Sep 2023 01:11:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233889AbjIZILQ (ORCPT + 99 others); Tue, 26 Sep 2023 04:11:16 -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: AQAAf8Bxni8NkhJlnnoSAA--.37906S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr1xKw18uw43WFy8Kr1rGrX_yoW5XryDpF ZrCw4YgFW3JFn7ta1qva1DWr4rC3ykWa47Xan8ZryxArnrAa4Yyw18tFn8K3y0yr1Fgryx Xry0g3Z3Aa1rCagCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 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 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 01:11:21 -0700 (PDT) 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 support. kmod: ipmi_msghandler: Unsupport relocation type 99, please add its support. kmod: pstore: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. 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=binutils-gdb.git;a=commit;h=ecb802d02eeb 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); } +static int apply_r_larch_32_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; + + *(u32 *)location = 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[] = { [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field, [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, }; int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, -- 2.1.0