From nobody Mon Jun 12 12:22:27 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QfrRR58Sgz4d9rD; Mon, 12 Jun 2023 12:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QfrRR4CqYz3qfT; Mon, 12 Jun 2023 12:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686572547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dQ78l0DaGQLGXH/Ejs5RRovptyZ3Jtt1CCsIy5R24hA=; b=vQfR862X3vpyD8XGIy5pYUFNLRZyhBv6JAMI4Jb06aaMAGZFSFE/aLBxgZWoMs5wlH3e5/ uUjFAlBCZyX555MT3FGl4LT063zEybbUGMBgZzSHE82H+5R5iUabkwPIxtb06OdLTHNmJZ NmS6U4QqWi/SikHRkhUONj2HuJGXv/obP+cpzk6x2I3Muu2lW/W1ZAABmAF8m3UiwjR8mC 6fyt4SOr7PfPf8onft9j9/0o+V8CC5yi9lb9+0ejgVX4dsIfKkAIyDFZRiexNlwLgNHsVS GglRvrFxT44yUhrAVjZnMtukcnwYsxkmXRpNUpN4NfF0RSkm2k6+l/og6233VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686572547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dQ78l0DaGQLGXH/Ejs5RRovptyZ3Jtt1CCsIy5R24hA=; b=cs9IKET0jIkTIHvxbF5iopP92YCA6hBd1x/L+RC8t/dflHsHJi1iLpGtREkHGVqIIeG/Ge L1aT4zOTbWtsEDwOINEexznfVo+H9DX85XP1u2aZlFxkMAbCaP0ipLbHWu+imGDXwJEomI cFkzi7KE/x/IdDRPo89qUyiJwPQ1H5MOeKFsJndqyiKo70s8e/ml6B2Do/SGeGQABYncG7 OtI5U/bob7pOSuRsWzjW8v7342zNcsCInewj8OSqVbsw0p4ukrF5GTklDv+9wFVU6CZ02A Ov53yqqxQERLhW5haFtLSh1ztS2eNAYgBdM2KS3fa1izXkrhvmaM9aR37hFPQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686572547; a=rsa-sha256; cv=none; b=lhMo/nwM9bTxH82JUOEU9GG7nb5Vv5RC5iKJDN6OYxw+di/klghL5BUSMgGF267rZuSHmv O6rWfRKD12x131AIYsp2PhqjnuKmj6WKWs1dAew5nlaA44wV7ogNUUcErjqcuITsb3+Yjg gq/48sIAkDPtGq9PiaMYVTLZIRu85Jp4E7zRYzhX5GulM0VGMAlbi3tf3s1v1RZVGs5DGM jG9WiYAANpY5SALrl9PVzNVXL3LRy1lhYNYtJIWhVf6wpoJchSYZMkIPWCtQ/ifbrk9Vaj Hxzi2/KhImRbcYuPSBXzuVovIsWySAS+zh+JKDxQ4DItOW2P64dzlloiDMK4DQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QfrRR32Nwzg1d; Mon, 12 Jun 2023 12:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35CCMRZk048036; Mon, 12 Jun 2023 12:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35CCMR8a048035; Mon, 12 Jun 2023 12:22:27 GMT (envelope-from git) Date: Mon, 12 Jun 2023 12:22:27 GMT Message-Id: <202306121222.35CCMR8a048035@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3f7327695061 - stable/13 - x86: microoptimize static PIE startup 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f732769506181f77f38b656fa32692f4b87c9fd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3f732769506181f77f38b656fa32692f4b87c9fd commit 3f732769506181f77f38b656fa32692f4b87c9fd Author: Konstantin Belousov AuthorDate: 2022-11-01 01:42:50 +0000 Commit: Konstantin Belousov CommitDate: 2023-06-12 12:19:38 +0000 x86: microoptimize static PIE startup (cherry picked from commit 0303938539f3f12da65128fc67f883efe82dc125) --- lib/libc/csu/amd64/Makefile.inc | 2 +- lib/libc/csu/amd64/reloc.c | 14 ++++++++++---- lib/libc/csu/i386/Makefile.inc | 2 +- lib/libc/csu/i386/reloc.c | 14 ++++++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/libc/csu/amd64/Makefile.inc b/lib/libc/csu/amd64/Makefile.inc index b3420a638164..f14033217580 100644 --- a/lib/libc/csu/amd64/Makefile.inc +++ b/lib/libc/csu/amd64/Makefile.inc @@ -1,4 +1,4 @@ # CFLAGS+= -DCRT_IRELOC_RELA \ - -DINIT_IRELOCS="" + -DINIT_IRELOCS="init_cpu_features()" diff --git a/lib/libc/csu/amd64/reloc.c b/lib/libc/csu/amd64/reloc.c index adb52e42a32c..0a5a24929954 100644 --- a/lib/libc/csu/amd64/reloc.c +++ b/lib/libc/csu/amd64/reloc.c @@ -29,13 +29,13 @@ __FBSDID("$FreeBSD$"); #include #include +static uint32_t cpu_feature, cpu_feature2; +static uint32_t cpu_stdext_feature, cpu_stdext_feature2; + static void -crt1_handle_rela(const Elf_Rela *r) +init_cpu_features(void) { - Elf_Addr *ptr, *where, target; u_int p[4]; - uint32_t cpu_feature, cpu_feature2; - uint32_t cpu_stdext_feature, cpu_stdext_feature2; do_cpuid(1, p); cpu_feature = p[3]; @@ -49,6 +49,12 @@ crt1_handle_rela(const Elf_Rela *r) cpu_stdext_feature = 0; cpu_stdext_feature2 = 0; } +} + +static void +crt1_handle_rela(const Elf_Rela *r) +{ + Elf_Addr *ptr, *where, target; switch (ELF_R_TYPE(r->r_info)) { case R_X86_64_IRELATIVE: diff --git a/lib/libc/csu/i386/Makefile.inc b/lib/libc/csu/i386/Makefile.inc index ac0984df2349..f3f8c2b176ce 100644 --- a/lib/libc/csu/i386/Makefile.inc +++ b/lib/libc/csu/i386/Makefile.inc @@ -1,4 +1,4 @@ # CFLAGS+= -DCRT_IRELOC_REL \ - -DINIT_IRELOCS="" + -DINIT_IRELOCS="init_cpu_features()" diff --git a/lib/libc/csu/i386/reloc.c b/lib/libc/csu/i386/reloc.c index 13438035841d..f99b1089cf47 100644 --- a/lib/libc/csu/i386/reloc.c +++ b/lib/libc/csu/i386/reloc.c @@ -29,13 +29,13 @@ __FBSDID("$FreeBSD$"); #include #include +static uint32_t cpu_feature, cpu_feature2; +static uint32_t cpu_stdext_feature, cpu_stdext_feature2; + static void -crt1_handle_rel(const Elf_Rel *r) +init_cpu_features(void) { - Elf_Addr *where, target; u_int cpuid_supported, p[4]; - uint32_t cpu_feature, cpu_feature2; - uint32_t cpu_stdext_feature, cpu_stdext_feature2; __asm __volatile( " pushfl\n" @@ -72,6 +72,12 @@ crt1_handle_rel(const Elf_Rel *r) cpu_stdext_feature = 0; cpu_stdext_feature2 = 0; } +} + +static void +crt1_handle_rel(const Elf_Rel *r) +{ + Elf_Addr *where, target; switch (ELF_R_TYPE(r->r_info)) { case R_386_IRELATIVE: