[PATCH] csu: Disable zero-init on stack in libc-start.c [BZ #33112]

Wilco Dijkstra Wilco.Dijkstra@arm.com
Fri Jun 27 13:13:17 GMT 2025


During early startup memcpy or memset must not be called since many targets
use ifuncs for them which won't be initialized yet.  Security hardening may
use -ftrivial-auto-var-init=zero which inserts calls to memset.  Explicitly
disable this feature in the makefile.  This fixes BZ #33112.

OK for commit?

---

diff --git a/csu/Makefile b/csu/Makefile
index 6d1c6b28cb92138b351c2ab55464e33e2b343548..36a2583f70989b33ad5a44f4f606e2f1fa84f911 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -166,7 +166,9 @@ endif
 asm-CPPFLAGS += -I$(objpfx).
 
 # Enable unwinding so backtrace unwinds to __libc_start_main
-CFLAGS-libc-start.c += -funwind-tables
+# Disable auto var initialization since this may call memset before ifunc
+# resolvers are called.
+CFLAGS-libc-start.c += -funwind-tables -ftrivial-auto-var-init=uninitialized
 
 include ../Rules
 


More information about the Libc-alpha mailing list