【问题标题】:Compiling a loadable kernel module(Debian/Ubuntu)编译可加载内核模块(Debian/Ubuntu)
【发布时间】:2015-03-12 00:52:48
【问题描述】:

这个问题是this one 的后续问题。我正在尝试将 ELF 加载器编译为单独的 LKM 并将其用作独立应用程序(替换基本内核中的原始模块听起来太冒险了)。 到目前为止,我已经将source file 复制到一个单独的目录树中,并尝试使用以下 Makefile 进行编译:

obj-m += binfmt_elf_mod.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

模块已生成,但给出以下警告:

make -C /lib/modules/3.13.0-32-generic/build M=/path/to/source/Resources modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-32-generic'
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "start_thread" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "arch_randomize_brk" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "find_extend_vma" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "security_bprm_secureexec" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "vdso_enabled" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "arch_align_stack" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "arch_setup_additional_pages" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "randomize_va_space" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "set_personality_64bit" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "elf_core_write_extra_data" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "get_dump_page" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "elf_core_write_extra_phdrs" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "task_cputime" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "elf_core_extra_data_size" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "copy_siginfo_to_user" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "thread_group_cputime" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "elf_core_extra_phdrs" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "arch_vma_name" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
WARNING: "get_gate_vma" [/path/to/source/Resources/binfmt_elf_mod.ko] undefined!
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-32-generic'

目前我正在使用 /lib/modules/3.13.0-32-generic 中的默认构建脚本而不是下载的源代码进行构建。如何解决这些依赖关系?

【问题讨论】:

  • 你试过在 lkml 上提问吗?
  • 我浏览了列表,在那里举行的讨论集中在错误修复和补丁上,而不是真正的两个:google.com/…

标签: c linux ubuntu linux-kernel kernel-module


【解决方案1】:

实际上,你不能。 Linux 内核中的 ELF 加载器链接到许多内核模块不可用的符号。

但更糟糕的是,如果您将 ELF 加载程序构建为一个模块,您将无法启动您的系统!您正在构建的模块和加载它的可执行文件都是 ELF 可执行文件;如果内核中已经存在 ELF 支持,您将无法使用它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 2013-03-11
    • 2017-06-21
    • 1970-01-01
    • 2016-02-20
    相关资源
    最近更新 更多