Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process Memory Map (Linux Windows)

Tags:

c++

c

linux

windows

Can someone please point me to some documentation on the virtual memory maps used for Linux and Windows. By that I mean what virtual addresses, code, writable static data, the stack and the heap (along with other kernel bits) will normally be placed in, in a typical process?

like image 642
doron Avatar asked Aug 26 '10 21:08

doron


3 Answers

Since the advent of ASLR, it's mostly on random virtual addresses.

like image 72
ninjalj Avatar answered Oct 23 '22 12:10

ninjalj


Probably the best way to get the process memory map on Linux is to look at the /proc//maps file. One can clearly see that for each executable or shared object there are separate sections for executable, const static data, and writable static data. Each one of these sections exists in its own memory page which allows Linux to share sections between executables and even implement features like copy-on-write.

In addition to this there is a section dedicated to the stack and one dedicated to the heap. There also may be some anonymous sections as well.

like image 40
doron Avatar answered Oct 23 '22 12:10

doron


The Wikipedia entry on Address Space Layout Randomisation (ALSR) describes how random allocation of address space protects against various attacks, and how the importance differs between data and code.

It describes both the Linux's default weak level of randomisation, and a patch you can use to strengthen it.

It also describes which versions of Windows offer it, and how it only applies to some code & executables.

like image 1
Oddthinking Avatar answered Oct 23 '22 12:10

Oddthinking