1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # cat ./kobject/kobject-example.mod.c ... MODULE_INFO(vermagic, VERMAGIC_STRING); struct module __this_module __attribute__((section(".gnu.linkonce.this_module"))) = { ... }; static const struct modversion_info ____versions[] __used __attribute__((section("__versions"))) = { ... }; static const char __module_depends[] __used __attribute__((section(".modinfo"))) = "depends="; MODULE_INFO(srcversion, "B06F9B8B7AB52AEED247B9F"); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # objdump --section=.modinfo -s hello/hello.o hello/hello.o: file format elf64-x86-64 Contents of section .modinfo: 0000 6c696365 6e73653d 4475616c 20425344 license=Dual BSD 0010 2f47504c 00 /GPL. # modinfo hello/hello.o filename: hello/hello.o license: Dual BSD/GPL # objdump --section=.modinfo -s hello/hello.mod.o ... # objdump --section=.modinfo -s hello/hello.ko ... |
1 2 3 4 5 6 7 8 9 10 | # insmod ./kobject/kobject-example.ko # ls /sys/kernel/kobject_example/ bar baz foo # lsmod | grep kobject kobject_example 12857 0 # cat /proc/modules | grep kobject kobject_example 12857 0 - Live 0xffffffffa0523000 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< else cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< cmd_modversions = \ if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ -T $(@D)/.tmp_$(@F:.o=.ver); \ rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ else \ mv -f $(@D)/.tmp_$(@F) $@; \ fi; endif |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |