i'm crosscompiling a helloworld kernel module
my files are:
hello-1.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
KBuild
obj-m := hello-1-helper.o
hello-1-helper-y := hsllo-1.o
Makefile
export KERNDIR=/home/myname/NXP/SDK2_0/QorIQ-SDK-V2.0-20160527-yocto/build_t1042d4rdb/tmp/work/t1042d4rdb-fsl-linux/linux-qoriq/4.1-r0/git
export PATH:=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/powerpc-fsl-linux:${PATH}
export ARCH=powerpc
export ARCH_CFLAGS+= -fPIC
default:
$(MAKE) -C $(KERNDIR) CROSS_COMPILE=powerpc-fsl-linux- M=`pwd` V=1 modules
clean:
$(MAKE) -C $(KERNDIR) M=`pwd` clean
And here's my terminal output showing error in insmod command:
module_32: hello-1-helper: unknown ADD relocation: 18
insmod: can't insert 'hello-1-helper.ko': invalid module format
but when i comment below line in makefile, everything is ok.
export ARCH_CFLAGS+= -fPIC
for simple codes like this, i can remove this flag. but in another code that i should use -fPIC flag, i have same error
how can i solve it?