编译一个内核模块时出现的问题,请高手看一下
用 cc -c hello.c 编译如下代码
hello.c
#define MODULE
#define __KERNEL__
#include "linux/kernel.h"
#include "linux/module.h"
/* pross the CONFIG_MODVERSIONS*/
#ifdef MODVERSIONS
#include "linux/modversions.h"
#endif
/* the init function*/
int init_module()
{
printk(" hello !\n");
return 1;
}
/* the distory function*/
int cleanup_module()
{
return 1;
}
出现如下错误提示:
In file included from /usr/include/linux/prefetch.h:13,
from /usr/include/linux/list.h:6,
from /usr/include/linux/module.h:12,
from hello.c:5:
/usr/include/asm/processor.h:65: `CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function)
/usr/include/asm/processor.h:65: requested alignment is not a constant
请高手指点!!!
6,1 顶端
hello.c
#define MODULE
#define __KERNEL__
#include "linux/kernel.h"
#include "linux/module.h"
/* pross the CONFIG_MODVERSIONS*/
#ifdef MODVERSIONS
#include "linux/modversions.h"
#endif
/* the init function*/
int init_module()
{
printk(" hello !\n");
return 1;
}
/* the distory function*/
int cleanup_module()
{
return 1;
}
出现如下错误提示:
In file included from /usr/include/linux/prefetch.h:13,
from /usr/include/linux/list.h:6,
from /usr/include/linux/module.h:12,
from hello.c:5:
/usr/include/asm/processor.h:65: `CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function)
/usr/include/asm/processor.h:65: requested alignment is not a constant
请高手指点!!!
6,1 顶端
...全文
相关推荐
bsdmod:各种示范性的FreeBSD内核模块
**三、编写和调试内核模块**编写内核模块时,开发者需要熟悉FreeBSD内核的内部工作原理和API。调试模块通常使用`dtrace`工具,它提供了强大的动态跟踪功能,可以帮助定位问题所在。
kernel_compile_example.tar.gz
**调试**:如果模块在加载时出现问题,你可以使用`gdb`(GNU调试器)或者`kgdb`(内核调试器)进行调试。这些工具允许你在运行时检查内核模块的变量和函数。
内核编译的东西
当你需要针对特定硬件或特定功能进行优化,或者想要启用或禁用某些内核模块时,就需要进行内核编译。内核编译的过程可以分为以下几个步骤:1.
Linux内核重编译常见故障介绍.rar_linux_linux内核
**文件权限问题**:在编译过程中,确保拥有足够的权限访问和修改系统文件。`sudo`命令可以帮助解决这类问题,但请谨慎使用,以免破坏系统。10.
内核编译详解
如果遇到问题,记得备份原有的内核,以便在需要时回滚。总之,Linux内核编译是一个复杂但重要的过程,它允许用户根据自己的需求定制系统,提高性能,添加功能,以及确保系统的安全性。


