Bonjour, j'ai compilé un programme kernel qui affiche hello word:
hello.c
* Copyright (C) 1998 by Ori Pomerantz
*
* "Hello, world" - the kernel module version.
*/
/* The necessary header files */
/* Standard in kernel modules */
#include <linux/kernel.h> /* We’re doing kernel work */
#include <linux/module.h> /* Specifically, a module */
/* Deal with CONFIG_MODVERSIONS */
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
/* If we return a non zero value, it means that
* init_module failed and the kernel module
* can’t be loaded */
return 0;
}
/* Cleanup - undid whatever init_module did */
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}
les erreurs suivantes son apparus:
abdelkader@abdelkader:~$ make hello
cc hello.c -o hello
In file included from /usr/include/asm-i486/local.h:4,
from /usr/include/asm/local.h:8,
from /usr/include/linux/module.h:20,
from hello.c:2:
/usr/include/linux/percpu.h: In function ‘__alloc_percpu’:
/usr/include/linux/percpu.h:44: error: ‘GFP_KERNEL’ undeclared (first use in this function)
/usr/include/linux/percpu.h:44: error: (Each undeclared identifier is reported only once
/usr/include/linux/percpu.h:44: error: for each function it appears in.)
In file included from /usr/include/asm/module.h:8,
from /usr/include/linux/module.h:22,
from hello.c:2:
/usr/include/asm-i486/module.h:60:2: error: #error unknown processor family
In file included
from hello.c:2:
/usr/include/linux/module.h: At top level:
/usr/include/linux/module.h:49: error: field ‘attr’ has incomplete type
/usr/include/linux/module.h:60: error: field ‘kobj’ has incomplete type
make: *** [hello] Erreur 1
le fichier make file :
# Makefile for a basic kernel module
CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
echo insmod hello.o to turn it on
echo rmmod hello to turn if off
echo
echo X and kernel programming do not mix.
echo Do the insmod and rmmod from outside X.
la distribution est debian version 4.0.
svp je veut comprend les erreurs pour que je puisse les résoudre.







Répondre avec citation
Partager