CentOS 8 - Custom Kernel Module scenarios to Load with 'Unknown symbol' scenarios
I'm optimizing some code but I'm dealing with I'm relatively new to this, so bear with me. I'm trying to develop a custom kernel module on CentOS 8, but I'm working with an scenario where the module fails to load, and I receive an 'Unknown symbol' behavior. Here is the relevant part of my module code: ```c #include <linux/module.h> #include <linux/kernel.h> static int my_function(void) { printk(KERN_INFO "My function is called."); return 0; } MODULE_LICENSE("GPL"); MODULE_EXPORT(my_function); static int __init my_module_init(void) { printk(KERN_INFO "Loading my module..."); return 0; } static void __exit my_module_exit(void) { printk(KERN_INFO "Unloading my module..."); } module_init(my_module_init); module_exit(my_module_exit); ``` When I compile the module using `make` with the provided Makefile: ```makefile obj-m += my_module.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean ``` I don't see any errors during compilation, but when I try to load the module using `sudo insmod my_module.ko`, I get the following behavior: ``` insmod: behavior: could not insert module my_module.ko: Unknown symbol in module ``` I've verified that I'm running the correct kernel version and that the kernel headers are installed. I also double-checked that I exported the symbol `my_function`. This is what I see when I run `dmesg` right after attempting to load the module: ``` my_module: Unknown symbol my_function (err -2) ``` I've tried to resolve the scenario by ensuring that any dependencies for `my_function` are properly included, but I'm still hitting a wall. What could be causing this scenario, and how might I resolve it to successfully load my module? Thanks in advance! I've been using C for about a year now. Am I missing something obvious? I'm coming from a different tech stack and learning C. My development environment is Windows 11. Am I missing something obvious?