Estoy tratando de compilar un ejemplo de "hello world" Kernel Module, problemas encontrados en ubuntu 11.04, kernel 3.2.6, gcc 4.5.2 y fedora 16, kernel 3.2.7, gcc 4.6.7.compilación de módulos: asm/linkage.h archivo no encontrado
código:
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int __init hello_init (void)
{
printk("Hello module init\n");
return 0;
}
static void __exit hello_exit (void)
{
printk("Hello module exit\n");
}
module_init(hello_init);
module_exit(hello_exit);
compilado con:
gcc -D__KERNEL__ -I /usr/src/linux/include/ -DMODULE -Wall -O2 -c hello.c -o hello.o
error:
In file included from /usr/src/linux/include/linux/kernel.h:13:0, from /usr/src/linux/include/linux/cache.h:4, from /usr/src/linux/include/linux/time.h:7, from /usr/src/linux/include/linux/stat.h:60, from /usr/src/linux/include/linux/module.h:10, from hello.c:1: /usr/src/linux/include/linux/linkage.h:5:25: fatal error: asm/linkage.h: file not found
entonces me encontré en/usr/src/linux/include/no hay ninguna carpeta llamada 'asm' pero 'asm-genérico'; así que hice un enlace blando 'asm' a 'asm-generic', y compilado agail:
esta vez fue el error:
In file included from /usr/src/linux/include/linux/preempt.h:9:0, from /usr/src/linux/include/linux/spinlock.h:50, from /usr/src/linux/include/linux/seqlock.h:29, from /usr/src/linux/include/linux/time.h:8, from /usr/src/linux/include/linux/stat.h:60, from /usr/src/linux/include/linux/module.h:10, from hello.c:1: /usr/src/linux/include/linux/thread_info.h:53:29: fatal error: asm/thread_info.h: file not found
Entonces me di cuenta de que estaba equivocado, pero ¿por qué? T_T
tengo que revisar las carpetas del núcleo src (3.2+) de 3 máquinas con Ubuntu, Fedora y gentoo, ninguno de ellos contiene la carpeta 'asm'. Así que creo que no es un error ... –
En el Redhat que revisé, '/ usr/src/kernels /.../includes/asm' es un enlace a' asm-x86_64'. – ugoren