里面有个宏定义: __init,在网上找到了说明: 来自:http://www./bbs/showthread.php?t=3240 The __init and __exit declarations are special kernel macros designed to tell the kernel to flag these functions for special handling in cases where they are compiled in statically rather than included as parts of modules. The __init declaration allows the kernel to reclaim the space used by initialization functions, while the __exit declaration tells the kernel to just plain ignore the function altogether. If you’re only going to write your device driver as a module, with no possibility that it will be included statically, it is perfectly safe to leave these special declarations out. 另外在:http://www./forum/showflat.php?Cat=&Board=linuxK&Number=232807&page=57&view=collapsed&sb=5&o=all 中有这么一段,熟悉汇编的朋友可以看一下: nclude/linux/init.h #define __init __attribute__ ((__section__ (".text.init"))) 这个定义表明使用__init的函数编译后将位于.text.init段 arch/i386/vmlinux.lds . = ALIGN(4096); /* Init code and data */ __init_begin = .; .text.init : { *(.text.init) } .data.init : { *(.data.init) } . = ALIGN(16); __setup_start = .; .setup.init : { *(.setup.init) } __setup_end = .; __initcall_start = .; .initcall.init : { *(.initcall.init) } __initcall_end = .; . = ALIGN(4096); __init_end = .; 从__init_begin到__init_end中的这些部分,将在系统启动完成后,从内存中释放掉。实际上内核中的很多初始化代码在内核启动后是没有用的。 最后,说一下,我的目的其实是在AIX 4.3上写这样一个驱动程序,当然要是模块化的,前面的文章里的代码是在系统启动时静态加载进内核的,呵呵,就是 __init 干的。 在AIX 上的相关资料太少了,哪位有的话望不吝赐教啊! |
|