解决编译内核模块helloworld.c:1: 错误:代码模式‘kernel’在 32 位模式下不受支持问题,未编译对64位的支持

来源:互联网 发布:庖丁解牛乎的意思 编辑:程序博客网 时间:2024/05/22 15:43

Makefile内容:

KERNELDIR ?=/root/Desktop/work/TI/linux-3.2.0PWD := $(shell pwd)obj-m += helloworld.odefault:    $(MAKE) -C $(KERNELDIR) M=$(PWD) modulesclean:    @rm -f *.o *.ord* *.sy* *.mod.* *.ko
clean标记中的@表示,执行命令的时候,终端上面不打印rm -r xxx.xx


make出错信息:

[root@localhost ldd3]# make
make -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


原创粉丝点击