日期:2014-05-16 浏览次数:20701 次
// hello.c #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } int say_hello(void) { printk(KERN_ALERT "Want me say hello again?\n"); return 0; } EXPORT_SYMBOL(say_hello); module_init(hello_init); module_exit(hello_exit);
// greeting.c #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); extern int say_hello(void); static int greeting_init(void) { say_hello(); return 0; } static void greeting_exit(void) { printk("No more greetings.\n"); } module_init(greeting_init); module_exit(greeting_exit);
$ cat /proc/kallsyms | grep hello f7cf1000 t hello_exit [hello] f7cf100c t hello_init [hello] f7cf1000 t cleanup_module [hello] f7cf100c t init_module [hello] fbc9f74e t br_hello_timer_expired [bridge] fbca0027 t show_hello_timer [bridge] fbca00fb t store_hello_time [bridge] fbca0264 t set_hello_time [bridge] fbca01ee t show_hello_time [bridge]