How the kernel module compiles when it bypasses Insmod version checking

Source: Internet
Author: User
Tags using git

------------------------------------------------------------------------------------------Add----------------------------- ----------------------------------------------------------------------

1, Uboot: Each arm chip or the sea chip have their own uboot.

2, but their kernel version can be the same, mainly with the respective kernel of the compilation options, 31 of the kernel version of the version check option "Kernel type->symmetrical multi-processing", The kernel version of 21 does not have this option set.

--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------

When developing kernel driver, there will always be annoying vermagic checks, so long as there is no inconsistency between the kernel version of run and the driver version used in kernel compilation, there is no way to insmod.

bash-3.2# Insmod Sdio.ko

Sdio:version Magic ' 2.6.28-271-gec75a15 preempt mod_unload modversions '

Should be ' 2.6.28 preempt mod_unload ARMv7 '

Insmod:init_module ' Sdio.ko ' failed (Exec format error)

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

So how do you use the disgusting way around it??? First, the Moudle version check off.

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 driver of the current 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 vermagic of kernel, and then recompile driver

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

#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 the vermagic of kernel.

#include
#include


#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完成编译后, you can have
#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 change the uts_release to our numbers, of course, if you don't bother to try the combination of strings, you can directly change the vermagic_string to the string you want

Proposed to modify the vermagic.h, utsrelease.h, or the kernel after the completion of the addendum kernel, more insurance.

The following is the result of a modified, modinfo look

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)

------------------------------------------------------------------------------------------

And if you're using Git for versioning, there's a git version number on the kernel number.
So we have to turn him off.


General Setup--->
[] Automatically append version information to the version Strin

Explain
Config_localversion_auto:│
││
│this'll try to automatically determine if it is a│
│release looking for git tags, belong to the current│
│top of tree Revision. │

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.