1 2 3 4 5 | # insmod ./hello/hello.ko insmod: error inserting './hello/hello.ko': -1 Invalid module format # dmesg | grep hello [ 9206.599843] hello: disagrees about version of symbol module_layout |
1 2 3 4 5 6 7 8 9 10 11 | /* kernel/module.c */ #ifdef CONFIG_MODVERSIONS void module_layout(struct module *mod, struct modversion_info *ver, struct kernel_param *kp, struct kernel_symbol *ks, struct tracepoint * const *tp) { } EXPORT_SYMBOL(module_layout); #endif |
1 2 3 4 5 6 | /* include/linux/module.h */ struct modversion_info { unsigned long crc; char name[MODULE_NAME_LEN]; }; |
1 2 3 4 5 6 7 8 9 | # uname – r 2.6.38-10-generic # modinfo ./hello/hello.ko filename: ./hello/hello.ko license: Dual BSD/GPL srcversion: 31FE72DA6A560C890FF9B3F depends: vermagic: 2.6.38-9-generic SMP mod_unload modversions |
1 2 | 0x1de386dd module_layout vmlinux EXPORT_SYMBOL <CRC> <Symbol> <module> |
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* kernel/module.c */ static int check_modinfo(struct module *mod, struct load_info *info) { const char *modmagic = get_modinfo(info, "vermagic"); ... } else if (!same_magic(modmagic, vermagic, info->index.vers)) { ... } ... return 0; } |
1 2 3 4 5 6 7 8 9 | /* kernel/module.c */ static const char vermagic[] = VERMAGIC_STRING; /* include/linux/vermagic.h */ #define VERMAGIC_STRING \ UTS_RELEASE " " \ MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \ MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \ MODULE_ARCH_VERMAGICLINE |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |