From patchwork Tue Oct 15 09:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 1997288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=wE2KScxc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSTqt6d58z1xsc for ; Tue, 15 Oct 2024 20:50:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1833C3858C39 for ; Tue, 15 Oct 2024 09:50:49 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from out203-205-221-210.mail.qq.com (out203-205-221-210.mail.qq.com [203.205.221.210]) by sourceware.org (Postfix) with UTF8SMTPS id 485843858D21 for ; Tue, 15 Oct 2024 09:50:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 485843858D21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cyyself.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 485843858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=203.205.221.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728985828; cv=none; b=S6Z3ET9NTY3B9OsxRQxRymLpg4aVxJhC7qD6EVG5hoFxefepoL6NFumh/4ZOQetqqaYysFg6ggmpRaInKrIrcW64x8baS/K3eon3Ey+yDbGR43HTKcklCldoX9LyBm5YR6JltWxD2wwIfScIf4LedTPCNHvFSk81kHNrVpWVDjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728985828; c=relaxed/simple; bh=ilSK6Q2dQ/bGunP+iR/bC8qWhQm67z2hW0WHcKbJZlQ=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=RPMsN6jZnSeJFNqpuZ7h0WKRRgg7RJRtAvnwm8FcV4skBU2ZggmPF8kglBFbFaV/84++ANJ6WTDDztUcV7a5SsWxsZDpULi2kckKsN+QpTs42HpGHa7k36cDMKoECcDgagMiAaMioCeFGj7d21mpaiz+FuAWYPzi6WdRu+rVMy0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1728985819; bh=ogepeqbMvMf9LQVeqQTl1rvoeXmsrE/aX/eLXhzDZ2A=; h=From:To:Cc:Subject:Date; b=wE2KScxcVs1cqZhblQuv//OUDLHOzLfYjV2aY54Dmu2ueeqfk+yfLdqywHnInChIz tkPfe38S8OQNrsIshTiYvpNbCHwVocZx6cqbmef6EQxZy6/0t3gzyjjaoPcM7iAiAr tcSEcBzjZfr8rsNmFSXIepJGZw69hUsikw9VnbLU= Received: from cyy-pc.lan ([240e:379:224e:6200:46fa:4c95:3ace:1c9d]) by newxmesmtplogicsvrsza15-1.qq.com (NewEsmtp) with SMTP id C5A8DACB; Tue, 15 Oct 2024 17:49:26 +0800 X-QQ-mid: xmsmtpt1728985766tkfwje1y8 Message-ID: X-QQ-XMAILINFO: OQhZ3T0tjf0aahC/3F2RyV47o1N6qYqVOCETMlJIPRi10mPF1t2TOGYok1i6zA 3HLKG1TePmR3hxgOQ9FTVu6V5a7kwicNFA/TVr/A/8p5YERlghfkZ+X98EC+//w9EWI2au5yaMh3 FRrHb7mJoqoDLtO7pHc4eZmYs/1flXbvL3FatI7hMTmkTvzF7kY2bu0K5XROmvfcdIOFgJNfBpMg z787iTZ8NhKTwg2oNzeSxKtN7m7kbig6o+ZwZ5eq5MaHoc579khz45h0geMUXoSw5E566SgRDARU W5WVRnNywoBOdVPqoe6maS9s6O1T2FmM8xvkWwvk9dJSGWe8L7OzmpRfZF1VXfARwVpksiSQXXw8 +ReRipg1Y9WxR/P/4E3IPoFmhaahM4y81mhxtHsDuNJjiqF/BN/kE/kJ0pcjEETT7cEZWMfyAX5T T1SCCQuuMydr7cuBm2S16I1rVjUJ41nd1SQAzQsEBLMFsaUwvKJHIVCRSZgPme94g05g0+T1Q/Ws wZ906p+9ehdbG93jrqnNtT7CmBASwGlsV295L+jc6Xnqb+tGoSwcCTRqc1hfZbVLjzvVNcS3tqEW gOwAKjuWTeRTBE6+4paTPEAcO9MBnwj/6wL8lFfx1cdmpYjglYbQNJXClL+BjSQFseu7UKR9E4uN ZP1GoTPC++CO0so0arXD9NKT40qY6bUJXEHa8ZBig6fuyYs+byT8E1fQIBytxL1IH0t8IyBYdYqV PNw8wYILud8z13JZaZMPeeNoy1F39xX8gU11+SIpccYUJGPEgsf9FWIXCi7dl/YE8108XDX7fP3Y v1AvWAwHnFC3D28evKcfTY/04VvqtMML2TJDy4xPGkGcNW0kndKnQj3BtxEU3Y78S/t9U2oNivwo k2tBuujWiA6VIpQ4nxMYR88JNbxlO7X7x8n1HMH1cstKBRa8Pwl57jDLRUmPItbylAy2pEaQMxVF LqH5K1h5PuhwFwrt8alef8F2nE1QITYkrnBFpXTxk9GkNyooK4ug== X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: Yangyu Chen To: libc-alpha@sourceware.org Cc: Palmer Dabbelt , Kito Cheng , Vincent Chen , Yangyu Chen Subject: [PATCH] RISC-V: Fix IFUNC resolver cannot access gp pointer Date: Tue, 15 Oct 2024 17:48:51 +0800 X-OQ-MSGID: <20241015094851.3244106-1-cyy@cyyself.name> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HELO_DYNAMIC_IPADDR, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org In some cases, a IFUNC resolver may need to access the gp pointer to resolve the function address, such object may have l_relocated == 0. In this case, the gp pointer is not set up, and the resolver cannot access the gp pointer. This patch fixes this issue by relaxing the check of l_relocated in elf_machine_runtime_setup. Closes: BZ #32269 Fixes: 96d1b9ac23 ("RISC-V: Fix the static-PIE non-relocated object check") Signed-off-by: Yangyu Chen --- sysdeps/riscv/dl-machine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index b2f28697f7..ffb8c4aaa0 100644 --- a/sysdeps/riscv/dl-machine.h +++ b/sysdeps/riscv/dl-machine.h @@ -348,7 +348,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], gotplt[1] = (ElfW(Addr)) l; } - if (l->l_type == lt_executable && l->l_relocated) + if (l->l_type == lt_executable) { /* The __global_pointer$ may not be defined by the linker if the $gp register does not be used to access the global variable