LiME内核模块交叉编译失败

时间:2019-07-12 08:21:04

标签: makefile linux-kernel cross-compiling kernel-module computer-forensics

我正在尝试使用以下Makefile交叉编译android-goldfish-3.10-n-dev的LiME内核模块(提交:3a3b199582a68ba0688a099147738738d6c99f3282d)Linux内核版本:

obj-m := lime.o
lime-objs := tcp.o disk.o main.o

KDIR_GOLD := /path/to/goldfish

PWD := $(shell pwd)
CCPATH :=/path/to/x86_64-linux-android-4.9/bin

default:
    # cross-compile for Android emulator
    $(MAKE) ARCH=x86_64 CROSS_COMPILE=$(CCPATH)/x86_64-linux-android-  -C $(KDIR_GOLD) M="$(PWD)" modules
    $(CCPATH)/x86_64-linux-android-strip --strip-unneeded lime.ko
    mv lime.ko lime-goldfish.ko

    $(MAKE) tidy

tidy:
    rm -f *.o *.mod.c Module.symvers Module.markers modules.order \.*.o.cmd \.*.ko.cmd \.*.o.d
    rm -rf \.tmp_versions

clean:
    $(MAKE) tidy
    rm -f *.ko

但是我收到以下错误/警告,并且编译失败。

make ARCH=x86_64 CROSS_COMPILE=/path/to/x86_64-linux-android-4.9/bin/x86_64-linux-android-  -C /path/to/goldfish M="/path/to/LiME/src" modules
make[1]: Entering directory '/path/to/goldfish'
  CC [M]  /path/to/LiME/src/tcp.o
  CC [M]  /path/to/LiME/src/disk.o
  CC [M]  /path/to/LiME/src/main.o
  LD [M]  /path/to/LiME/src/lime.o
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "param_ops_int" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "param_ops_charp" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "param_ops_long" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "ldigest_final" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "ns_to_timeval" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "kfree" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "ktime_get_real" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "iomem_resource" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "ldigest_init" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "sscanf" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "strcmp" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "kmem_cache_alloc_trace" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "kmalloc_caches" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "ldigest_update" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "vfs_write" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "filp_close" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "filp_open" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "kernel_sendmsg" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "sock_setsockopt" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "kernel_stack" [/path/to/LiME/src/lime.ko] undefined!
WARNING: "sock_create_kern" [/path/to/LiME/src/lime.ko] undefined!
  CC      /path/to/LiME/src/lime.mod.o
/path/to/LiME/src/lime.mod.c:8:1: error: variable '__this_module' has initializer but incomplete type
 __attribute__((section(".gnu.linkonce.this_module"))) = {
 ^
/path/to/LiME/src/lime.mod.c:9:2: error: unknown field 'name' specified in initializer
  .name = KBUILD_MODNAME,
  ^
/path/to/LiME/src/lime.mod.c:9:2: warning: excess elements in struct initializer
/path/to/LiME/src/lime.mod.c:9:2: warning: (near initialization for '__this_module')
/path/to/LiME/src/lime.mod.c:10:2: error: unknown field 'init' specified in initializer
  .init = init_module,
  ^
/path/to/LiME/src/lime.mod.c:10:2: warning: excess elements in struct initializer
/path/to/LiME/src/lime.mod.c:10:2: warning: (near initialization for '__this_module')
/path/to/LiME/src/lime.mod.c:14:2: error: unknown field 'arch' specified in initializer
  .arch = MODULE_ARCH_INIT,
  ^
/path/to/LiME/src/lime.mod.c:14:10: error: 'MODULE_ARCH_INIT' undeclared here (not in a function)
  .arch = MODULE_ARCH_INIT,
          ^
/path/to/LiME/src/lime.mod.c:14:2: warning: excess elements in struct initializer
  .arch = MODULE_ARCH_INIT,
  ^
/path/to/LiME/src/lime.mod.c:14:2: warning: (near initialization for '__this_module')
make[2]: *** [/path/to/goldfish/scripts/Makefile.modpost:111: /path/to/LiME/src/lime.mod.o] Error 1
make[1]: *** [Makefile:1228: modules] Error 2
make[1]: Leaving directory '/path/to/goldfish'
make: *** [Makefile:35: default] Error 2

如果我在已构建内核的System.map文件中搜索“未定义”符号,则可以找到所有这些符号。 关于如何解决此问题的任何提示?谢谢

1 个答案:

答案 0 :(得分:0)

我已经在我的.config文件中解决了金鱼内核的已发布设置CONFIG_MODULES=y。我还需要替换.config文件中的一行,否则KBuild系统将不会通知文件更改,并且CONFIG_MODULES=y将被覆盖并且不适用。