Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Dec 2025 17:00:23 +0000
Message-ID:  <69403ea7.e0a3.5e8628aa@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=e73457d194b000a53218a77564730e87b84f66af

commit e73457d194b000a53218a77564730e87b84f66af
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2025-05-06 22:14:51 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
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;


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69403ea7.e0a3.5e8628aa>