RedPill-TTG / redpill-lkm

Linux kernel module for RedPill
GNU General Public License v3.0
307 stars 168 forks source link

error: code model kernel does not support PIC mode #13

Closed goldengit closed 3 years ago

goldengit commented 3 years ago

Hello redpill devs,

I am a newbie linux dev, and couldn't resist jumping in and testing a bit here. when running "make modules_prepare" I am getting the following error below stating code model kernel does not support PIC mode - the first command "make oldconfig" worked fine without error.

make[1]: Nothing to be done for 'all'. make[1]: Nothing to be done for 'relocs'. CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h UPD include/generated/utsrelease.h CC kernel/bounds.s cc1: error: code model kernel does not support PIC mode make[1]: [/home/user1/syno-custom/redpill-lkm/linux-3.10/./Kbuild:36: kernel/bounds.s] Error 1 make: [Makefile:840: prepare0] Error 2

My environment is an ubuntu 20.04 server. I cloned this repo and downloaded/unpacked GPL kernel source per the instructions. Am I missing something else here?

Really appreciate the effort by all devs for this project!

Ren

ttg-public commented 3 years ago

Hi!

This error is slightly unfortunate and comes from the Linux kernel code itself. In essence every Linux version has a list of supported GCC versions. Building with a slightly newer version sometimes works (but it's an uncharted territory). However, building with a much newer will almost always fail or produce a broken binary. In case of the error you're getting it's fixable but as soon as you do there are like 50 more ;) All kernel modules must be built with with same compatible version of GCC as the kernel they target.

In case of Linux v3 and v4, which are quite old, an old version of GCC is needed. The newest version usable for both is GCC v4.9.2. You cannot really install it on a modern Ubuntu/Debian system without resorting to cross-compilation toolchains. It's much easier (and more stable as others found) to use an older distro with native GCC 4.9. You can use a docker container or a VM with Debian 8 (in case of docker you can use the debian8-slim version).

Let us know if that helps.

goldengit commented 3 years ago

thank you for the clear explanation and suggestions - I will test with a docker container or vm with an appropriate gcc version - You guys rock, keep up the great work!

goldengit commented 3 years ago

Using a Debian 8 vm worked as suggested :) thank you!!