A, c program storage space layout
The C program has been composed of the following parts:
1 The body section--cpu the execution machine instruction part; A program has only one copy; read-only to prevent the program from modifying its own instructions as a result of an accident;
2 Initialize the data segment (data segment)--All global variables with initial values in the program are stored here.
3 non-initialized data segment (BSS segment)--The global variable not initialized in the program; the kernel initializes this segment to 0.
4 Stack-growth direction: From top to bottom growth; automatic variables and the information that needs to be saved each time a function is called (return address; Environment information).
5) heap-dynamic storage points.
|-----------|
| |
|-----------|
| 栈 |
|-----------|
| | |
| |/ |
| |
| |
| /| |
| | |
|-----------|
| 堆 |
|-----------|
| 未初始化 |
|-----------|
| 初始化 |
|-----------|
| 正文段 |
|-----------|