git: 3f7327695061 - stable/13 - x86: microoptimize static PIE startup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Jun 2023 12:22:27 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=3f732769506181f77f38b656fa32692f4b87c9fd
commit 3f732769506181f77f38b656fa32692f4b87c9fd
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-11-01 01:42:50 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
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 <machine/specialreg.h>
#include <machine/cpufunc.h>
+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 <machine/specialreg.h>
#include <machine/cpufunc.h>
+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: