Yo estoy siguiendo este manual con un kernel 2.6.8 compilado desde los
sources y no me da ningun problema
http://tldp.org/LDP/lkmpg/2.6/html/index.html

Espero que te sirva

Salu2.



----- Original Message ----- 
From: "coin" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, February 22, 2005 7:00 PM
Subject: Re: Compilar un modulo


On Tue, 22 Feb 2005 11:21:05 -0600, coin <[EMAIL PROTECTED]> wrote:
> Estoy tratando de compilar el cl�sico m�dulo hola mundo y este es el
c�digo:
>
> #include <linux/module.h>
> #include <linux/config.h>
> #include <linux/init.h>
>
> MODULE_LICENSE("GPL");
> static int __init name_of_initialization_routine(void) {
>        printk("<1>Hello, world\n");
>    return 0;
> }
> static void __exit name_of_cleanup_routine(void) {
>        printk("<1>Goodbye cruel world\n");
> }
> module_init(name_of_initialization_routine);
> module_exit(name_of_cleanup_routine);
>
> Y lo compile con esta instruccion:
> # gcc -D__KERNEL__ -DMODULE -I/usr/src/kernel-source-2.6.8/include/
> -O2 -c hello1.c
>
> Y me dio buenos resultados pues genero el .o pero cuando le doy :
> # insmod ./hello.o
>
> me sale:
> insmod: error inserting './hello1.o': -1 Invalid module format

En esta pagina aparece como compilar modulos para 2.6.8
http://linuxdevices.com/articles/AT4389927951.html

entonces es el mismo codigo c pero ahora tengo un Makefile con esto
obj-m := hello1.o

le doy como dice ahi:
# make -C /usr/src/kernel-source-2.6.8 SUBDIRS=$PWD modules

y me genera varios archivos:
-rw-r--r--  1 root   root    2275 2005-02-22 11:48 hello1.ko
-rw-r--r--  1 root   root     154 2005-02-22 11:48 .hello1.ko.cmd
-rw-r--r--  1 root   root     691 2005-02-22 11:48 hello1.mod.c
-rw-r--r--  1 root   root    1556 2005-02-22 11:48 hello1.mod.o
-rw-r--r--  1 root   root    6493 2005-02-22 11:48 .hello1.mod.o.cmd
-rw-r--r--  1 root   root    1316 2005-02-22 11:48 hello1.o
-rw-r--r--  1 root   root    6399 2005-02-22 11:48 .hello1.o.cmd
 y le doy:
# insmod ./hello.o
y me sale lo mismo. �el modulo compilado si es *.o? �esa es la forma
correcta de instalar un modulo?





-- 
��Abajo los imperialistas!!
No a la invasi�n en Irak




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Responder a