Skip to content

Instantly share code, notes, and snippets.

@xterat
Last active September 1, 2017 13:29
Show Gist options
  • Save xterat/3c27a7f93324bd2c56873503d2267386 to your computer and use it in GitHub Desktop.
Save xterat/3c27a7f93324bd2c56873503d2267386 to your computer and use it in GitHub Desktop.

Compile kernel

  1. make menuconfig
  2. make -j40
  3. sudo make modules_install
  4. sudo make install
  5. sudo reboot

Some dependencies to install before compilation:

  1. sudo apt-get install libncurses5-dev libncursesw5-dev
  2. sudo apt-get install libssl-dev

Solution to PIC Mode related error:

-> add these lines after 'all: vmlinux' in Makefile:

KBUILD_CFLAGS += $(call cc-option, -fno-pie)
KBUILD_CFLAGS += $(call cc-option, -no-pie)
KBUILD_AFLAGS += $(call cc-option, -fno-pie)
KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
--- a/Makefile
+++ b/Makefile
@@ -608,6 +608,12 @@ endif # $(dot-config)
 # Defaults to vmlinux, but the arch makefile usually adds further targets
 all: vmlinux
 
+# force no-pie for distro compilers that enable pie by default
+KBUILD_CFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CFLAGS += $(call cc-option, -no-pie)
+KBUILD_AFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
+
 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
 # values of the respective KBUILD_* variables
 ARCH_CPPFLAGS :=
-- 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment