据我了解Linux内核中的内存管理,有一个mm_struct结构负责每个进程中的地址空间。一个重要的内存区域是堆栈。这应该由 vm_area_struct 内存区域来标识,并且 mm_struct 本身有一个指针 mm_struct->stack_start ,它是堆栈的地址。
我遇到了下面的代码,我无法理解为什么任何内存区域起始/结束地址不等于 mm_struct->stack_start 值。任何有助于理解这一点的帮助将不胜感激。谢谢
加载编译内核模块的一些结果:
Vma 编号 14:从 0x7fff4bb68000 开始,在 0x7fff4bb8a000 结束 Vma 编号 15:从 0x7fff4bbfc000 开始,在 0x7fff4bbfe000 结束 Vma 编号 16:从 0x7fff4bbfe000 开始,在 0x7fff4bc00000 结束 代码段开始 = 0x400000,结束 = 0x400854 数据段开始 = 0x600858,结束 = 0x600a94 堆栈段开始 = 0x7fff4bb88420
可以发现堆栈段开始(0x7fff4bb88420)属于vma编号14,但我不知道地址不同。
内核模块源码:
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/mm.h>
static int pid_mem = 1;
static void print_mem(struct task_struct *task)
{
struct mm_struct *mm;
struct vm_area_struct *vma;
int count = 0;
mm = …Run Code Online (Sandbox Code Playgroud)