vermagic in Linux Device Driver

Vermagic is a magic string present in the Linux Kernel and added into the .modinfo section of the Linux Kernel Modules.

This is used to verify whether the kernel module was compiled for the particular kernel version or not.

‘VERMAGIC_STRING’ is generated by the kernel configuration.

#define VERMAGIC_STRING                         \
    UTS_RELEASE " "                         \
    MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT             \
    MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS   \
    MODULE_ARCH_VERMAGIC                        \
    MODULE_RANDSTRUCT_PLUGIN

Code:

Output:

If we change the value of 'vermagic' string using 'MODULE_INFO', we will get the error while loading the module.


Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto