Linux Device Driver
解決"unknown relocation: 10"問題
問題如下:
# insmod test.ko [ 7.175590] hello: unknown relocation: 10 [ 7.206189] hello: unknown relocation: 10 insmod: can't insert 'test.ko': invalid module format
定位到位置在arch/arm/kernel/module.c
default: pr_err("%s: unknown relocation: %u\n", module->name, ELF32_R_TYPE(rel->r_info)); return -ENOEXEC; } } return 0; }
定義值如下:
#define R_ARM_THM_CALL 10
往回找一下,發現在同一段
#ifdef CONFIG_THUMB2_KERNEL case R_ARM_THM_CALL: case R_ARM_THM_JUMP24:
THUMB2沒有被Enable
Enable後,再度編譯Kernel,出現很多編譯問題...
最後,司徒發現原來是export造成的問題,原本的export如下:
export ARCH=arm export CROSS=arm-linux-gnueabihf- export CC=${CROSS}gcc export LD=${CROSS}ld export AS=${CROSS}as export CXX=${CROSS}g++
改成如下即可
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf-