m0nad / Diamorphine

LKM rootkit for Linux Kernels 2.6.x/3.x/4.x/5.x/6.x (x86/x86_64 and ARM64)
Other
1.82k stars 431 forks source link

Compiling for ubuntu22.04 Linux 6.5.0-35 #43

Open AITleo opened 4 months ago

AITleo commented 4 months ago

When compiling for ubuntu22.04 Linux 6.5.0-35 I received a gcc warning about mismatched compilers and an error about an unknown option like so:

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:           gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /home/ubuntu/Diamorphine/diamorphine.o
gcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’

Setting the standard gcc version to 12 solves it.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --config gcc
(select gcc-12 here)

It works.

But I am confused since the error message states that we are already using gcc-12 and we would need to use x86_64-linux-gnu-gcc-12. On my system it exists under /usr/bin/x86_64-linux-gnu-gcc-12 thus setting this as the standard gcc should be the solution. This is weird.

Anyway maybe the hint that such an error may be resolved by playing around with update-alternatives is good information.