[PATCH 3/3] um: improve checking for --no-warn-rwx-segments

Johannes Berg johannes at sipsolutions.net
Wed Sep 23 08:34:32 PDT 2026


From: Johannes Berg <johannes.berg at intel.com>

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

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 arch/um/Makefile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 937639edc295..d930c5f25fb9 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -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))
 
-- 
2.55.0




More information about the linux-um mailing list