linux 加载模块时遇到:

insmod: init_module 'xxx.ko' failed (No such file or directory)

解决办法:

使用dmesg查看问题            

dmesg

发现:

         xxx: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)

解决方案:

        编译的时候加入 EXTRA_CFLAGS=-fno-pic 参数

比如:

obj-m += xxx.o
KDIR = /home/RK3128/rk3128sdk/kernel
PWD := $(shell pwd)
ARCH=arm 
CROSS_COMPILE = /home/RK3128/rk3128sdk/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-

all:
	$(MAKE) -C $(KDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)  EXTRA_CFLAGS=-fno-pic  M=$(PWD) modules
clean:
	rm -rf *.o *.ko .depend *.mod.o *.mod.c Module.* modules.* 

Logo

更多推荐