gpt4 book ai didi

ubuntu - insmod 无法插入一个非常简单的模块

转载 作者:太空宇宙 更新时间:2023-11-03 16:49:19 24 4
gpt4 key购买 nike

我正在尝试编译一个模块并将其插入到我的内核中,但我一直收到此错误:

insmod: error inserting 'hello.ko': -1 Invalid module format

我在这里按照本教程中描述的步骤操作:http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html .一切似乎都有意义并且有效。我编译了我的示例模块,但有一条警告可能是导致这件事失败的重要原因。警告是这样的:

WARNING: Symbol version dump /usr/src/linux-3.0.0/Module.symvers is missing; modules will have no dependencies and modversions.

坦率地说,我不知道为什么没有 Module.symvers 文件。 /usr/src/linux-3.0.0 目录及其所有内容都是我在使用以下命令下载源代码后创建的:

apt-get source linux-image-$(uname -r)

事实上,那是该教程中我没有遵循的唯一步骤,因为我无法找到我的内核 (3.0.0-32-generic) 的确切来源,并认为 aptitude 工具会解决这个问题我。

顺便说一句,我在 64 位机器上运行 Ubuntu,这是 uname -a 输出:

Linux vega 3.0.0-32-generic #51-Ubuntu SMP Thu Mar 21 15:50:59 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

关于接下来要尝试什么有什么建议吗?有什么推荐读物吗?

PS1。经过更多研究后,我确认我正在运行 3.0.0-32-generic。更新 grub 返回:

Found linux image: /boot/vmlinuz-3.0.0-32-generic

但是在发出 sudo make oldconfig 并检查生成的 .config 文件后,我得到了这个有趣的行:

CONFIG_VERSION_SIGNATURE="Ubuntu 3.0.0-32.51-generic 3.0.69"

这是否符合不匹配的条件?

PS2。 dmesg 输出这个:

[    5.869900] ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 6.144304] EXT4-fs (dm-1): re-mounted. Opts: errors=remount-ro
[ 6.368936] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[ 6.433919] vesafb: mode is 640x480x32, linelength=2560, pages=0
[ 6.433921] vesafb: scrolling: redraw
[ 6.433923] vesafb: Truecolor: size=8:8:8:8, shift=24:16:8:0
[ 6.435424] vesafb: framebuffer at 0xb0000000, mapped to 0xffffc90012800000, using 1216k, total 1216k
[ 6.435516] Console: switching to colour frame buffer device 80x30
[ 6.443104] EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)
[ 6.450198] fb0: VESA VGA frame buffer device
[ 8.884523] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
[ 8.885845] ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[ 12.611236] init: ssh main process (762) terminated with status 255
[ 12.624381] init: failsafe main process (752) killed by TERM signal
[ 12.634739] type=1400 audit(1373412287.107:8): apparmor="STATUS" operation="profile_load" name="/usr/sbin/tcpdump" pid=852 comm="apparmor_parser"
[ 12.634873] type=1400 audit(1373412287.107:9): apparmor="STATUS" operation="profile_replace" name="/sbin/dhclient" pid=851 comm="apparmor_parser"
[ 12.635180] type=1400 audit(1373412287.107:10): apparmor="STATUS" operation="profile_replace" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=851 comm="apparmor_parser"
[ 12.635403] type=1400 audit(1373412287.107:11): apparmor="STATUS" operation="profile_replace" name="/usr/lib/connman/scripts/dhclient-script" pid=851 comm="apparmor_parser"
[ 19.390991] eth1: no IPv6 routers present
[ 576.758697] hello: no symbol version for module_layout

最佳答案

您当前的内核版本是 3.0.0-32-generic转到 cd/lib/modules/3.0.0-32-gereric/ 目录并检查构建目录是否存在。如果存在,那么您可以使用以下命令直接编译您的模块

make -C /lib/modules/3.0.0-32-generic/build M=$(PWD) modules

如果你想用你下载的内核编译你的模块,那么请按照以下步骤操作:

cd /usr/src/linux-3.0.0/

make menuconfig

make -j5

make modules

sudo make modules_install

sudo make install

sudo reboot

然后使用 linux-3.0.0 内核启动您的系统,并使用以下命令编译您的模块:

make -C /lib/modules/3.0.0/build M=$(PWD) modules

关于ubuntu - insmod 无法插入一个非常简单的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17560989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com