内核符号导出
本实验用到的三个文件:Makefile、calculate.c、hello.c
(1)Makefile
ifneq ($(KERNELRELEASE),)
obj-m := hello.o calculate.o
else
KDIR := /lib/modules/2.6.18-53.el5/build
all:
clean:
endif
(2)calculate.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
int add_integar(int a,int b)
{
}
int sub_integar(int a,int b)
{
}
static int __init sym_init()
{
}
static void __exit sym_exit()
{
}
module_init(sym_init);
module_exit(sym_exit);
EXPORT_SYMBOL(add_integar);
EXPORT_SYMBOL(sub_integar);
(3)hello.c
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
extern int add_integar(int a,int b); //extern可以置于变量或者函数前,
extern int sub_integar(int a,int b);
static int __init hello_init(void)
{
}
static void __exit hello_exit()
{
}
module_init(hello_init);
module_exit(hello_exit);
在这里,编译加载内核模块就不再详述
查看当前环境下内核导出了那些符号
或直接查找