编译模块时EXPORT_SYMBOL的用法 (转)
时间:2010-05-25 来源:1032120121
原帖http://blog.csdn.net/aaa6695798/archive/2009/08/25/4483748.aspx
Linux symbol export method:
[1] If we want export the symbol in a module, just use the EXPORT_SYMBOL(xxxx) in the C or H file.
And compile the module by adding the compile flag -DEXPORT_SYMTAB.
Then we can use the xxxx in the other module.
[2] If we want export some symbol in Kernel that is not in a module such as xxxx in the /arch/ppc/fec.c.
Firstly, define the xxxx in the fec.c;
Secondly, make a new file which contain the "extern" define the xxxx(for example, extern int xxxx);
Lastly, in the ppc_ksyms.c we includes the new file, and add the EXPORT_SYMBOL(xxxx).
Then we can use the xxxx. 其中第二条指明:在编译内核的同时编译模块,若出现某符号在模块中未定义的错误,则需要做以下事情: (1)找到该符号在内核代码中定义的文件 (2)在符号定义文件内#include <linux/module.h>文件 (3)在符号定义文件内EXPORT_SYMBOL(XXX) 导出该符号XXX供模块代码使用;
And compile the module by adding the compile flag -DEXPORT_SYMTAB.
Then we can use the xxxx in the other module.
[2] If we want export some symbol in Kernel that is not in a module such as xxxx in the /arch/ppc/fec.c.
Firstly, define the xxxx in the fec.c;
Secondly, make a new file which contain the "extern" define the xxxx(for example, extern int xxxx);
Lastly, in the ppc_ksyms.c we includes the new file, and add the EXPORT_SYMBOL(xxxx).
Then we can use the xxxx. 其中第二条指明:在编译内核的同时编译模块,若出现某符号在模块中未定义的错误,则需要做以下事情: (1)找到该符号在内核代码中定义的文件 (2)在符号定义文件内#include <linux/module.h>文件 (3)在符号定义文件内EXPORT_SYMBOL(XXX) 导出该符号XXX供模块代码使用;
相关阅读 更多 +