未知重定位:insmod后内核模块为27

时间:2014-01-26 14:19:25

标签: android linux-kernel kernel-module

我编译了一个基本的hello world Android内核模块

#include <linux/module.h>   /* Needed by all modules */
#include <linux/kernel.h>   /* Needed for KERN_INFO */
#include <linux/init.h>     /* 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);

并在Makefile中写下以下内容:

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

然而,在运行make并将其推送到Android设备后,它给了我一个错误:

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

我使用

摆脱了这个错误
make CFLAGS_MODULE=-fno-pic

在针对内核模块运行make时 然而,在使用dmesg后,它说:

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

有谁能告诉我哪里出错了?

0 个答案:

没有答案