__exit和__init的迷惑
1) __init:是内建模块的时候,初始化会使用到,用完之后就释放内存空间。当编译成模块时,insmod肯定也要用到,但是不会把函数占用的内存释放???
2) __exit:是内建模块的时候,肯定不会用到,因为根本就不要去卸载该模块。当编译成模块时,rmmod的时候,要调用吗???
请各位大侠指教下,谢谢
------解决方案--------------------
#ifdef MODULE
#define __exitused
#else
#define __exitused __used
#endif
#define __exit __section(.exit.text) __exitused __cold
/**
* module_exit() - driver exit entry point
* @x: function to be run when driver is removed
*
* module_exit() will wrap the driver clean-up code
* with cleanup_module() when used with rmmod when
* the driver is a module. If the driver is statically
* compiled into the kernel, module_exit() has no effect.
* There can only be one per module.
*/
根据init.h里的内容,__exit在模块时,肯定会调用的