From nobody Tue May 6 22:15:31 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZsXlS0KZMz5vXc8; Tue, 06 May 2025 22:15:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZsXlR59YZz3cnC; Tue, 06 May 2025 22:15:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746569731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vY3vRLW1vvcFRwDXSssCwAmg1E+v85L86tnftykcq34=; b=vEI1+5sT910A0kOUKqYTngno/v1M594JicQWKZdOPgTsXjI/ko10SElhXnyZ62O7lvCnaV Wf1ToHTkzu8fUQ+kH49+WLiWa5F2/1/PuKls9qMXHoQ1e05e0v0j3GEITfAcuwxpD36PCM L0w3CAVODYQrUKSGErSdkn0qSvzpDoKaqXRdP20dViT1570O2EIvUobLq8s8ToJX3/kOIF SPy1wREcJpYXp6oGkbTJIcf4+miTry5D8YLYpRT9whYGwKATFpVmFo91EIUWdMJ5jwDJyA //cB3WzhP1UZNs8zRJJ1IIwLah1xXrQq3Oz3d58fv2p74UNFl+S+/mc01hN3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746569731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vY3vRLW1vvcFRwDXSssCwAmg1E+v85L86tnftykcq34=; b=YpVZC+6h22naOCsjOL8mCf5Xe/0JCtsN1p3Z+zDp+xgxTwkJMN7PlDJp6IvJyzhds6+eb3 tx4vJvrSSs40EExQEZMrFQnj9UB/WWEP6CmX5ed0l4uGBh849rNyDcVOq3Bd0jys75q9hF /JrtClKmmgV3jOLuaAN5Y+d5Ndn1LrOtCYbPAOiyiL3dthkfqyIwKgQWjUg/7Y7R+KAKAl zpH0X6VIOU9pmQfafJc6FUUOwg0VUwBOI/1jCe/+3rwirHONAZdjeby69ItFsMoDCm958S 6Dhz2VisbI7RC8ucrMnAGnVBfqN1cOcw4BRxVbM14y+zhjWLYd8S2YJhbk8clw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746569731; a=rsa-sha256; cv=none; b=pkOtRaMjmlGf0X7Ww1CfMBegT13XwkjyNdZ99g+E8wLp7RjbfE1wmME9/eAOsEBfMPpmBC ImNYwmR5nCByaQNS5iXSNEj9gRHVh8pthsv77TrBA1cxQZQI9X4/vCgyKBHBq3s5GaBZ8O xl/nxTot+K47c9l3kuttLWoMh9M/v0hRzZLvK+R3A1XtP24NqD3AyRd+Q/xeAoKU3hmRTh jSIZxmoLS1nBRrd71OI46HXMjUQRF3ZEz9QzNFuxgifOOnN+ljss3C7JVP2ypWjQ0m1Rd8 GdqH9a3zoQXNsYfi9FTBgiHD54+FP5LJwqRPxHqpaPVF1U8V128g+xtp43m+dQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZsXlR4k1Cz1HHj; Tue, 06 May 2025 22:15:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 546MFViQ062967; Tue, 6 May 2025 22:15:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 546MFVPr062964; Tue, 6 May 2025 22:15:31 GMT (envelope-from git) Date: Tue, 6 May 2025 22:15:31 GMT Message-Id: <202505062215.546MFVPr062964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 8ad9cec3a2cc - main - rtld-elf: Fix dlsym(3) for TLS symbols on PowerPC and RISC-V List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8ad9cec3a2cc643020a286ee68f70eb01225fbdd Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=8ad9cec3a2cc643020a286ee68f70eb01225fbdd commit 8ad9cec3a2cc643020a286ee68f70eb01225fbdd Author: Jessica Clarke AuthorDate: 2025-05-06 22:14:51 +0000 Commit: Jessica Clarke CommitDate: 2025-05-06 22:14:51 +0000 rtld-elf: Fix dlsym(3) for TLS symbols on PowerPC and RISC-V The implementation here is meant to mirror what a GOT entry for the given symbol would use for ti_offset. However, on PowerPC and RISC-V, TLS_DTV_OFFSET is non-zero, and so the GOT entries are normally biased by this, but we fail to do so here. As a result we end up getting a pointer TLS_DTV_OFFSET past where the variable actually is. (Note this also applies to MIPS on stable/13) Reviewed by: kib Fixes: 5ceeeba90c6c ("Import DragonFly BSD commit") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D50183 --- libexec/rtld-elf/rtld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 12aee444fccf..29d32e54e690 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4135,7 +4135,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, sym = rtld_resolve_ifunc(defobj, def); else if (ELF_ST_TYPE(def->st_info) == STT_TLS) { ti.ti_module = defobj->tlsindex; - ti.ti_offset = def->st_value; + ti.ti_offset = def->st_value - TLS_DTV_OFFSET; sym = __tls_get_addr(&ti); } else sym = defobj->relocbase + def->st_value;