From: H.J. Lu Date: Mon, 7 Jul 2025 22:38:38 +0000 (+0800) Subject: x86: Avoid vector/r16-r31 registers and memcpy/memset in mcount_internal X-Git-Tag: glibc-2.42~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7130c2ae972b3c521e2795af6935982a4f078850;p=thirdparty%2Fglibc.git x86: Avoid vector/r16-r31 registers and memcpy/memset in mcount_internal 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 Reviewed-by: Andreas K. Huettel --- diff --git a/gmon/Makefile b/gmon/Makefile index 26051ed2fb..b42c14aa83 100644 --- a/gmon/Makefile +++ b/gmon/Makefile @@ -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 diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 2aca36c1f0..4fbd48e1c8 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -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 \ diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index be64eb2ee4..c3e1065c81 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -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)