From: Arjan van de Ven <arjan@linux.intel.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org, ak@suse.de
Subject: Re: [patch 5/5] -fstack-protector feature: Enable the compiler flags in CFLAGS
Date: Wed, 16 Aug 2006 21:24:25 +0200 [thread overview]
Message-ID: <1155756265.3023.133.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <20060816185538.GE5852@mars.ravnborg.org>
On Wed, 2006-08-16 at 20:55 +0200, Sam Ravnborg wrote:
> stack-protector = $(shell $(CONFIG_SHELL) \
>
> $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(1))
> cflags-$(CONFIG_CC_STACKPROTECTOR) += \
> $(call stack-protector, $(CC) -fstack-protector)
> cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += \
> $(call stack-protector, $(CC)
> -fstack-protector-all)
ok that works (I've tested it ;)
Subject: [patch 5/5] Add the -fstack-protector option to the CFLAGS
From: Arjan van de Ven <arjan@linux.intel.com>
Add a feature check that checks that the gcc compiler has stack-protector
support and has the bugfix for PR28281 to make this work in kernel mode.
The easiest solution I could find was to have a shell script in scripts/
to do the detection; if needed we can make this fancier in the future
without making the makefile too complex.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
CC: Andi Kleen <ak@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
---
arch/x86_64/Makefile | 3 +++
scripts/gcc-x86_64-has-stack-protector.sh | 8 ++++++++
2 files changed, 11 insertions(+)
Index: linux-2.6.18-rc4-stackprot/arch/x86_64/Makefile
===================================================================
--- linux-2.6.18-rc4-stackprot.orig/arch/x86_64/Makefile
+++ linux-2.6.18-rc4-stackprot/arch/x86_64/Makefile
@@ -55,6 +55,15 @@ cflags-y += $(call cc-option,-funit-at-a
# prevent gcc from generating any FP code by mistake
cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
+
+stack-protector = $(shell $(CONFIG_SHELL) \
+ $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(1))
+
+cflags-$(CONFIG_CC_STACKPROTECTOR) += \
+ $(call stack-protector, $(CC) -fstack-protector)
+cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += \
+ $(call stack-protector, $(CC) -fstack-protector-all)
+
CFLAGS += $(cflags-y)
CFLAGS_KERNEL += $(cflags-kernel-y)
AFLAGS += -m64
Index: linux-2.6.18-rc4-stackprot/scripts/gcc-x86_64-has-stack-protector.sh
===================================================================
--- /dev/null
+++ linux-2.6.18-rc4-stackprot/scripts/gcc-x86_64-has-stack-protector.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - | grep -q "%gs"
+if [ "$?" -eq "0" ] ; then
+ echo $2
+fi
next prev parent reply other threads:[~2006-08-16 19:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-16 16:48 [patch 0/5] -fstack-protector feature for the kernel (try 2) Arjan van de Ven
2006-08-16 16:49 ` [patch 1/5] -fstack-protector feature: annotate the PDA offsets Arjan van de Ven
2006-08-16 16:50 ` [patch 2/5] -fstack-protector feature: Add the Kconfig option Arjan van de Ven
2006-08-16 18:12 ` Adrian Bunk
2006-08-18 11:08 ` Andi Kleen
2006-08-18 11:23 ` Arjan van de Ven
2006-08-18 14:05 ` Andi Kleen
2006-08-18 13:10 ` Arjan van de Ven
2006-08-18 13:30 ` Arjan van de Ven
2006-08-18 17:21 ` Sam Ravnborg
2006-08-16 16:51 ` [patch 3/5] -fstack-protector feature: Add the canary field to the PDA area Arjan van de Ven
2006-08-16 16:52 ` [patch 4/5] -fstack-protector feature: Add the __stack_chk_fail() function Arjan van de Ven
2006-08-16 16:53 ` [patch 5/5] -fstack-protector feature: Enable the compiler flags in CFLAGS Arjan van de Ven
2006-08-16 18:55 ` Sam Ravnborg
2006-08-16 19:24 ` Arjan van de Ven [this message]
2006-08-18 11:15 ` [patch 0/5] -fstack-protector feature for the kernel (try 2) Andi Kleen
2006-08-18 11:29 ` Arjan van de Ven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1155756265.3023.133.camel@laptopd505.fenrus.org \
--to=arjan@linux.intel.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®