Skip to content

Instantly share code, notes, and snippets.

@yukkeorg
Last active November 6, 2016 01:25
Show Gist options
  • Select an option

  • Save yukkeorg/d1b61d58a9cae1f1c8cae77b2339474f to your computer and use it in GitHub Desktop.

Select an option

Save yukkeorg/d1b61d58a9cae1f1c8cae77b2339474f to your computer and use it in GitHub Desktop.

Revisions

  1. Yusuke Ohshima renamed this gist Nov 6, 2016. 1 changed file with 13 additions and 18 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,16 @@
    # curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.5.tar.xz
    # tar xf linux-4.8.5.tar.xz
    # cd linux-4.8.5
    # patch -p1 < this.patch

    diff --git a/Makefile b/Makefile
    index daa3a01..23bd0f7 100644
    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 -fno-PIC

    -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 -fno-PIC
    +KBUILD_AFLAGS_KERNEL := -fno-PIE
    KBUILD_CFLAGS_KERNEL :=
    KBUILD_AFLAGS := -D__ASSEMBLY__
    KBUILD_AFLAGS_MODULE := -DMODULE
    @@ -25,21 +20,21 @@ index 12dbd0b..84e49fa 100755
    +++ 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
    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
    echo y
    else
  2. Yusuke Ohshima revised this gist Oct 30, 2016. No changes.
  3. Yusuke Ohshima revised this gist Oct 29, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions kernel_build_on_debian_sid_gcc-6_6.2.0-7.patch
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    # curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.5.tar.xz
    # tar xf linux-4.8.5.tar.xz
    # cd linux-4.8.5
    # patch -p1 < this.patch

    diff --git a/Makefile b/Makefile
    index daa3a01..23bd0f7 100644
    --- a/Makefile
  4. Yusuke Ohshima created this gist Oct 29, 2016.
    40 changes: 40 additions & 0 deletions kernel_build_on_debian_sid_gcc-6_6.2.0-7.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    diff --git a/Makefile b/Makefile
    index daa3a01..23bd0f7 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 -fno-PIC

    -KBUILD_AFLAGS_KERNEL :=
    +KBUILD_AFLAGS_KERNEL := -fno-PIE -fno-PIC
    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