diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 373a1cdd2d0..95f40299583 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -543,10 +543,12 @@ allocate_initial_tls(Obj_Entry *objs) addr = allocate_tls(objs, 0, TLS_TCB_SIZE, TLS_TCB_ALIGN); /* - * This does not use _tcb_set() as it calls amd64_set_fsbase() + * This does not use _tcb_set() as it calls amd64_set_tlsbase() * which is an ifunc and rtld must not use ifuncs. */ - if (__getosreldate() >= P_OSREL_WRFSBASE && + if (__getosreldate() >= P_OSREL_TLSBASE) + sysarch(AMD64_SET_TLSBASE, &addr); + else if (__getosreldate() >= P_OSREL_WRFSBASE && (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0) wrfsbase((uintptr_t)addr); else diff --git a/sys/x86/include/tls.h b/sys/x86/include/tls.h index 29d036fd487..1ed47bf0193 100644 --- a/sys/x86/include/tls.h +++ b/sys/x86/include/tls.h @@ -69,7 +69,7 @@ static __inline void _tcb_set(struct tcb *tcb) { #ifdef __amd64__ - amd64_set_fsbase(tcb); + amd64_set_tlsbase(tcb); #else i386_set_gsbase(tcb); #endif