um: improve checking for --no-warn-rwx-segments

Since LLVM=1 might end up using different linkers for
CC as linker and LD, use detect --no-warn-rwx-segments
support using CC.

Link: https://patch.msgid.link/20260923173523.15f90065ca57.I3079cffd8db3a639e93c3e2624c61bbebadc3cbd@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-09-23 17:34:32 +02:00
parent d5f40f0b4b
commit 82ddd2bd76

View File

@ -134,9 +134,10 @@ LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
# Avoid binutils 2.39+ warnings by marking the stack non-executable and
# ignorning warnings for the kallsyms sections.
LDFLAGS_EXECSTACK = -z noexecstack
ifeq ($(CONFIG_LD_IS_BFD),y)
LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
endif
# check --no-warn-rwx-segments with CC-as-linker since that gets used
# for vmlinux and is where we need the option, in particular with LLVM=1
# it might be different links (ld.bfd vs. ld.lld)
LDFLAGS_EXECSTACK += $(call try-run,$(CC) -Wl$(comma)--no-warn-rwx-segments -shared -x c /dev/null -o "$$TMP",--no-warn-rwx-segments)
LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt))