The structure of an LKM is not a secret. It may be retrieved from Linux kernel sources, which are freely available and, therefore, we have no need to dig any deeper into it; instead, following Occam's Razor principle, let's move on to the implementation of the module.
As has been mentioned already, an LKM is an object file; therefore, we begin by creating a lkm.asm file and entering our code like this:
format ELF64 ; 64-bit ELF object file
extrn printk ; We are going to use this symbol,
; exported by the kernel, in order to
; have an indication of the module being
; loaded without problems
Right after this, we are free to begin creating sections of an LKM.