Two articles on the role of Linux kernel compiler config_modversions.
In general, if you do not select Config_modversions, these symbols are normal strings, and if you select Config_modversions, the symbols are followed by a check string. This is done to prevent the Linux kernel from crashing when the module does not load properly.
One
If the kernel chooses the config_modversions option, add the following lines to your module's makefile
Cflags + +-dmodversions-include/usr/src/linux/include/linux/modversions.h
or add to your C source file.
#ifdef config_modversions
#define Modversions
#include <linux/modversions.h>
#endif
This allows you to compile the kernel module, and if the module references the kernel symbol table, you can automatically compute the checksum string without unresloved symbol error when loading the module.
Two
But when your kernel makes the config_modversions option at compile time, the module you insert can be a couple of things:
1, there is no config_modversions option at compile time, but the version must be consistent with the kernel version;
2, the version of the module will be unlimited if the config_modversions option is available at compile time;
Typically, the kernel is compiled with the config_modversions option, so there is a situation at the beginning of the article: the kernel and the version of the module are inconsistent. At the same time we found the solution--Select the Config_modversions option at the module compile time, so we can solve the problem of version mismatch.
We need to add the following macro definition to the source file (c file):
#ifdef config_modules
#ifdef config_modversions
#MODFLAGS + =-dmodversions- Include $ (hpath)/linux/modversions.h
#endif
#endif
and then compile it.