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

  1. Hi, this is a very interesting matter about vermagic. Could yo tell me how can I do that. I am new in this area. thx

    ReplyDelete

Post a Comment

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig