Around Linux Driver vermagic check __linux

Source: Internet
Author: User

*linux Driver vermagic* Check

In the development of kernel driver, there will always be annoying vermagic checks, so long as the kernel version of Run is inconsistent with the driver version used in kernel, there is no way to insmod.

bash-3.2# Insmod Sdio.ko

Sdio:version Magic ' 2.6.28-271-gec75a15 preempt mod_unload modversions
ARMv7 '
Should be ' 2.6.28 preempt mod_unload ARMv7 '
Insmod:init_module ' Sdio.ko ' failed (Exec format error)

This greatly reduces the speed of development, especially when you do not get the customer in the use of kernel, but also to develop driver for him, it is really troublesome ...

So how do you use the disgusting way to get around it???

First, the *moudle version* check out.

User@host # Arch=arm Make Menuconfig

-enable loadable Module support││

││[] Forced module loading││
││[*] Module unloading││
││[*] Forced module unloading││
││[] Module Versioning support││
││[] Source checksum for all modules

Two
When using *modinfo* , you can see the current *driver* **vermagic

Filename:external_drivers/omap3530/linux/sdio/sdio.ko

Author:texas Instruments Inc.

Alias:tiwlan_sdio

License:gpl

Description:ti WLAN SDIO Driver

Depends:

VERMAGIC:2.6.28-271-GEC75A15 preempt Mod_unload ARMv7

Parm:g_sdio_debug_level:debug level (int)

Third, modify the kernel vermagic, and then re-translated driver

The first value of Vermagic is 2.6.28-noneed by this include/linux/utsrelease.h
The definition of uts_release.

#define Uts_release "2.6.28-271-GEC75A15"

And then by the macro in include/linux/vermagic.h to assemble the vermagic_string,
Which is Kernel's vermagic.

#include

#include

/* Simply Sanity version stamp for modules. */

#ifdef CONFIG_SMP

#define MODULE_VERMAGIC_SMP "SMP"

#else

#define MODULE_VERMAGIC_SMP ""

#endif

#ifdef CONFIG_PREEMPT

#define MODULE_VERMAGIC_PREEMPT "Preempt"

#else

#define MODULE_VERMAGIC_PREEMPT ""

#endif

#ifdef Config_module_unload

#define MODULE_VERMAGIC_MODULE_UNLOAD "Mod_unload"

#else

#define MODULE_VERMAGIC_MODULE_UNLOAD ""

#endif

#ifndef config_modversions

#define Module_vermagic_modversions "Modversions"

#else

#define Module_vermagic_modversions ""

#endif

#ifndef module_arch_vermagic

#define MODULE_ARCH_VERMAGIC ""

#endif

#define VERMAGIC_STRING \

Uts_release ” ” \

MODULE_VERMAGIC_SMP module_vermagic_preempt \

Module_vermagic_module_unload module_vermagic_modversions \

Module_arch_vermagic

So, we just put uts_release
Change it to our numbers, and, of course, if lazy have to go to the string after the try group, you can also change the vermagic_string to the string you want.
:)

The suggestion modifies the vermagic.h,
After the utsrelease.h, or kernel again to edit the kernel, more insurance.

Here's what you can see with Modinfo after the change.

Filename:external_drivers/omap3530/linux/sdio/sdio.ko

Author:texas Instruments Inc.

Alias:tiwlan_sdio

License:gpl

Description:ti WLAN SDIO Driver

Depends:

vermagic:2.6.28 preempt Mod_unload ARMv7

Parm:g_sdio_debug_level:debug level (int)

Note: The include/linux/utsrelease.h is generated according to the Include/config/kernel.release;
These files are regenerated every time the kernel is compiled and can be modified
include/linux/vermagic.h files.

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.