Skip to contentSkip to conversation

extboot: fix -fno-stack-protector usage

PATCH Applied Christian Ehrhardt 2 participants 2 messages Jan 8, 2008 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extboot: fix -fno-stack-protector usage

Subject: [PATCH] extboot: fix -fno-stack-protector usage
From: Christian Ehrhardt <[email protected]>

Option -fno-stack-protector breaks kvm-userspace in environments without stack-protector functionality. They fail with "unrecognized command line option" when compiling extboot.
This patch removes the fix -fno-stack-protector option and replaces it with a detection that only adds -fno-stack-protector if the option is supported by the used gcc.
The detection code is copied from kernel sources scripts/Kbuild.include.

 Makefile |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
extboot/Makefile +22 -2
index 1ea71a7..ab2dae7 100644
@@ -1,7 +1,27 @@
 OBJCOPY=objcopy
 
-CFLAGS=-Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin \
-       -fno-stack-protector
+# from kernel sources - scripts/Kbuild.include
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;		\
+	TMP="$(TMPOUT).$$$$.tmp";	\
+	if ($(1)) >/dev/null 2>&1;	\
+	then echo "$(2)";		\
+	else echo "$(3)";		\
+	fi;				\
+	rm -f "$$TMP")
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+cc-option-yn = $(call try-run,\
+	$(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
+
+CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
+ifeq ($(call cc-option-yn,-fno-stack-protector),y)
+CFLAGS += -fno-stack-protector
+endif
 
 all: extboot.bin
 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

A message that is not in the archive (sent off-list or not yet received): 11998113973225-git-send-email-ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

Applied
#2 lore raw
Quoted 11 lines · Christian Ehrhardt

Subject: [PATCH] extboot: fix -fno-stack-protector usage
From: Christian Ehrhardt <[email protected]>

Option -fno-stack-protector breaks kvm-userspace in environments without stack-protector functionality. They fail with "unrecognized command line option" when compiling extboot.
This patch removes the fix -fno-stack-protector option and replaces it with a detection that only adds -fno-stack-protector if the option is supported by the used gcc.
The detection code is copied from kernel sources scripts/Kbuild.include.

Applied, thanks.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace