It consists of the following three parts:
1) BSS segment
BSS segments are generally used to storeUninitialized global variablesMemory area. BSS is short for Block Started by Symbol. BSS segment belongsStatic Memory Allocation. The uninitialized data segment is generated only during the initialization phase, so its size does not affect the size of the target file.
The bss segment contains uninitialized global variables and static variables.
2) data Segment
Data segments are usually used to storeInitialized global variablesMemory area. Data Segment belongsStatic Memory Allocation.
- The data segment consists of three parts: heap, stack, and static data zone.
- Heap)
- Stack)
- Static Data zone: storesInitialized global variables, static variables, and constants.
3) text section
A text segment is usually used to store programs.Execute CodeMemory area. The size of this area is determined before the program runs, and the memory area isRead-Only. The code segment may also contain some read-onlyConstant variableSuch as string constants.
Eg:
Int a = 0; // The Global initialization zone (data) char * p1; // The Global uninitialized zone (BSS) main () {static int c = 0; // global (static) initialization zone (data) int B; // stack (data) char s [] = "abc"; // stack (data) char * p2; // stack (data) char * p3 = "123456"; // "123456 \ 0" is in the constant zone, and p3 is in the stack. (All in data zone) p1 = (char *) malloc (10); p2 = (char *) malloc (20 ); // The allocated 10-byte and 20-byte areas are in the heap area. (Data )}
Reference: http://www.nowamagic.net/librarys/veda/detail/2384