From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from xry111.site (xry111.site [89.208.246.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 154C97A for ; Thu, 28 Jul 2022 06:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1658990480; bh=fDQSFbUZY0M91qUtS+Iv4m66BChIz9OnKWn9rwXW7a8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=EL+39Ph7bEITu8PzwGES+iF6ugZ9jlOeunCVSXGJ/r1RIVqM3360AImW/NUIrgarS tvBU4piCpYWB1LawjkV0fIrMdUepuC7gXpV16UmhLKp1tmcYOs72hjXAQ0GvBg5Nqo AQVwO0r1Sh+qFccIn8+RxdKMUj1TnYecvIwKA4Qg= 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 D8A62669E8; Thu, 28 Jul 2022 02:41:18 -0400 (EDT) Message-ID: <9a79a424a11339ae025539c38fe121104ff00804.camel@xry111.site> Subject: Re: [PATCH 3/5] LoongArch: Support relocation against _GLOBAL_OFFSET_TABLE_ From: Xi Ruoyao To: Jinyang He , loongarch@lists.linux.dev Cc: linux-kernel@vger.kernel.org, WANG Xuerui , Huacai Chen Date: Thu, 28 Jul 2022 14:41:16 +0800 In-Reply-To: <10c1e0f9-8409-a0f4-9b18-a5f56dfb14e1@loongson.cn> References: <385f63bcbee8e37c42f479ce9cdc7e7d731d419b.camel@xry111.site> <99733532831377ab6585d43ee40bf314a2d4c5a3.camel@xry111.site> <10c1e0f9-8409-a0f4-9b18-a5f56dfb14e1@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 Precedence: bulk X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2022-07-28 at 09:02 +0800, Jinyang He wrote: > Hi, Ruoyao, >=20 > It is possible to create a symbol when linking, which means > maybe we can add _GLOBAL_OFFSET_TABLE_ in 'module.lds.h'. > What do you think about it? Hi Jinyang, I think you are right, this patch can be replaced with the following, which is much simpler. -- >8 -- With the stack-based relocations, the assembler emits three relocations to push the PC-relative offset of a GOT entry: R_LARCH_SOP_PUSH_PCREL _GLOBAL_OFFSET_TABLE_ R_LARCH_SOP_PUSH_GPREL foo R_LARCH_SOP_ADD In normal relocatable ELF object files, "_GLOBAL_OFFSET_TABLE_" is undefined in the symtab and the BFD linker generates it on final link. Define it for kernel modules so we will be able to really use R_LARCH_SOP_PUSH_GPREL relocation. Note that we need to use "HIDDEN" to make it a local symbol because each kernel module has its own GOT and the reference to it should not be resolved to the GOT in the main kernel image. Suggested-by: Jinyang He Signed-off-by: Xi Ruoyao --- arch/loongarch/include/asm/module.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/include/asm/module.lds.h b/arch/loongarch/inclu= de/asm/module.lds.h index 57bbd0cedd26..42b7cca0b947 100644 --- a/arch/loongarch/include/asm/module.lds.h +++ b/arch/loongarch/include/asm/module.lds.h @@ -4,5 +4,5 @@ SECTIONS { . =3D ALIGN(4); .plt : { BYTE(0) } .plt.idx : { BYTE(0) } - .got : { BYTE(0) } + .got : { HIDDEN(_GLOBAL_OFFSET_TABLE_ =3D .); BYTE(0) } } --=20 2.37.0