building a hello world module
hi
i'm trying to get into module hacking
now, i've found this hello module in an online book
it looks like this
//start hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
//end hello.c
The Makefile is
obj-m := hello.o
I can build and load the module WITH KERNEL VERSION 2.6.14:
root@KanotixBox:/home/sancho/Programming/ldd/1# make -C /usr/src/linux-2.6.14-kanotix64-9/ M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.14-kanotix64-9'
CC [M] /home/sancho/Programming/ldd/1/hello.o
Building modules, stage 2.
MODPOST
CC /home/sancho/Programming/ldd/1/hello.mod.o
LD [M] /home/sancho/Programming/ldd/1/hello.ko
make: Leaving directory `/usr/src/linux-headers-2.6.14-kanotix64-9'
root@KanotixBox:/home/sancho/Programming/ldd/1# insmod ./hello.ko
However, as soon as I re-logon WITH MY NEWLY COMPILED kernel version 2.6.18, I get the following:
root@KanotixBox:/home/sancho/Programming/ldd/1# make -C /usr/src/linux-2.6.18-slh64-smp-2/ M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.18-slh64-smp-2'
CC [M] /home/sancho/Programming/ldd/1/hello.o
Building modules, stage 2.
MODPOST
CC /home/sancho/Programming/ldd/1/hello.mod.o
LD [M] /home/sancho/Programming/ldd/1/hello.ko
make: Leaving directory `/usr/src/linux-headers-2.6.18-slh64-smp-2'
root@KanotixBox:/home/sancho/Programming/ldd/1# insmod ./hello.ko
Error inserting './hello.ko': -1 Invalid module format
Is there any particular reason why this simple module works with version .14 but not .18?
I mean, I would understand this error if I had compiled the module against .18 while still running .14 and viceversa but as you can see, I'm always compiling against the source I'm actually running so this error shouldn't occur, should it?
Thanx,
Martin
|