解决编译内核模块helloworld.c:1: 错误:代码模式‘kernel’在 32 位模式下不受支持问题,未编译对64位的支持
Makefile内容:
KERNELDIR ?=/root/Desktop/work/TI/linux-3.2.0 PWD := $(shell pwd) obj-m += helloworld.o default: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules clean: @rm -f *.o *.ord* *.sy* *.mod.* *.koclean标记中的@表示,执行命令的时候,终端上面不打印rm -r xxx.xx
make出错信息:
[root@localhost ldd3]# makemake -C /root/Desktop/work/TI/linux-3.2.0 M=/root/Desktop/work/ldd3 modules
make[1]: Entering directory `/root/Desktop/work/TI/linux-3.2.0'
CC [M] /root/Desktop/work/ldd3/helloworld.o
/root/Desktop/work/ldd3/helloworld.c:1: 错误:代码模式 ‘kernel’ 在 32 位模式下不受支持
/root/Desktop/work/ldd3/helloworld.c:1: 对不起,尚未实现:未编译入对 64 位模式的支持
make[2]: *** [/root/Desktop/work/ldd3/helloworld.o] 错误 1
make[1]: *** [_module_/root/Desktop/work/ldd3] 错误 2
make[1]: Leaving directory `/root/Desktop/work/TI/linux-3.2.0'
make: *** [default] 错误 2
出错原因:在内核目录中的Makefile,没有指定ARCH、CROSS_COMPILE。因为编译内核的时候,使用的是:make CROSS_COMPILE=arm-linux- ARCH=arm uImage命令,并未修改Makefile文件。
解决:指定ARCH、CROSS_COMPILE内容
ARCH=arm
CROSS_COMPILE=arm-linux-
在编译通过,生成helloworld.ko
最后更新:2017-04-03 14:54:20