创建内核模块时如何消除“vmlinux 不可用”错误

问题描述 投票:0回答:1

学校给我分配了一个任务,要求我创建一个内核模块,该模块可以使用我的 PID 访问 task_struct。我收到一个错误(我不认为这是一个错误,但我不知道还能叫它什么),上面写着,

Skipping BTF generation for /home/dpb/Documents/CSE_420/p4/try2/mymodule2.ko due to unavailability of vmlinux
,通过在线搜索,我什至无法弄清楚在这种情况下 vmlinux 是什么。

这是我的代码...

```
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>

#include <linux/pid_namespace.h>

int p_id;
struct pid *pid_struct;
struct task_struct *task;


/* Meta Information */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Devin 4 GNU/Linux");
MODULE_DESCRIPTION("A hello world LKM");

/* This funciton is called when the module is loaded into the kernel */
static int __init ModuleInit(void) {
    pid_struct = find_get_pid(p_id);
    task = pid_task(pid_struct,PIDTYPE_PID);    
    
    printk("PID: \n");
    printk("Name: %s\n", task->comm);
    printk("Total Pages in KB: \n");
    printk("File System Name: \n");
    return 0;
}

/* This funciton is called whe the module is removed fromt he kernel */
static void __exit ModuleExit(void) {
    printk("Bye!\n");
}

module_init(ModuleInit);
module_exit(ModuleExit);

```#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>

#include <linux/pid_namespace.h>

int p_id;
struct pid *pid_struct;
struct task_struct *task;


/* Meta Information */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Devin 4 GNU/Linux");
MODULE_DESCRIPTION("A hello world LKM");

/* This funciton is called when the module is loaded into the kernel */
static int __init ModuleInit(void) {
    pid_struct = find_get_pid(p_id);
    task = pid_task(pid_struct,PIDTYPE_PID);    
    
    printk("PID: \n");
    printk("Name: %s\n", task->comm);
    printk("Total Pages in KB: \n");
    printk("File System Name: \n");
    return 0;
}

/* This funciton is called whe the module is removed fromt he kernel */
static void __exit ModuleExit(void) {
    printk("Bye!\n");
}

module_init(ModuleInit);
module_exit(ModuleExit);
```

当我运行我的 make 文件时收到错误...

```
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m += mymodule2.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
```

与我交谈过的班上的每个人都没有遇到过这个问题,有人可以解释一下 vmlinux 不可用意味着什么吗?这样我就可以尝试找出为什么我的模块在使用命令行运行时无法完成执行

sudo insmod mymodule2.ko

c linux module linux-kernel
1个回答
0
投票

空变量值

$ make ... CONFIG_DEBUG_INFO_BTF_MODULES=模块

© www.soinside.com 2019 - 2024. All rights reserved.