I've compiled a basic hello world Android kernel module using goldfish 
2.6.29 for the emulator

Code:

#include /* Needed by all modules */
#include /* Needed for KERN_INFO */
#include /* Needed for the macros */
static int hello3_data __initdata = 3;
static int __init hello_3_init(void)
{
printk(KERN_INFO "Hello, world %d\n", hello3_data);
return 0;
}
static void __exit hello_3_exit(void)
{
printk(KERN_INFO "Goodbye, world 3\n");
}
module_init(hello_3_init);
module_exit(hello_3_exit);


and written the following in the Makefile :

Code:

VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 29
EXTRAVERSION =
obj-m += hello_3.o
KDIR=/home/aniket/beproject/htconev/android/goldfish
PWD := $(shell pwd)
all:
make -C $(KDIR) ARCH=arm 
CROSS_COMPILE=/home/aniket/beproject/android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
 
SUBDIRS=$(PWD) modules
clean:
make -C $(KDIR) ARCH=arm 
CROSS_COMPILE=/home/aniket/beproject/android/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
 
SUBDIRS=$(PWD) clean


However after running make, pushing it to the Android device and running 
insmod it gives me an error :
 

insmod: init_module _.ko failed (Exec format error)


I got rid of that error using 
Code:

make CFLAGS_MODULE=-fno-pic

on the kernel module

Now i can use insmod module.ko and module gets installed and is shown as 
live by running cat /proc/modules
However dmesg gives the output as :

hello_3: module license 'unspecified' taints kernel.
hello_3: unknown relocation: 27
hello_3: no version for "magic" found: kernel tainted.


Can anyone please tell me where I've gone wrong ?

-- 
-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel
--- 
You received this message because you are subscribed to the Google Groups 
"Android Linux Kernel Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-kernel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to