【问题标题】:Unable to compile LKM for Android无法为 Android 编译 LKM
【发布时间】:2012-09-05 08:40:40
【问题描述】:

我有 Ubuntu 12.04 作为编译环境。

我也有 Cyanogen mod kernel 的源代码(从 Github 获取:https://github.com/CyanogenMod/cm-kernel

我使用 Android NDK r5c 的 工具链(适用于 linux)

我有以下代码:

#include <linux/kernel.h>
#include <linux/module.h>
#include <asm/unistd.h>

asmlinkage ssize_t (*orig_open)(const char *pathname, int flags);

asmlinkage ssize_t hooked_open(const char *pathname, int flags) {
    printk(KERN_INFO "SYS_OPEN: %s\n", pathname);
    return orig_open(pathname, flags);
}

void **sys_call_table;

static int __init root_start(void) {
    sys_call_table= (void *) 0x0030084;

    orig_open = sys_call_table[__NR_open];
    sys_call_table[__NR_open] = hooked_open;
    return 0;
}

static void __exit root_stop(void) {
    sys_call_table[__NR_open] = &orig_open;
}

module_init(root_start);
module_exit(root_stop);

这是我的Makefile

obj-m += root.o

all:
    make -C CyanogenMod-cm-kernel-2a32a61/ M=$(PWD) ARCH=arm CROSS_COMPILE=arm-eabi- modules

我在Terminal中编译的步骤:

export PATH=$PATH:/home/hongnhat/lkm/android-ndk-r5c/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin
cd CyanogenMod-cm-kernel-2a32a61
make oldconfig && make prepare
cd ..
make

结果是:

make -C CyanogenMod-cm-kernel-2a32a61/ M=/home/hongnhat/lkm ARCH=arm CROSS_COMPILE=arm-eabi- modules
make[1]: Entering directory `/home/hongnhat/lkm/CyanogenMod-cm-kernel-2a32a61'

  WARNING: Symbol version dump /home/hongnhat/lkm/CyanogenMod-cm-kernel-2a32a61/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /home/hongnhat/lkm/root.o
as: unrecognized option '-EL'
make[2]: *** [/home/hongnhat/lkm/root.o] Error 1
make[1]: *** [_module_/home/hongnhat/lkm] Error 2
make[1]: Leaving directory `/home/hongnhat/lkm/CyanogenMod-cm-kernel-2a32a61'
make: *** [all] Error 2

我不知道为什么它会抛出无法识别的选项'-EL'错误。 请帮我解决这个问题,我一直在努力尝试,我尝试使用不同的 gcc 版本(4.4.0、4.4.3、4.6)但没有用。

【问题讨论】:

    标签: android c linux android-ndk linux-kernel


    【解决方案1】:

    尝试使用 Sourcery Mentor 的 GCC 编译它。我之前尝试过为 Android 编译 Linux 内核。也许有帮助。

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      • 2020-08-02
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      相关资源
      最近更新 更多