Linux kernel compiler config_modversions function __linux

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.