C-V List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: e73457d194b000a53218a77564730e87b84f66af Auto-Submitted: auto-generated Date: Mon, 15 Dec 2025 17:00:23 +0000 Message-Id: <69403ea7.e0a3.5e8628aa@gitrepo.freebsd.org> The branch stable/14 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=e73457d194b000a53218a77564730e87b84f66af commit e73457d194b000a53218a77564730e87b84f66af Author: Jessica Clarke AuthorDate: 2025-05-06 22:14:51 +0000 Commit: Jessica Clarke CommitDate: 2025-12-15 16:58:44 +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 (cherry picked from commit 8ad9cec3a2cc643020a286ee68f70eb01225fbdd) --- 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 8509321b785f..00e805c5c4c9 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4088,7 +4088,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;