insmod: init_module 'hello.ko' failed (Exec format error)
来源:互联网 发布:ni 高速数据采集卡 编辑:程序博客网 时间:2024/05/20 05:09
在经过重新编译的goldfish内核上,已经运行了安卓模拟器,正在动态添加自己编译的内核。
一开始的时候我从网上找了个hello.c文件,按照他的方式写了Makefile文件,但是当运行命令insmod的时候,会报错:
insmod: init_module 'hello.ko' failed (Exec format error)
期间,查了好多资料依然没有解决,然后又重新按照这篇博客的方式试了一下,竟然成功了,连接地址:http://blog.csdn.net/yf210yf/article/details/9901375
下面我把他的Makefie文件贴出来,hello.c文件没有问题,问题就出在Makefile上,按照他的方式写Makefile,便可以动态插入自己编译的内核了。下面贴代码:
obj-m := hello-yf.o
hello-yf-objs := hello.o
KID :=~/android-kernel/goldfish
PWD := $(shell pwd)
ARCH=arm
CROSS_COMPILE=arm-eabi-
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld
all:
make -C $(KID) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=${PWD} modules
clean:
rm -rf *.o .cmd *.ko *.mod.c .tmp_versions
但是,我现在不知道为什么他这样写是正确的,我在研究研究。等把原理弄清楚了,在更新这篇博客,不过这个问题已经解决了。
我大概明白是为什么了,大家看这个代码:
all:
make -C $(KID) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=${PWD} modules
我觉得这段代码是解决这个问题的关键,首先通过make -C $(KID),将当前的goldfish内核源码的本地路径指定为编译环境,然后分别给ARCH 和交叉编译的环境变量分别赋值,这样的话就不会在出现上面的问题了。如果大家想要自己编译自己的内核按照,这种方式去写makefile文件的话,应该是没有问题的。
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
在更新一下,“M=”选项的作用是,当用户需要以某个内核为基础编译一个外部模块的话,需要在make modules 命令中加入“M=dir”,程序会自动到你所指定的dir目录中查找模块源码,将其编译,生成KO文件。这样一来生成的ko文件才能动态插入到内核中。
- insmod: init_module 'hello.ko' failed (Exec format error)
- ok6410开发板android底层驱动模块编写,出现insmod:init_module ‘hello.ko’ failed (Exec format error)
- insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- 解决insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod: error inserting 'hello.ko': -1 Invalid module format
- 解决insmod: error inserting 'hello.ko': -1 Invalid module format
- insmod问题: init_module xxxxx.ko' failed (Operation not permitted)
- 可以解决问题insmod: error inserting 'hello.ko': -1 Invalid module format
- 解决insmod: error inserting 'helloworld.ko': -1 Invalid module format
- 解决insmod: error inserting 'helloworld.ko': -1 Invalid module format
- 解决insmod: error inserting 'helloworld.ko': -1 Invalid module format
- insmod: error inserting 'simp-blkdev.ko': -1 Invalid module format
- insmod: error inserting 'first_drv.ko': -1 Invalid module format
- Java高新技术---反射&动态代理
- iOS开发滚动视图UIScrollView
- Emacs
- Oracle 应用之--Virtualbox UUID问题
- 敏感字符过滤
- insmod: init_module 'hello.ko' failed (Exec format error)
- [IOS]iphone从相册或相机获取图片
- 文章标题
- ftl页面中获取map值
- Maven 修改本地存储库位置
- 关于IIS服务器下载新文件类型提示找不到文件的问题
- WebView详解
- android第三方应用安装来源设置分析
- Linux 性能监控、测试、优化工具