What part of the process virtual memory scheme does mmap () use?

The mmap () function must establish a mapping between the virtual address space of the process and the device file or physical memory area.

A process virtual memory format has the following sections:

enter image description here

In what area of ​​the virtual address space of the process is mmap () used to display?

+4
source share
2 answers

Mmap uses "unallocated memory".

Please note that the image you painted is unlikely to be used on any UNIX system that is under 30 years old. Used UNIX had this memory layout in the early 70s, but these days the image is much more complex, especially when using shared libraries.

+5
source

To get an idea of ​​what's happening today, try (on Linux) the following command

cat /proc/self/maps 

on my car, he now gives

 00400000-0040c000 r-xp 00000000 08:01 1850896 /bin/cat 0060c000-0060d000 rw-p 0000c000 08:01 1850896 /bin/cat 00adc000-00afd000 rw-p 00000000 00:00 0 [heap] 7ffe843ef000-7ffe84569000 r-xp 00000000 08:01 787567 /lib/x86_64-linux-gnu/libc-2.13.so 7ffe84569000-7ffe84769000 ---p 0017a000 08:01 787567 /lib/x86_64-linux-gnu/libc-2.13.so 7ffe84769000-7ffe8476d000 r--p 0017a000 08:01 787567 /lib/x86_64-linux-gnu/libc-2.13.so 7ffe8476d000-7ffe8476e000 rw-p 0017e000 08:01 787567 /lib/x86_64-linux-gnu/libc-2.13.so 7ffe8476e000-7ffe84773000 rw-p 00000000 00:00 0 7ffe84773000-7ffe84792000 r-xp 00000000 08:01 790578 /lib/x86_64-linux-gnu/ld-2.13.so 7ffe8495e000-7ffe84961000 rw-p 00000000 00:00 0 7ffe84990000-7ffe84992000 rw-p 00000000 00:00 0 7ffe84992000-7ffe84993000 r--p 0001f000 08:01 790578 /lib/x86_64-linux-gnu/ld-2.13.so 7ffe84993000-7ffe84994000 rw-p 00020000 08:01 790578 /lib/x86_64-linux-gnu/ld-2.13.so 7ffe84994000-7ffe84995000 rw-p 00000000 00:00 0 7fffdbaac000-7fffdbacd000 rw-p 00000000 00:00 0 [stack] 7fffdbb66000-7fffdbb67000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] 

It displays the memory card of the process executing the cat .

+4
source

Source: https://habr.com/ru/post/1383419/


All Articles