Linux the segment management,
BSS A segment (BSS segment) usually refers to an area of memory that is used to hold uninitialized global variables in the program. BSS is the abbreviation for English block Started by symbol. BSS segments belong to static memory allocations.
This segment is used to store uninitialized global variables or global variables that are initialized to 0 by default.
Data Segment This section is used to store the initialized global variables, and the global variables initialized to 0 are either stored in the BSS section or the data segment is static memory allocation for the purpose of compiling the optimized strategy.
text segment : The text segment is used to store program code, compile-time determination, memory area is usually read-only,
Rodata segment : This section is also called a constant area, for storing constant data, storing the string in C and the constant defined by # define, RO is the meaning of Read only. Note, however, that not all constants are placed in constant data segments, with the following special cases: 1) Some immediate numbers are compiled with instructions directly in the code snippet.
Heap Heap : Heap is used to store the program running in the dynamic allocation of memory segments, his size is not fixed, can be dynamically expanded or reduced, when the process calls the malloc function to allocate memory, the newly allocated memory is dynamically added to the heap, when using the free function to release memory, The freed memory is removed from the heap.
Stack Stack : is a local variable that is temporarily created by the user store program, that is, the variable defined in the parentheses "{}" (but not the static declared variable, static means that the variable is stored in the data segment). In addition, when a function is called, its arguments are also pressed into the process stack that initiates the call, and the return value of the function is stored back to the stack when the call ends. Due to the advanced first-out features of the stack, the stack is particularly handy for saving/recovering call sites. In this sense, we can think of stacks as a memory area where temporary data is stored and exchanged
constant Segments: constant segments typically contain data generated by the compiler (unlike read-only segments that contain user-defined read-only data). For example, by a statement a=2+3 compiler to 2+3 compile period even if 5, stored as constant 5 in the constant segment
In general, a program is essentially a BSS section, data section, text paragraph three composed of
Both the text and data fields are in the executable file (typically cured in an embedded system in an image file) and are loaded from the executable file by the system. The BSS segment is not in the executable file and is initialized by the system.
BSS does not occupy the. exe file space, its contents are initialized by the operating system (0), while. Data needs to be occupied, its contents are initialized by the program,
Author CUMTCHW
Segment management in Linux, BSS segment, data segment,