um: make stub compilation more robust

With clang, stub compilation could result in getting stack
frames where none are allowed, or ways of making it be not
relocatable. Set -ftrivial-auto-var-init=uninitialized for
more code, and -fomit-frame-pointer as well to avoid these
issues.

Link: https://patch.msgid.link/20260923173523.9cb03214335b.Ie1487657bc0f464f4911e95f532ab010b32864b8@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-09-23 17:34:31 +02:00
parent 779c65ede6
commit d5f40f0b4b
2 changed files with 11 additions and 2 deletions

View File

@ -44,8 +44,14 @@ targets += stub_exe.dbg stub_exe $(stub_exe_objs-y)
CFLAGS_stub.o := $(CFLAGS_NO_HARDENING)
CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING)
# Clang will call memset() from __builtin_alloca() when stack variable
# initialization is enabled, which is used in stub_exe.c.
# stub_signal_restorer() must not touch stack pointer, clang doesn't
# always omit the frame pointer automatically
CFLAGS_stub.o += -fomit-frame-pointer
CFLAGS_stub_exe.o += -fomit-frame-pointer
# Clang's stack var initialisation can use memset() or similar and that
# cannot be done for this code since we embed/move the stub
CFLAGS_stub.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
CFLAGS_stub_exe.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
UNPROFILE_OBJS := stub.o stub_exe.o

View File

@ -47,4 +47,7 @@ include/generated/user_constants.h: $(obj)/user-offsets.s FORCE
UNPROFILE_OBJS := stub_segv.o
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
# see arch/um/kernel/skas/Makefile - this goes into the stub
CFLAGS_stub_segv.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
include $(srctree)/arch/um/scripts/Makefile.rules