data segment
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. 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 ( 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. Historically, to be able to support memory address spaces larger than the native size of the internal address register would allow, early CPUs implemented a system of segmentation whereby they would store a small set of indexes to use as offsets to certain areas. The Intel 8086 family of CPUs provided four segments: the code segment, the data segment, the stack segment and the extra segment. Each segment was placed at a specific location in memory by the software being executed, and all instructions that operated on the data within those segments were performed relative to the start of that segment.…
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. 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 ( 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. Historically, to be able to support memory address spaces larger than the native size of the internal address register would allow, early CPUs implemented a system of segmentation whereby they would store a small set of indexes to use as offsets to certain areas. The Intel 8086 family of CPUs provided four segments: the code segment, the data segment, the stack segment and the extra segment. Each segment was placed at a specific location in memory by the software being executed, and all instructions that operated on the data within those segments were performed relative to the start of that segment. This allowed a 16-bit address register, which would normally be able to access 64 KB of memory space, to access 1 MB of memory space. This segmenting of the memory space into discrete blocks with specific tasks carried over into the programming languages of the day, and the concept is still widely in use within modern programming languages. int i = 3; char a[] = "Hello World"; static int b = 2023; // Initialized static global variable void foo (void) { static int c = 2023; // Initialized static local variable } static int i; static char a[12]; ==Interpreted languages== Some interpreted languages offer a similar facility to the data segment, notably Perl and Ruby. In these languages, including the line __DATA__ (Perl) or __END__ (Ruby, old Perl) marks the end of the code segment and the start of the data segment. Only the contents prior to this line are executed, and the contents of the source file after this line are available as a file object: PACKAGE::DATA in Perl (e.g., main::DATA ) and DATA in Ruby. This can be considered a form of here document (a file literal). ==See also== Segmentation (memory) Segmentation fault Linker (computing) Code segment .bss Uninitialized variable Stack (abstract data type) Process control block
References
- data segment · retrieved 2026-11-23 · rev 1346093539
Cite this reference
MLA "data segment." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1346093539. Accessed 24 November 2026.
Chicago "data segment." 2026-11-23. https://en.wikipedia.org/w/index.php?oldid=1346093539.
APA encyclopegia.org. (2026). data segment. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1346093539
Cite this article
MLA
"data segment." encyclopegia.org, 2026, https://encyclopegia.org/wiki/data-segment. Accessed 24 November 2026.
Chicago
"data segment." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/data-segment.
APA
encyclopegia.org. (2026). data segment. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/data-segment
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON
Claims
| Predicate | Value | Source |
|---|---|---|
| year mentioned | 2023 | article body |