首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LiME内核模块交叉编译失败

LiME内核模块交叉编译失败
EN

Stack Overflow用户
提问于 2019-07-12 16:21:05
回答 1查看 592关注 0票数 0

我正在尝试交叉编译用于android-goldfish-3.10-n-dev (提交: 3a3b199582a68ba0688a099147738d6c99f3282d ) LiME内核版本的Linux内核模块,生成文件如下:

代码语言:javascript
复制
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

但是我得到了以下错误/警告,编译失败。

代码语言:javascript
复制
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文件中搜索“未定义的”符号,我可以找到所有这些符号。有什么关于如何解决这个问题的提示吗?谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-07-12 17:14:11

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57002979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档