Received: by 2002:ac0:b7d5:0:0:0:0:0 with SMTP id v21csp117300ime; Thu, 28 Jul 2022 19:29:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txp58K8ibYVc22p0bujCT3enfNNIcdv3nOdPGxuV+8xNrjEZzlouwEopvEUZvS5SfILpHT X-Received: by 2002:a17:907:980d:b0:72f:2cf2:9aff with SMTP id ji13-20020a170907980d00b0072f2cf29affmr1245877ejc.165.1659061741247; Thu, 28 Jul 2022 19:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659061741; cv=none; d=google.com; s=arc-20160816; b=bZJJo0fS1ttIOfixKMPNx3ANZ/IjPACQe+V3vDc5lnQdkgbjHh6kBA0/euIMbzhNIA Mwyb7+gQcuNBlKNWVRYqpip54yvEfVregW8lWVvo3+tDZr5FwuTHT1U7BWDRa9yRgx68 AWwzNrYdzlmnTWiLbTYwJ4KuEOdQXBAlg36dBIDU3F/Wy+VSjtIf6Y7kIWVORWvm3mR1 qKb4rky9LzucFinPxaE2QQh5P2Ak27sqN/rq2epFtwdhdUwhQ2L+QF7z96U6k7WFx8mX DHQpRPszW14hCglXVe4kK0p1bZUB4rRTkP78wafrB4bY8dp5T2Bc8+LTEyO41Mzc9X9G NhxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=lR/CyNzvSIHqPfUxWsDX2qw91Y1VIj5HwGHzCfBG6+c=; b=di9/2jRkAWn4+iZXUnoP0b5vGvX3/R2UFvvltRJl6wY5aCgWAl7OaFeK4LBLz/PZ9I JOulCKGEhDJ4Ftvip89nvPmbrCpXALQh/SYqokYCZjs92uvEgNClBFWO2SMZPkxWPNo4 xPRoCPXO1JYshJTiQ/tzkjx4QDidoQSxqVS8Tjc3l7Q9S6NcJpts1yNbByZZK6EVDW7B ZGG437nIMK0AbuYT7mbcOFMNmST84F/7NhmgwyEMewhR1H3Y7qCGSVVyvgG4fqvHMffm d15OeWjwIdug3B/SKmCrp6h88nhKTlgz+lAb+wP6rGEx/gfboYmeD61KWnOd9M/YAcjj Ku7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=gwlf0iYH; 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=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt2-20020a170907728200b006fed9376071si2397983ejc.13.2022.07.28.19.28.37; Thu, 28 Jul 2022 19:29:01 -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=@xry111.site header.s=default header.b=gwlf0iYH; 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=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231636AbiG2CI6 (ORCPT + 99 others); Thu, 28 Jul 2022 22:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiG2CIz (ORCPT ); Thu, 28 Jul 2022 22:08:55 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 072E532DA6 for ; Thu, 28 Jul 2022 19:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1659060534; bh=qVACV7bz4zGf1t3CnRp5Cj62T95tqtofD76Q2nBE43Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=gwlf0iYHJ0ResOx2sIfRr4pm6x2RVTj7g5i52O9KPRcns5ytqOhv520VajLerTvYa SXkvS7RXuADBnr9OUj/aPDmOvVWBir2z4e3cK7Wvl/N2aKyk12kvWaszY1Nw3PRNck K01+09VKFrLnKhh8wl4XiggS0USMd6QZMJokxnqk= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 5D3DE65929; Thu, 28 Jul 2022 22:08:53 -0400 (EDT) Message-ID: Subject: [PATCH v3 2/4] LoongArch: Support R_LARCH_SOP_PUSH_GPREL relocation type in kernel module From: Xi Ruoyao To: loongarch@lists.linux.dev Cc: linux-kernel@vger.kernel.org, WANG Xuerui , Huacai Chen , Youling Tang , Jinyang He Date: Fri, 29 Jul 2022 10:08:51 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 MIME-Version: 1.0 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS autolearn=no 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 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 mod= ule *mod, u32 *location, E return apply_r_larch_sop_push_pcrel(mod, location, v, rela_stack, rela_st= ack_top, type); } =20 +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 =3D module_emit_got_entry(mod, v); + ptrdiff_t offset =3D (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[] =3D { [R_LARCH_SOP_PUSH_PCREL] =3D apply_r_larch_sop_push_pcrel, [R_LARCH_SOP_PUSH_ABSOLUTE] =3D apply_r_larch_sop_push_absolute, [R_LARCH_SOP_PUSH_DUP] =3D apply_r_larch_sop_push_dup, + [R_LARCH_SOP_PUSH_GPREL] =3D apply_r_larch_sop_push_gprel, [R_LARCH_SOP_PUSH_PLT_PCREL] =3D apply_r_larch_sop_push_plt_pcrel, [R_LARCH_SOP_SUB ... R_LARCH_SOP_IF_ELSE] =3D apply_r_larch_sop, [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] =3D apply_r_larch_so= p_imm_field, --=20 2.37.0