MODULE_INFO in Linux Device Driver

'modinfo' section in the .ko (ELF) file stores the Module information. MODULE_INFO is the macro which can be used in the source code to add information to this section

#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
#define __MODULE_INFO(tag, name, info)                    \
static const char __UNIQUE_ID(name)[]                     \
  __used __attribute__((section(".modinfo"), unused, aligned(1)))     \
  = __stringify(tag) "=" info

MODULE_INFO is used in several places by other macros such as 
  • license, 
  • alias,
  • author,
  • vermagic.

Some of the fields can be retrieved through the THIS_MODULE (struct module)

Code:



Output:


modinfo utility lists each attribute of the module in form fieldname:value, for easy reading  from the Linux Kernel modules given on the command line


In the above screenshot, we used readelf, to dump the contents of the modinfo section.

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