From owner-svn-src-head@freebsd.org Mon Oct 29 23:59:27 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 477CD10EE039; Mon, 29 Oct 2018 23:59:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E804C8BA61; Mon, 29 Oct 2018 23:59:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE32315717; Mon, 29 Oct 2018 23:59:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9TNxQjb033477; Mon, 29 Oct 2018 23:59:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9TNxQiY033476; Mon, 29 Oct 2018 23:59:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201810292359.w9TNxQiY033476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 29 Oct 2018 23:59:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339897 - head/libexec/rtld-elf/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/libexec/rtld-elf/amd64 X-SVN-Commit-Revision: 339897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Oct 2018 23:59:27 -0000 Author: kib Date: Mon Oct 29 23:59:26 2018 New Revision: 339897 URL: https://svnweb.freebsd.org/changeset/base/339897 Log: Remove rtld use of libc amd64_set_fsbase(). One less non-trivial dependency of rtld on libc. Also, amd64_set_fsbase() is to be converted to ifunc, which I do not want to support inside rtld. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/libexec/rtld-elf/amd64/reloc.c Modified: head/libexec/rtld-elf/amd64/reloc.c ============================================================================== --- head/libexec/rtld-elf/amd64/reloc.c Mon Oct 29 23:56:39 2018 (r339896) +++ head/libexec/rtld-elf/amd64/reloc.c Mon Oct 29 23:59:26 2018 (r339897) @@ -35,8 +35,9 @@ #include #include -#include #include +#include +#include #include #include @@ -495,17 +496,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)