> I'm very interested in a little bit kernel hacking, so I bought
> myself the book 'Linux device drivers' (O'Reilly) and started
> to code a simple 'Hello world' module
> Part 1:
> -------
> #define __NO_VERSION__
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/version.h>
> char kernel_version[] = UTS_RELEASE;
> int init_module(void)
> {
> printk("<1>Here we are :-)\n");
> return 0;
> }
> Part 2:
> -------
> #define __NO_VERSION__
> #include <linux/kernel.h>
> #include <linux/module.h>
> void cleanup_module(void)
> {
> printk("<1>Now we're gone :-(");
> }
> Compiling works just fine,
> root@weyoun:/home/twesthei/C/kernel > make
> gcc -D__KERNEL__ -I/usr/src/linux/include -O2 -Wall -Wstrict-prototypes
> -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -malign-loops=2
> -malign-jumps=2 -malign-functions=2 -DCPU=586 -DMODULE -DEXPORT_SYMTAB
> -c skull_init.c -o skull_init.o
> gcc -D__KERNEL__ -I/usr/src/linux/include -O2 -Wall -Wstrict-prototypes
> -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -malign-loops=2
> -malign-jumps=2 -malign-functions=2 -DCPU=586 -DMODULE -DEXPORT_SYMTAB
> -c skull_clean.c -o skull_clean.o
> ld -r skull_init.o skull_clean.o -o skull.o
> but I can't insmod that piece of code because of
> root@weyoun:/home/twesthei/C/kernel > insmod skull
> ./skull.o: unresolved symbol printk
> What??? Any help appreciated ;-)
You have kernel with MODVERSIONS support but module is compiled without
MODVERSIONS support. No-go.
Add -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h
to gcc command line and remove __NO_VERSION__ from .c files ...
BTW why printk("<1>Here we are :-)\n");, not
printk(KERN_ALERT "Here we are :-)\n"); ?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/