.o和.ko文件之间的区别 [英] Difference between .o and .ko file

查看:660
本文介绍了.o和.ko文件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写简单的Linux模块mod.c. 当我编译mod.c文件时,它将创建两个输出文件 mod.o mod.ko . 所以我只想知道 mod.o和mod.ko文件有什么区别?

I am writing simple Linux module mod.c. When I compile mod.c file, it creates two output file mod.o and mod.ko. So I just want to know, What is the difference between mod.o and mod.ko file?

推荐答案

简短的答案是 .ko 文件是您的目标文件,该文件与某些内核自动生成的数据结构链接,内核.

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.

.o 文件是模块的目标文件-编译C文件的结果.然后,内核构建系统会自动创建另一个具有描述内核模块的数据结构的C文件(名为your_module_kmod.c),将此C文件编译为另一个目标文件,并将您的目标文件和它一起构建的目标文件链接在一起以创建 .ko 文件.

The .o file is the object file of your module - the result of compiling your C file. 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.

内核中负责加载内核模块的动态链接程序,期望在 .ko 文件中找到内核放入kmod对象中的数据结构,并且将无法加载没有它们的内核模块.

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.

这篇关于.o和.ko文件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆