kernel: bump 4.4 to 4.4.120 for 17.01
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0552-kbuild-Steal-gcc-s-pie-from-the-very-beginning.patch
1 From e1c194ad704d298d6914e5b1efc4afee41a18a4c Mon Sep 17 00:00:00 2001
2 From: Borislav Petkov <bp@suse.de>
3 Date: Mon, 14 Nov 2016 19:41:31 +0100
4 Subject: [PATCH] kbuild: Steal gcc's pie from the very beginning
5
6 commit c6a385539175ebc603da53aafb7753d39089f32e upstream.
7
8 So Sebastian turned off the PIE for kernel builds but that was too late
9 - Kbuild.include already uses KBUILD_CFLAGS and trying to disable gcc
10 options with, say cc-disable-warning, fails:
11
12 gcc -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
13 ...
14 -Wno-sign-compare -fno-asynchronous-unwind-tables -Wframe-address -c -x c /dev/null -o .31392.tmp
15 /dev/null:1:0: error: code model kernel does not support PIC mode
16
17 because that returns an error and we can't disable the warning. For
18 example in this case:
19
20 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
21
22 which leads to gcc issuing all those warnings again.
23
24 So let's turn off PIE/PIC at the earliest possible moment, when we
25 declare KBUILD_CFLAGS so that cc-disable-warning picks it up too.
26
27 Also, we need the $(call cc-option ...) because -fno-PIE is supported
28 since gcc v3.4 and our lowest supported gcc version is 3.2 right now.
29
30 Signed-off-by: Borislav Petkov <bp@suse.de>
31 Cc: Ben Hutchings <ben@decadent.org.uk>
32 Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
33 Signed-off-by: Michal Marek <mmarek@suse.com>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 ---
36 Makefile | 2 --
37 1 file changed, 2 deletions(-)
38
39 --- a/Makefile
40 +++ b/Makefile
41 @@ -624,8 +624,6 @@ KBUILD_CFLAGS += $(call cc-disable-warni
42 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
43 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
44 KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
45 -KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
46 -KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
47
48 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
49 KBUILD_CFLAGS += -Os $(EXTRA_OPTIMIZATION)