LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Error compiling loadable kernel module with vanilla kernel (http://www.linuxquestions.org/questions/linux-newbie-8/error-compiling-loadable-kernel-module-with-vanilla-kernel-4175414846/)

aijazbaig1 07-04-2012 06:24 AM

Error compiling loadable kernel module with vanilla kernel
 
Hello Folks

Ive been trying to compile a vanilla kernel just for the purpose of refreshing some long forgotten loadable modules concepts. By the way, Im running centos 6.

what ive done is, ive downloaded a vanilla kernel image 2.6.32 from kernel.org and then I did a
Code:

menu xconfig
on it to create a .config file. After having done that, I run
Code:

make
on the top level directory which seems to work fine.

However
Code:

make modules
fails with the following errors:

Code:

No rule to make target 'net/ipv4/netfilter/ipt_ecn.c', needed by `net/ipv4/netfilter/ipt_ecn.o'. Stop'
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [net/ipv4/netfilter] Error 2
make[1]: *** [net/ipv4] Error 2
make: *** [net] Error 2
make: *** Waiting for unfinished jobs....

I believe this just means that it was NOT able to build the 'ipt_ecn' module ('iptables' module which is typically used as a filtering, network traffic sniffer/shaper..and many other things. Thats out of topic for this). And thats fine with me. What has got me concerned is, since it apparently failed in the middle, it may have missed out on any book-keeping task(s) which it does at the end of 'make modules'?

Nonetheless, I ran a
Code:

make modules
and it seemed to have went fine (note that ive already installed the modules under /lib/modules/ by doing a
Code:

make modules_install
at the top of the vanilla kernel source tree). I then cd into the directory where my kernel module source code is located. My Makefile in it looks like this:
Code:

obj−m += hello−1.o

all:
make -C /lib/modules/2.6.32.59/build M=$(shell pwd) modules

clean:
make -C /lib/modules/2.6.32.59/build M=$(shell pwd) clean

I DID NOT use the /lib/modules/`uname -r`/build path as I do not want to have these modules linked against the currently running kernel. I will only do an 'insmod' after having booted into the '2.6.32.59' vanilla kernel later. So am I allowed to build a kernel module against a kernel which is not currently running?

Anyways, I try doing exactly that, by doing a
Code:

make all
in the directory where I have my kernel module source. However I get the following errors:
Code:

make -C /lib/modules/2.6.32.59/build M=/home/aijazbaig1/modules modules
make[1]: Entering directory `/home/aijazbaig1/linux-2.6.32.59'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)
mkdir -p /home/aijazbaig1/modules/.tmp_versions ; rm -f /home/aijazbaig1/modules/.tmp_versions/*

WARNING: Symbol version dump /home/aijazbaig1/linux-2.6.32.59/Module.symvers
is missing; modules will have no dependencies and modversions.

make -f scripts/Makefile.build obj=/home/aijazbaig1/modules
(cat /dev/null; ) > /home/aijazbaig1/modules/modules.order
make -f /home/aijazbaig1/linux-2.6.32.59/scripts/Makefile.modpost
scripts/mod/modpost -m -a -i /home/aijazbaig1/linux-2.6.32.59/Module.symvers -I /home/aijazbaig1/modules/Module.symvers -o /home/aijazbaig1/modules/Module.symvers -S -w -s
make[1]: Leaving directory `/home/aijazbaig1/linux-2.6.32.59

After searching a lot over the internet, ive come across many different opinions but I couldn't figure out a single reason as to why it fails to find the autoconf.h or auto.conf files. These files are present under the source tree

[root@MyCentOS-VM linux-2.6.32.59]# find . -name autoconf.h
./include/linux/autoconf.h
[root@MyCentOS-VM linux-2.6.32.59]# find . -name auto.conf
./include/config/auto.conf

Ive also created a soft link (since it wasn't there by default to begin with) '/usr/src/linux' to point to the directory where the stock kernel is located.
Here:
[root@MyCentOS-VM modules]# ls -l /usr/src/
total 8
drwxr-xr-x. 2 root root 4096 Sep 23 2011 debug
drwxr-xr-x. 3 root root 4096 Jun 27 16:08 kernels
lrwxrwxrwx. 1 root root 33 Jul 2 16:05 linux -> /home/aijazbaig1/linux-2.6.32.59/

I fail to understand what exactly is causing the build to fail. Please enlighten me or give me some pointers as to where should I be looking at.

Keen to hear from you soon.

Regards,
Aijaz

aijazbaig1 07-05-2012 12:48 AM

Moderator, could you please delete this thread from here? It should have been posted under Linux-kernel and I've done that now.

Thanks again and sorry for the wrong address this time :)

Regards,
Aijaz Baig

bsat 07-05-2012 03:35 AM

Try this

In the makefile for the module use the path to the kernel source along with make i.e.

Code:

obj−m += hello−1.o

all:
make -C <Path to kernel source> M=$(shell pwd) modules

clean:
make -C <Path to kernel source> M=$(shell pwd) clean


aijazbaig1 07-05-2012 04:41 AM

Hello bsat

Could we continue the discussion here: http://www.linuxquestions.org/questi...el-4175414977/

Im going to ask the mod to close this one so more people interested in kernel development can take a look there.

Thanks


All times are GMT -5. The time now is 05:42 PM.