神前晓作品:linux export 变量供模块使用

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 00:23:56
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.
[2].a e.g: 1. 在C文件中定义变量: int export_flag; 2. 在arch/arm/kernel/armksyms.c 文件中 加上: extern int export_flag; export_symbol(export_flag);   就可以了。