The memory layout of the process is structurally regular, specifically for the process on the Linux system, its memory space can generally be roughly divided into the following large sections of "1", from high memory to low memory arrangement:
1, the kernel State memory space, its size is generally fixed (can be adjusted at compile time), but the value of 32-bit system and 64-bit system is different.
2, the user state stack, the size is not fixed, can be adjusted with Ulimit-s, the default is generally 8M, from high address to low address growth.
3, mmap area, process vast memory space in the main part, can be from high address to low address extension (so-called flexible layout), but also from low to high extension (so-called legacy layout), see the process of the specific situation "2" "3".
4, BRK area, close to the data segment (even affixed), from low to high, but its size depends mainly on how the mmap growth, generally speaking, even if the 32-bit process extends in the traditional way, there are almost 1 GB of space (accurately TASK_SIZE/3-code segment Data segment, see AR Definition of Ch/x86/include/asm/processor.h) "4"
5, the data section, mainly in the process initialization and uninitialized global data sum, of course, compiler generated some auxiliary data structure, and so on, the size depends on the specific process, its position is close to the code snippet.
6, the code snippet, mainly is the process instruction, including the user code and the compiler generates the auxiliary code, its size depends on the specific program, but the starting position is fixed according to 32 bit or 64 bit general fixation (-fpic,-fpie, etc. except "5").
The above paragraphs (in addition to the code snippet data segment) Its starting position according to whether the system is randomize_va_space generally slightly change, between each paragraph so there may be random size interval, thousands of words than a picture (x86-32 bit):
Example of a 32-bit under bash process:
"1" Https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat _enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-growing_the_oracle_sga_ To_2.7_gb_in_x86_red_hat_enterprise_linux_2.1_without_vlm-linux_memory_layout.html
"2" Understanding the Linux kernel, page 819, flexible memory region layout:https://books.google.com.hk/books?id= h0lltxyj8aic&pg=pt925&lpg=pt925&dq=linux+flexible+memory&source=bl&ots=go7riyb8hr&sig= Pirb5pswdhfhsljy57eksxs3abw&hl=en&sa=x&ved=0ahukewjpkfa-2_rrahvgfjqkhcetdsuq6aeitdah#v=onepage &q=linux%20flexible%20memory&f=false
"3" https://gist.github.com/CMCDragonkai/10ab53654b2aa6ce55c11cfc5b2432a4
"4" http://lxr.free-electrons.com/source/arch/x86/include/asm/processor.h#L770
"5" https://access.redhat.com/blogs/766093/posts/1975793
Memory space layout of the process