Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Nov 2018 10:22:42 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r340557 - stable/11/libexec/rtld-elf/amd64
Message-ID:  <201811181022.wAIAMgT4096312@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Nov 18 10:22:42 2018
New Revision: 340557
URL: https://svnweb.freebsd.org/changeset/base/340557

Log:
  MFC r339897:
  Remove rtld use of libc amd64_set_fsbase().

Modified:
  stable/11/libexec/rtld-elf/amd64/reloc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/rtld-elf/amd64/reloc.c
==============================================================================
--- stable/11/libexec/rtld-elf/amd64/reloc.c	Sun Nov 18 09:58:36 2018	(r340556)
+++ stable/11/libexec/rtld-elf/amd64/reloc.c	Sun Nov 18 10:22:42 2018	(r340557)
@@ -33,8 +33,9 @@
 
 #include <sys/param.h>
 #include <sys/mman.h>
-#include <machine/sysarch.h>
 #include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
 
 #include <dlfcn.h>
 #include <err.h>
@@ -490,17 +491,26 @@ pre_init(void)
 
 }
 
+int __getosreldate(void);
+
 void
 allocate_initial_tls(Obj_Entry *objs)
 {
-    /*
-     * Fix the size of the static TLS block by using the maximum
-     * offset allocated so far and adding a bit for dynamic modules to
-     * use.
-     */
-    tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
-    amd64_set_fsbase(allocate_tls(objs, 0,
-				  3*sizeof(Elf_Addr), sizeof(Elf_Addr)));
+	void *addr;
+
+	/*
+	 * Fix the size of the static TLS block by using the maximum
+	 * offset allocated so far and adding a bit for dynamic
+	 * modules to use.
+	 */
+	tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
+
+	addr = allocate_tls(objs, 0, 3 * sizeof(Elf_Addr), sizeof(Elf_Addr));
+	if (__getosreldate() >= P_OSREL_WRFSBASE &&
+	    (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
+		wrfsbase((uintptr_t)addr);
+	else
+		sysarch(AMD64_SET_FSBASE, &addr);
 }
 
 void *__tls_get_addr(tls_index *ti)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811181022.wAIAMgT4096312>