Тестовая программа
#include <unistd.h>
#include <malloc.h>
#include <stdio.h>
#include <sys/mman.h>
int bss, data=10;
int main(int argc, char *argv[])
{
int stack;
void *heap, *brk, *mmp;
heap=malloc(1);
brk=sbrk(0);
mmp=mmap(0,1,PROT_READ,MAP_SHARED|MAP_ANONYMOUS,-1,0);
printf("Text=%p\nData=%p\nBSS=%p\nHeap=%p\nBrk=%p\nlibc.so=%p\nMmap=%p\nStack=%p\nArgv=%p\n ",main,&data,&bss,heap,brk,printf,mmp,&stack,argv);
sleep(100);
return 0;
}
Вывод тестовой программы
$ ./testmap
Text =0x0045c690
Data =0x0045e02c
BSS =0x0045e034
Heap =0x01435008
Brk =0x01456000
libc.so=0xb75bb940
Mmap =0xb773a000
Stack =0xbfe8f850
Argv =0xbfe8f924
Распределение памяти тестовой программы
$ ./testmap >/dev/null &
[1] 6662
$ cat /proc/6662/maps
0042a000-0042b000 r-xp 00000000 08:01 305009 /home/student/testmap
0042b000-0042c000 r--p 00000000 08:01 305009 /home/student/testmap
0042c000-0042d000 rw-p 00001000 08:01 305009 /home/student/testmap
00ece000-00eef000 rw-p 00000000 00:00 0 [heap]
b7603000-b77b4000 r-xp 00000000 08:01 151995 /lib/i386-linux-gnu/libc-2.24.so
b77b4000-b77b5000 ---p 001b1000 08:01 151995 /lib/i386-linux-gnu/libc-2.24.so
b77b5000-b77b7000 r--p 001b1000 08:01 151995 /lib/i386-linux-gnu/libc-2.24.so
b77b7000-b77b8000 rw-p 001b3000 08:01 151995 /lib/i386-linux-gnu/libc-2.24.so
b77b8000-b77bb000 rw-p 00000000 00:00 0
b77cb000-b77cc000 r--s 00000000 00:05 100324 /dev/zero (deleted)
b77cc000-b77ce000 rw-p 00000000 00:00 0
b77ce000-b77d0000 r--p 00000000 00:00 0 [vvar]
b77d0000-b77d2000 r-xp 00000000 00:00 0 [vdso]
b77d2000-b77f5000 r-xp 00000000 08:01 138298 /lib/i386-linux-gnu/ld-2.24.so
b77f5000-b77f6000 r--p 00022000 08:01 138298 /lib/i386-linux-gnu/ld-2.24.so
b77f6000-b77f7000 rw-p 00023000 08:01 138298 /lib/i386-linux-gnu/ld-2.24.so
bff5d000-bff7e000 rw-p 00000000 00:00 0 [stack]
$ uname -a
Linux antix-1 4.9.87-antix.1-486-smp #1 SMP Tue Mar 13 12:29:54 EDT 2018 i686 GNU/Linux