Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp430699imn; Thu, 28 Jul 2022 05:18:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vuxy3jtW0OVU/q54bvFiFb7nfLby8ziO5JIwV5GiMeMYe/KsUe4qbNkApSbALNm+7ltXU0 X-Received: by 2002:a17:906:478c:b0:72f:3240:f632 with SMTP id cw12-20020a170906478c00b0072f3240f632mr20831168ejc.336.1659010698983; Thu, 28 Jul 2022 05:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659010698; cv=none; d=google.com; s=arc-20160816; b=o4ocOYKxSxS8awyqNuKB89Pe111Hrl5tOPj2qlVgxLq4eDwJG65YAs6bAjAA7P7pSj YKDnYhqJN/g+u5vRMtUpNTx2vcUZHrLI7WNbRfDua6W8cXSOyRu/xlcimGt3P+S3CjsK fLJcDQefKhn38YCJx6NvghtFazMrIPy8EefRI/OTslxQNZA//DTmV4PCsgWEoWFGG+br oYyD/0DzZp35d5cP/SnjBeDFtOgVp8wqZO/hasmx+EeyeXT/o2V1AgAJlZ8f3WWCNtHg VQbM6l65Hj1O17ZzZl64Davjn5l+KJ6u6LQd0cjJM05XvFxtKk4c3XwaenRdTPdwfd1z ajwQ== 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=OKwGaJgyCAJFNFgeXqkMqs6xGwPCZuN02b7kD7JEv+YREs3anFf1C96fW++oEbGZEn 8jVu+zMvFLIBgUN2c5WepANaGtOx3cGy29PAY5aUDCjXdRf1aDpnwVbvzQX1GA/zwgwr Lg/UVwa3ZNrNKd6rjDW9TVNzr9ag5RtIeHSRJ4DXuwCAsSOtsOhDjsnZv/HCNS14IVuy tSrTk+HTYffkdydqlbl8ecnaAi8mCMtZg5XF0w6soZQss8z9wIIzVw3NV0k7mdlaUedv pBCnOebvMYDODSbJpuoHG4GF9oYaC1Et86FzySJcXSL9QMM9i67wNM5ej4TaGp6a0eux 4vwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=XXHKtBMh; 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 qp28-20020a170907207c00b0072b2e339b71si498964ejb.429.2022.07.28.05.17.53; Thu, 28 Jul 2022 05:18:18 -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=XXHKtBMh; 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 S236702AbiG1L74 (ORCPT + 99 others); Thu, 28 Jul 2022 07:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235732AbiG1L7z (ORCPT ); Thu, 28 Jul 2022 07:59:55 -0400 Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A375691CD for ; Thu, 28 Jul 2022 04:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1659009591; bh=qVACV7bz4zGf1t3CnRp5Cj62T95tqtofD76Q2nBE43Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XXHKtBMhzfQTjSB2WKW9ZpbxkEhzEZCCiGRXL7jeNJm7qnLQXvgv1nvwg2NEBYzMl pOBTsjrKoGSjDq5DlF63KUPFSmqXYcoteQW1Y4jTNlLfjhSuCVBPDrP9CGX7vhLUlF /7j/viIcj30zowF8dtRnS0inJWtUeyiKXi/urBDI= 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 5346C6695D; Thu, 28 Jul 2022 07:59:50 -0400 (EDT) Message-ID: <81c67c5f4c5f20fa5e6862f260884c61cafcaf93.camel@xry111.site> Subject: [PATCH 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: Thu, 28 Jul 2022 19:59:48 +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