zoukankan      html  css  js  c++  java
  • 内核模块版本和内核版本不一致的处理方法

    内核版本是如何生成的:

        Linux 内核在进行模块装载时先完成模块的 CRC 值校验,再核对 vermagic 中的字符信息,linux版本:在linux/utsrelease.h中定义,文件中的内容如下:#define UTS_RELEASE "2.6.35.7-perf+",utsrelease.h是kernel编译后自动生成的,用户更改里面的内容不会有效果。

        在init/version.c中,定义了kernel启动时的第一条打印信息:

    const char linux_banner[] =  
        "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"  
        LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "
    ";

    这里UTS_RELEASE在kernel编译时自动生成

        在init/main.c的start_kernel函数中,有kernel启动的第一条打印信息,这条信息是dmesg命令打印出来:

    printk(KERN_NOTICE "%s", linux_banner);

    方法二:

        驱动模块的version magic信息是怎么生成的:

       2 .6内核下,在linux/vermagic.h中定义有VERMAGIC_STRING,VERMAGIC_STRING不仅包含内核版本号,还包含有 内核使用的gcc版本,SMP与PREEMPT等配置信息。模块在编译时,我们可以看到屏幕上会显示"MODPOST"。在此阶 段,VERMAGIC_STRING会添加到模块的modinfo段。在内核源码目录下scriptsmodmodpost.c文件中可以看到模块后 续处理部分的代码。模块编译生成后,通过`modinfo mymodule.ko`命令可以查看此模块的vermagic等信息。2.6内核下的模块装载器里保存有内核的版本信息,在装载模块时,装载器会比较所 保存的内核vermagic与此模块的modinfo段里保存的vermagic信息是否一致,两者一致时,模块才能被装载。为了使两个版本一致:可以把 依赖源码中的include/linux/vermagic.h中的UTS_RELEASE修改成与目标机器的版本一致,这样,再次编译模块就可以了。


    参考:

    http://blog.sina.com.cn/s/blog_6e5e78bf010105jj.html

    http://blog.csdn.net/armeasy/article/details/6027563

     

  • 相关阅读:
    [AngularFire 2] Protect Write Access Using Security Rules
    [Ramda] Handle Branching Logic with Ramda's Conditional Functions
    [Angular2 Router] Setup page title with Router events
    [HTML] Creating visual skip links in HTML and CSS
    [AngularFire2] Signup and logout
    [AngularFire2] Building an Authentication Observable Data Service
    [Swift] Add Scroll View
    [Swift] Storyboard outlet and action
    [AngularFire2] Auth with Firebase auth -- email
    网站优化与Cdn文件传输服务
  • 原文地址:https://www.cnblogs.com/muyuzhanglao/p/4311225.html
Copyright © 2011-2022 走看看