Hello world kernel module for android & unknown relocation: 27 when insmod

后端 未结 2 569
悲&欢浪女
悲&欢浪女 2021-01-17 13:30

I am trying to create a simple kernel module. I am trying to print messages to dmesg but i keep getting

insmod: init_module \'hello.ko\' failed (Exec format error) i

相关标签:
2条回答
  • 2021-01-17 13:43

    Thanks, -fno-pic got my dlkm working also. On to "real" work...

    BTW, you can export ARCH, SUBARCH, CROSS_COMPILE, KERNELDIR in the shell so the Makefile becomes very simple. This also allows one to more easily build the dlkm for the native or target platform by setting the KERNELDIR properly (native does not need the ARCH, SUBARCH or CROSS_COMPILE vars.)

    obj-m += hello.o

    all: make -C $(KERNELDIR) M=$(PWD) modules

    0 讨论(0)
  • 2021-01-17 13:51

    It turns out I had to use

    make CFLAGS_MODULE=-fno-pic
    
    0 讨论(0)
提交回复
热议问题