【问题标题】:Linux Kernel Module development compile for other kernelLinux内核模块开发编译为其他内核
【发布时间】:2017-05-27 13:12:00
【问题描述】:

我在其他中使用 LinK+ 来开发一个 linux 内核模块。我的开发机器安装了 Linux Mint 18 操作系统,内核版本为 4.4.xx。为了测试,我想将内核模块部署到内核版本为 3.16.xx 的 Debian 机器(在虚拟机中)。

LinK+ 有一个名为“为其他内核编译”的选项(见下图)

当我按下该按钮时,一个对话框要求我指向内核源位置。我从https://www.kernel.org/ 下载了内核版本 3.16.xx,然后指向从该存档中提取的文件。

make 命令的输出是这样的:

**** Build of configuration Debug for project VMDD ****

make --makefile=Makefile --directory=KERN_SRC modules 
make: Entering directory '/home/george/linkProjects/VMDD/KERN_SRC'
make -C /home/george/kernels/linux-3.16.43/ M=/home/george/linkProjects/VMDD/KERN_SRC modules
make[1]: Entering directory '/home/george/kernels/linux-3.16.43'

  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /home/george/linkProjects/VMDD/KERN_SRC/VMDD.o
/bin/sh: 1: ./scripts/recordmcount: not found
scripts/Makefile.build:263: recipe for target '/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o' failed
make[2]: *** [/home/george/linkProjects/VMDD/KERN_SRC/VMDD.o] Error 127
Makefile:1337: recipe for target '_module_/home/george/linkProjects/VMDD/KERN_SRC' failed
make[1]: Leaving directory '/home/george/kernels/linux-3.16.43'
make[1]: *** [_module_/home/george/linkProjects/VMDD/KERN_SRC] Error 2
make: *** [modules] Error 2
Makefile:8: recipe for target 'modules' failed
make: Leaving directory '/home/george/linkProjects/VMDD/KERN_SRC'

我做错了什么?

【问题讨论】:

    标签: linux linux-kernel kernel-module


    【解决方案1】:

    我从https://www.kernel.org/ 下载了内核版本 3.16.xx,然后指向从该存档中提取的文件。

    如果您只有原始源代码,则无法为某些内核编译模块。您需要点 IDE 来配置和部分构建内核。实际上,为某个内核版本构建模块所需的所有文件都在编译内核的 kbuild 目录中,安装到 /lib/modules/version/kbuild。有 linux-kbuild-version (https://packages.debian.org/jessie/kernel/linux-kbuild-3.16) 包和一些文件 https://packages.debian.org/jessie/amd64/linux-kbuild-3.16/filelist 和 linux-headers-version (https://packages.debian.org/jessie/linux-headers-3.16.0-4-amd64) 其中包括 Module.symvers ( https://packages.debian.org/jessie/amd64/linux-headers-3.16.0-4-amd64/filelist):

    /usr/src/linux-headers-3.16.0-4-amd64/Module.symvers

    【讨论】:

    • 如何在不替换当前内核的情况下“配置和部分构建内核”?
    • George02,我不知道 LinK+ IDE 及其对指向其他内核的目录的要求。我知道 Debian 中的软件包包含在本地构建内核模块所需的所有文件(使用 2 个软件包名称更新答案;它们允许使用 kernel.org/doc/Documentation/kbuild/modules.txtmake -C /lib/modules/__VERSION__/build M=$PWD 在本地构建内核模块)。它们安装在不同的目录中,我不知道如何将它们复制和组织到 LinK+ 的单个目录中。
    • @George02,只需在虚拟 Debian 中安装构建模块所需的模块,然后: 在虚拟机中使用 make -C /lib/modules/`uname -r`/build M=$PWDmake -C /lib/modules/`uname -r`/build M=$PWD modules_install 构建模块;或检查/lib/modules/`uname -r`/build 目录中的内容并递归(带有链接)将其复制到主机,然后指向复制到LinK+。
    • 是的 :)) 愚蠢的我。我可以在我的虚拟机中构建模块。
    猜你喜欢
    • 2011-05-03
    • 2011-06-06
    • 1970-01-01
    • 2019-05-18
    • 2023-03-14
    • 2012-02-22
    • 2014-01-25
    相关资源
    最近更新 更多