'(missing .modinfo section or name field): No module found in object

I am trying to run a kernel module , however I got invalid module format when I try to load it using insmod insmod: ERROR: could not insert module mymodule.ko: Invalid module format

running dmesg I got the following output (missing .modinfo section or name field): No module found in object [] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 00000

Makefile

obj-m = mymodule.o
KVERSION = $(shell uname -r)
all:
    make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) modules
clean:
    make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) clean

mymodule.c

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>



MODULE_LICENSE("GPL");
MODULE_AUTHOR("ME");
MODULE_DESCRIPTION("TEST of The bla bla bla");


static int __init ModuleInit(void) {
    /*
     Some Code
    */
    return 0;

}

static void __exit ModuleExit(void) {
        printk ("Module EXIT");
}

module_init(ModuleInit);
module_exit(ModuleExit);

kernel version : 5.13.0-30-generic



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source