From: Sven Joachim <svenjoac@gmx.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Joe Perches <joe@perches.com>,
Adam Borowski <kilobyte@angband.pl>,
Michal Marek <mmarek@suse.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
ben@decadent.org.uk
Subject: Re: [RFC PATCH] kbuild: add -fno-PIE
Date: Mon, 24 Oct 2016 19:32:30 +0200 [thread overview]
Message-ID: <874m41mz4h.fsf@turtle.gmx.de> (raw)
In-Reply-To: <20161024074332.uomcxyhqo6aq7vxk@linutronix.de> (Sebastian Andrzej Siewior's message of "Mon, 24 Oct 2016 09:43:32 +0200")
[-- Attachment #1: Type: text/plain, Size: 813 bytes --]
On 2016-10-24 09:43 +0200, Sebastian Andrzej Siewior wrote:
> On 2016-10-24 09:38:49 [+0200], Sven Joachim wrote:
>>
>> But make still fails with it. :-(
>
> try setting CONFIG_CC_STACKPROTECTOR_NONE=y and please let me know if
> the resulting kernel built with v3.2 gcc boots & works.
Sorry, I don't have gcc 3.2 around, and my gcc 3.3 environment produces
assembler errors in arch/x86/entry/entry_32.S. Maybe binutils 2.15 is
not recent enough anymore?
Anyway, with CONFIG_CC_STACKPROTECTOR=y it is necessary to add -fno-pie
in scripts/gcc-x86_64-has-stack-protector.sh as well, because that
script invokes the compiler without KBUILD_CFLAGS. That's probably not
a problem since -fstack-protector is newer than -fno-pie. The attached
patch works for me with Debian's gcc-6 package.
Cheers,
Sven
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-kbuild-add-fno-pie-to-KBUILD_CFLAGS.patch --]
[-- Type: text/x-diff, Size: 2035 bytes --]
>From 2c72542688476168920c027cdc28c6764387ecac Mon Sep 17 00:00:00 2001
From: Sven Joachim <svenjoac@gmx.de>
Date: Mon, 24 Oct 2016 18:17:26 +0200
Subject: [PATCH] kbuild: add -fno-pie to KBUILD_CFLAGS
If GCC is configured with --enable-default-pie, the build fails early
because this default is incompatible with -mcmodel=kernel.
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
Avoid that by adding -fno-pie to KBUILD_CFLAGS, if supported by the
compiler. This flag is also needed in the x86_64 stack-protector test
script which otherwise errors out.
Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong available but compiler is broken
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841420 and
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1574982.
Signed-off-by: Sven Joachim <svenjoac@gmx.de>
---
Makefile | 1 +
scripts/gcc-x86_64-has-stack-protector.sh | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 93beca4..81ef816 100644
--- a/Makefile
+++ b/Makefile
@@ -619,6 +619,7 @@ ARCH_AFLAGS :=
ARCH_CFLAGS :=
include arch/$(SRCARCH)/Makefile
+KBUILD_CFLAGS += $(call cc-option,-fno-pie,)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
index 973e8c1..274cba1 100755
--- a/scripts/gcc-x86_64-has-stack-protector.sh
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-pie -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
--
2.10.1
next prev parent reply other threads:[~2016-10-24 17:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 11:16 [RFC PATCH] kbuild: add -fno-PIE Sebastian Andrzej Siewior
2016-10-21 21:21 ` Adam Borowski
2016-10-23 16:19 ` Sven Joachim
2016-10-23 19:23 ` Joe Perches
2016-10-24 7:38 ` Sven Joachim
2016-10-24 7:43 ` Sebastian Andrzej Siewior
2016-10-24 17:32 ` Sven Joachim [this message]
2016-10-24 17:48 ` Joe Perches
2016-10-25 7:30 ` Sebastian Andrzej Siewior
2016-10-26 17:51 ` Sven Joachim
2016-10-27 7:28 ` Sebastian Andrzej Siewior
2016-10-28 23:00 ` Andrew Morton
2016-10-29 10:10 ` Tomas Janousek
2016-10-29 17:03 ` Sven Joachim
2016-10-29 19:21 ` Tomas Janousek
2016-10-29 21:18 ` Sven Joachim
2016-10-24 9:57 ` Joe Perches
2016-10-27 17:09 ` Shuah Khan
2016-10-28 8:09 ` Sebastian Andrzej Siewior
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=874m41mz4h.fsf@turtle.gmx.de \
--to=svenjoac@gmx.de \
--cc=ben@decadent.org.uk \
--cc=bigeasy@linutronix.de \
--cc=joe@perches.com \
--cc=kilobyte@angband.pl \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.com \
/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