解答1:.o的文件是object文件,.ko是kernel object,与.o的区别在于其多了一些sections,比如.modinfo。.modinfo section是由kernel source里的modpost工具生成的,包括MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_LICENSE, device ID table以及模块依赖关系等等。 depmod 工具根据.modinfo section生成modules.dep, modules.*map等文件,以便modprobe更方便的加载模块。
解答2:The short answer is that the .ko file is your object file linked with some kernel automatically generated data structures that are needed by the kernel.
The .o file is the object file of your modules - the result of compiling your c files. The kernel build system then automatically creates another C file with some data structures describing the kernel module (named your_module_kmod.c), compile this C file into another object file and links your object file and the object file it built together to create the .ko file.
The dynamic linker in the kernel that is in charge of loading kernel modules, expects to find the data structure the kernel put in the kmod object in the .ko file and will not be able to load your kernel module without them