In computing, a data segment (often denoted .data) is a portion of an object file or the corresponding address space of a program that contains initialized static variables, that is, global variables and static local variables. The size of this segment is determined by the size of the values in the program’s source code, and does not change at run time.
在计算中,数据段(通常表示为.data)是目标文件或程序对应地址空间的一部分,其中包含初始化的静态变量,即全局变量和静态局部变量。这个段的大小由程序源代码中的值的大小决定,在运行时不会改变。
The data segment is read/write, since the values of variables can be altered at run time. This is in contrast to the read-only data segment (rodata segment or .rodata), which contains static constants rather than variables; it also contrasts to the code segment, also known as the text segment, which is read-only on many architectures. Uninitialized data, both variables and constants, is instead in the BSS segment.
数据段是读/写的,因为变量的值可以在运行时更改。这与只读数据段(rodata段或.rodata)相反,后者包含静态常数而不是变量;就像代码段(也称为文本段),代码段在许多体系结构上是只读的。未初始化的数据(包括变量和常量)则位于BSS段中。
- data segment( .data) : read/write, the values of variables can be altered at run time.
- rodata segment( .rodata):read-only data segment,static constants
- BSS segment:uninitialized data, both variables and constants