简体   繁体   English

解释proc /的不同行 <pid> / maps输出

[英]Interpret different lines of the proc/<pid>/maps output

On a Ubuntu 32-bit machine, I read out the memory map of a process which is a simple C program I wrote. 在Ubuntu 32位计算机上,我读出了进程的内存映射,该进程是我编写的简单C程序。 I notice there are three memory region allocated for /malloc/malloc_example which is the path to my binary. 我注意到为/ malloc / malloc_example分配了三个内存区域,这是我的二进制文件的路径。 A few questions: 几个问题:

1.What are the meanings of these three memory regions? 1.这三个存储区的含义是什么? (The second one looks like stack) (第二个看起来像堆栈)

2.Similarly, what are the meanings of the three memory regions for /lib/i386-linux-gnu/libc-2.15.so? 2.同样,/ lib / i386-linux-gnu / libc-2.15.so的三个内存区域的含义是什么?

3.What is the purpose of [vdso] region? 3. [vdso]区域的目的是什么?

4.What is the purpose of [stack] region? 4. [stack]区域的目的是什么? (I assume that is not the actual stack of the main function because program stack normally starts at 0x0804xxxx) (我认为这不是主要功能的实际堆栈,因为程序堆栈通常从0x0804xxxx开始)

$cat /proc/27429/maps 
08048000-08049000 r-xp 00000000 08:01 292930     /malloc/malloc_example
08049000-0804a000 r-xp 00000000 08:01 292930     /malloc/malloc_example
0804a000-0804b000 rwxp 00001000 08:01 292930     /malloc/malloc_example
b7e05000-b7e07000 rwxp 00000000 00:00 0 
b7e07000-b7faa000 r-xp 00000000 08:01 7311       /lib/i386-linux-gnu/libc-2.15.so
b7faa000-b7fac000 r-xp 001a3000 08:01 7311       /lib/i386-linux-gnu/libc-2.15.so
b7fac000-b7fad000 rwxp 001a5000 08:01 7311       /lib/i386-linux-gnu/libc-2.15.so
b7fad000-b7fb0000 rwxp 00000000 00:00 0 
b7fb0000-b7fc7000 r-xp 00000000 08:01 7416       /lib/i386-linux-gnu/libpthread-2.15.so
b7fc7000-b7fc8000 r-xp 00016000 08:01 7416       /lib/i386-linux-gnu/libpthread-2.15.so
b7fc8000-b7fc9000 rwxp 00017000 08:01 7416       /lib/i386-linux-gnu/libpthread-2.15.so
b7fc9000-b7fcb000 rwxp 00000000 00:00 0 
b7fd9000-b7fdd000 rwxp 00000000 00:00 0 
b7fdd000-b7fde000 r-xp 00000000 00:00 0          [vdso]
b7fde000-b7ffe000 r-xp 00000000 08:01 7612       /lib/i386-linux-gnu/ld-2.15.so
b7ffe000-b7fff000 r-xp 0001f000 08:01 7612       /lib/i386-linux-gnu/ld-2.15.so
b7fff000-b8000000 rwxp 00020000 08:01 7612       /lib/i386-linux-gnu/ld-2.15.so
bffdf000-c0000000 rwxp 00000000 00:00 0          [stack]

First,we should know the mean of every column.The first column means the start and end address in virtual memory.The second column means this sector's authority,r = read,w = write,x = executable,s = share,p = private.The third column means address offset in mapping file.The fourth column means mapping file's major device number and minor device number.The fifth column means number of inode.The last means name of mapping file. 首先,我们应该知道每一列的平均值。第一列是虚拟内存中的起始地址和结束地址。第二列是该扇区的权限,r =读,w =写,x =可执行,s = share,p = private,第三列表示映射文件中的地址偏移量,第四列表示映射文件的主设备号和次设备号,第五列表示索引节点的编号,最后一列表示映射文件的名称。


So,there are three memory region for some path is because those sector have different authority.Some sector is code sector,this sector have the r+w+x authority.Some is read-only data sector,other maybe read-write data sector.Next reason is the different offset in mapping file.You can see in this two line: 因此,某条路径存在三个存储区域是因为这些扇区具有不同的权限。某些扇区是代码扇区,该扇区具有r + w + x权限。某些是只读数据扇区,其他可能是读写数据扇区下一个原因是映射文件中的偏移量不同。您可以在这两行中看到:

b7fb0000-b7fc7000 r-xp 00000000 08:01 7416       /lib/i386-linux-gnu/libpthread-2.15.so
b7fc7000-b7fc8000 r-xp 00016000 08:01 7416       /lib/i386-linux-gnu/libpthread-2.15.so

the offset in different,it means the two sector is from the same file,but different location. 偏移量不同,表示两个扇区来自同一文件,但位置不同。


stack sector is this progress's stack,stack sector keep the local data. 堆栈扇区是此进程的堆栈,堆栈扇区保留本地数据。


vspd means Virtual Dynamic Shared Object,it is a .so file,it not store in disk but kernel.When program start running,kernel will map memory page(stroe .so file) to program's memory.You can use command ldd /bin/bash to get more information. vspd表示虚拟动态共享对象,它是一个.so文件,不存储在磁盘中,而是存储在内核中。当程序开始运行时,内核会将内存页面(stroe .so文件)映射到程序的内存中。可以使用命令ldd /bin/bash获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM