Difference between .o and .ko file

后端 未结 2 1802
情书的邮戳
情书的邮戳 2021-01-30 10:20

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 i

2条回答
  •  清歌不尽
    2021-01-30 11:00

    Before Linux 2.6, a user space program would interpret the ELF object (.o) file and do all the work of linking it to the running kernel, generating a finished binary image. The program would pass that image to the kernel and the kernel would do little more than stick it in memory. In Linux 2.6, the kernel does the linking. A user space program passes the contents of the ELF object file directly to the kernel. For this to work, the ELF object image must contain additional information. To identify this particular kind of ELF object file, we name the file with suffix ".ko" ("kernel object") instead of ".o" For example, the serial device driver that in Linux 2.4 lived in the file serial.o in Linux 2.6 lives in the file serial.ko.

    from http://tldp.org/HOWTO/Module-HOWTO/linuxversions.html .

提交回复
热议问题