]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Avoid vector/r16-r31 registers and memcpy/memset in mcount_internal
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 7 Jul 2025 22:38:38 +0000 (06:38 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 8 Jul 2025 21:33:05 +0000 (05:33 +0800)
Since mcount_internal is called from mcount/__fentry__ which preserve
only RAX, RCX, RDX, RSI, RDI, R8 and R9, compile mcount.c with

-fno-tree-loop-distribute-patterns -mgeneral-regs-only -mno-apxf

to void vector/r16-r31 registers and memcpy/memset in mcount_internal.
This fixes BZ #33134.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
gmon/Makefile
sysdeps/x86/Makefile
sysdeps/x86_64/Makefile

index 26051ed2fbad790480e27340b5c1026cad245a63..b42c14aa83dd15849012454f9bff2cc0aa5f1f11 100644 (file)
@@ -62,8 +62,9 @@ tests-static += tst-gmon-static-pie
 endif
 endif
 
-# The mcount code won't work without a frame pointer.
-CFLAGS-mcount.c := -fno-omit-frame-pointer
+# The mcount code won't work without a frame pointer nor when memcpy or
+# memset are called.
+CFLAGS-mcount.c := -fno-omit-frame-pointer -fno-tree-loop-distribute-patterns
 
 CFLAGS-tst-gmon.c := -fno-omit-frame-pointer -pg
 tst-gmon-no-pie = yes
index 2aca36c1f0cbd5eeaf29ee43ea2d6534303c56a0..4fbd48e1c82bb6fc35c218632e2da82744538e86 100644 (file)
@@ -137,6 +137,10 @@ tst-tls23-mod.so-no-z-defs = yes
 $(objpfx)tst-tls23-mod.so: $(libsupport)
 endif
 
+ifeq ($(subdir),gmon)
+CFLAGS-mcount.c += -mgeneral-regs-only
+endif
+
 ifeq ($(subdir),math)
 tests += \
  tst-ldbl-nonnormal-printf \
index be64eb2ee416ccc8190dcceed046208e93b7c883..c3e1065c81b5e7f19466d802282474c4ea328b78 100644 (file)
@@ -19,6 +19,10 @@ sysdep_routines += _mcount
 # recursive calls when ENTRY is used.  Just copy the normal static
 # object.
 sysdep_noprof += _mcount
+
+ifeq (yes,$(have-x86-apx))
+CFLAGS-mcount.c += -mno-apxf
+endif
 endif
 
 ifeq ($(subdir),string)