Process Memory Linux
Every Process has an address space with three segments: Text (code), Data, and Stack.
The Text segment ,sometimes also called code segment contains the machine instructions that form the programs executable code. This section is usually read only and is generated by the compiler.
The Data segment contains storage for program variables, strings, arrays and other data. This segment contains two parts, initialized and uninitialized data. The Uninitialized portion is known (historically at least) as BSS. The data segment can change, unlike the text(code) segment.
The Stack Segment starts at the top of the Virtual Address Space and grows down towards 0. If the stack grows beyond its bounds a hardware fault occurs and the operation system lowers the bottom of the stack by 1 page. When you start a program all its variables and command line arguments are stored on the stack segment. This last statement should connect in your memory and fill in the “why” from any tutorials you may have read, which did something like strcpy(buffer, argv[1]).
Process Memory Layout: (Borrowed w/o permission from tutorial by: xgc/dx A.K.A Thyago Silva http://milw0rm.com/papers/4) 0xc0000000
--------------------- | | | env/argv pointer. | | argc | |-------------------| | | | stack | | | | | | | | | | V | / / | | | ^ | | | | | | | | | | heap | |-------------------| | bss | |-------------------| | initialized data | |-------------------| | text | |-------------------| | shared libraries | | etc. | |-------------------|
0x8000000
Above when discussing the stack segment we briefly mentioned that the operating system will increase the stack by 1 page when it grows out of its boundaries. A page is a 4Kb area of memory and is the basic unit of memory with which both the kernel and the CPU deal. Although both can access individual bytes (or even bits), the amount of memory that is managed is usually in pages. For more information on Linux paging and the linux memory model in general see This link
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URI
