Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp469852imn; Thu, 28 Jul 2022 06:23:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ufWJlt9AgbMfBk70r2h12ApYFeFon/lXBzbiENdqOChLE6Ljj7c7kxOdm9puO4G82Nzacm X-Received: by 2002:a05:6402:371a:b0:43a:ece9:ab8e with SMTP id ek26-20020a056402371a00b0043aece9ab8emr27324821edb.126.1659014622619; Thu, 28 Jul 2022 06:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659014622; cv=none; d=google.com; s=arc-20160816; b=hmxTYbGgYQeoh83h31A6oKHJ9irtvutJxxG+j5vY4cihvq9cJ1KeTr/UXuv8b9jSIw HG+lXcz6DMTwhMc0TjqO5YQjEk8ukzQpy9xq/lFtKoMpw2SUJszzSwR33+Q3XpQFsPAi PjxW6mplKeDdm241S80yTbNPkr4B6qpAR6TddzyXpKHIb5qq0l6IWVzL+C7BrKnzKJyt YuYI9BbBLydvUi4Y5sgDOtDrwO7O8Obkqj0qPr6C/vG4p5O3He+OWadJR3qNOXEFUs/9 kFAkZ5VBwnMRxWCyTjQMXRjobhFUEHU94gAGOL1rLAmTbVwqCbVz4HIXjSu3VaDqiHpY 7atA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TcNadAg14bbHF47H20HE6dCfNhp+i3HngJZKs6rcR+s=; b=ZOuCwbT+3gMZEurDaPvg5lvjlHLeEZWjVw4vApsS4MAl7p0PoUyAno5hdy42k3Suxt hhzADV5OGkr03F/7OBOiZgxV2CzbwtgcQgKBSIA7zae1ODG/ovuZRSL9zDpKSeZxzfR5 5aRMHrulbAfWGW15khxz/LBdo9ZCE24KN2tBCxWXMsAUIPo0PUZGE5eDwq5lSbGKY0iw jdGOpIs1slnre3VM/bRgv5CE5nvTTBDJOpA0Muotpm7LJx4Wg0jYy7CppcDkeSE8opCt ZErD3WiDND0bEKNbVaB/9zDeJP/KfpJ4hiA6j69xxMoObTcYfUx9pZDMJQKWRwTz+iNU b7zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mjrMP/MH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a50d08f000000b0043a707aa43fsi751395edd.201.2022.07.28.06.23.17; Thu, 28 Jul 2022 06:23:42 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mjrMP/MH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237422AbiG1Ma5 (ORCPT + 99 others); Thu, 28 Jul 2022 08:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238726AbiG1Mah (ORCPT ); Thu, 28 Jul 2022 08:30:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431394E63C for ; Thu, 28 Jul 2022 05:30:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EE474B82440 for ; Thu, 28 Jul 2022 12:30:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A10C4347C for ; Thu, 28 Jul 2022 12:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659011429; bh=iv54j1mHM1UKpygMWX9SMc2VsQtTs7Br5QyTcza7ZCI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mjrMP/MH712h+HhGvQQ1kymV+ulGFsQtzZ/Ijr94LT2WGjm/dNHxjCLy6bc2AkVP4 Evqy4l3EdkssdMZpfmDz+uhkFO0zUQcXykMkSO/T0aSe8+NZ4rMWV+2hY9oKAIbvFU i9QIpps2+On3Ehw3kmrLq9M9BOp91RoDZO4FzGHv/vFBSlscDBHZ/Rzd1Pa6x65w/j tqjP2lvl0TfEDSXR0d+6c51F1KpFVHUZwT97l7KuaZ2cLp2qUkjGgo4iIuVB88PFiv IkkDEgYEwdqeq1tcvAXWwTyWGmpbxouGT1lqCQMc6cendhkCsno6p3QSAigjyNeJF/ JlsPjXRq3X5Jw== Received: by mail-vs1-f52.google.com with SMTP id t28so1447080vsr.11 for ; Thu, 28 Jul 2022 05:30:29 -0700 (PDT) X-Gm-Message-State: AJIora8n/vhkfkbj0u8YdA8+/iLgEvW9bu5eM6WqqUHxqRYFudXAl7d2 BP0gUfFQiHyLtrfCLglrRgMXbosUhpcg8LFT+yc= X-Received: by 2002:a67:d599:0:b0:358:6371:4cfb with SMTP id m25-20020a67d599000000b0035863714cfbmr6290530vsj.78.1659011428530; Thu, 28 Jul 2022 05:30:28 -0700 (PDT) MIME-Version: 1.0 References: <81c67c5f4c5f20fa5e6862f260884c61cafcaf93.camel@xry111.site> In-Reply-To: <81c67c5f4c5f20fa5e6862f260884c61cafcaf93.camel@xry111.site> From: Huacai Chen Date: Thu, 28 Jul 2022 20:30:15 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] LoongArch: Support R_LARCH_SOP_PUSH_GPREL relocation type in kernel module To: Xi Ruoyao Cc: loongarch@lists.linux.dev, LKML , WANG Xuerui , Youling Tang , Jinyang He Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Hi, Ruoyao, Missing V2 in the title? Huacai On Thu, Jul 28, 2022 at 7:59 PM Xi Ruoyao wrote: > > This relocation type pushes the offset of the GOT entry for a symbol > from the beginning of GOT into the relocation stack. Our linker script > has initialized an empty GOT, so we need to create a new GOT entry if > there is no exist one for a symbol. > > Signed-off-by: Xi Ruoyao > --- > arch/loongarch/kernel/module.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c > index 638427ff0d51..3ac4fbb5f109 100644 > --- a/arch/loongarch/kernel/module.c > +++ b/arch/loongarch/kernel/module.c > @@ -122,6 +122,16 @@ static int apply_r_larch_sop_push_plt_pcrel(struct module *mod, u32 *location, E > return apply_r_larch_sop_push_pcrel(mod, location, v, rela_stack, rela_stack_top, type); > } > > +static int apply_r_larch_sop_push_gprel(struct module *mod, u32 *location, > + Elf_Addr v, s64 *rela_stack, size_t *rela_stack_top, > + unsigned int type) > +{ > + Elf_Addr got = module_emit_got_entry(mod, v); > + ptrdiff_t offset = (void *)got - (void *)mod->arch.got.shdr->sh_addr; > + > + return rela_stack_push(offset, rela_stack, rela_stack_top); > +} > + > static int apply_r_larch_sop(struct module *mod, u32 *location, Elf_Addr v, > s64 *rela_stack, size_t *rela_stack_top, unsigned int type) > { > @@ -306,6 +316,7 @@ static reloc_rela_handler reloc_rela_handlers[] = { > [R_LARCH_SOP_PUSH_PCREL] = apply_r_larch_sop_push_pcrel, > [R_LARCH_SOP_PUSH_ABSOLUTE] = apply_r_larch_sop_push_absolute, > [R_LARCH_SOP_PUSH_DUP] = apply_r_larch_sop_push_dup, > + [R_LARCH_SOP_PUSH_GPREL] = apply_r_larch_sop_push_gprel, > [R_LARCH_SOP_PUSH_PLT_PCREL] = apply_r_larch_sop_push_plt_pcrel, > [R_LARCH_SOP_SUB ... R_LARCH_SOP_IF_ELSE] = apply_r_larch_sop, > [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field, > -- > 2.37.0 > > >