Skip to content

Instantly share code, notes, and snippets.

@yukkeorg
Last active November 6, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukkeorg/d1b61d58a9cae1f1c8cae77b2339474f to your computer and use it in GitHub Desktop.
Save yukkeorg/d1b61d58a9cae1f1c8cae77b2339474f to your computer and use it in GitHub Desktop.
Patch for Building Linux kernel 4.8.5 with gcc-6 6.2.0(Enabled PIE default) on Debian
diff --git a/Makefile b/Makefile
index b249529..ae6fa4b 100644
--- a/Makefile
+++ b/Makefile
@@ -399,9 +399,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
- -std=gnu89
+ -std=gnu89 -fno-PIE
-KBUILD_AFLAGS_KERNEL :=
+KBUILD_AFLAGS_KERNEL := -fno-PIE
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS := -D__ASSEMBLY__
KBUILD_AFLAGS_MODULE := -DMODULE
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh
index 12dbd0b..84e49fa 100755
--- a/scripts/gcc-x86_32-has-stack-protector.sh
+++ b/scripts/gcc-x86_32-has-stack-protector.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
index 973e8c1..17867e7 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
@yukkeorg
Copy link
Author

yukkeorg commented Nov 6, 2016

Update (11/06)

  • fix extracted tab on Makefile
  • remove -fno-PIC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment