This section contains the code required for successful initialization of an LKM. In our case, as we are not adding any functionality to the module, it could simply return, but as we need an indication of our LKM having loaded successfully, we will implement a tiny procedure, which will print a string into the system log:
section '.init.text' executable
module_init:
push rdi ; We are going to use this register
mov rdi, str1 ; Load RDI with the address of the string
; we want to print to system log (we will
; add it to the data section in a few moments)
xor eax, eax
call printk ; Write the string to the system log
xor eax, eax ; Prepare return value
pop rdi ; Restore the RDI register
ret
Rather simple, isn't it? We just print the string and return from this procedure.