Debian Codegraph @

upstream/debian-unstable/man3/end.3

raw
1 .\" Copyright, the authors of the Linux man-pages project
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH end 3 2025-09-21 "Linux man-pages 6.18"
6 .SH NAME
7 etext, edata, end \- end of program segments
8 .SH SYNOPSIS
9 .nf
10 .BI extern " etext" ;
11 .BI extern " edata" ;
12 .BI extern " end" ;
13 .fi
14 .SH DESCRIPTION
15 The addresses of these symbols indicate the end of various program
16 segments:
17 .TP
18 .I etext
19 This is the first address past the end of the text segment
20 (the program code).
21 .TP
22 .I edata
23 This is the first address past the end of the
24 initialized data segment.
25 .TP
26 .I end
27 This is the first address past the end of the
28 uninitialized data segment (also known as the BSS segment).
29 .SH STANDARDS
30 None.
31 .SH HISTORY
32 Although these symbols have long been provided on most UNIX systems,
33 they are not standardized;
34 use with caution.
35 .SH NOTES
36 The program must explicitly declare these symbols;
37 they are not defined in any header file.
38 .P
39 On some systems the names of these symbols are preceded by underscores,
40 thus:
41 .IR _etext ,
42 .IR _edata ,
43 and
44 .IR _end .
45 These symbols are also defined for programs compiled on Linux.
46 .P
47 At the start of program execution,
48 the program break will be somewhere near
49 .I &end
50 (perhaps at the start of the following page).
51 However, the break will change as memory is allocated via
52 .BR brk (2)
53 or
54 .BR malloc (3).
55 Use
56 .BR sbrk (2)
57 with an argument of zero to find the current value of the program break.
58 .SH EXAMPLES
59 When run, the program below produces output such as the following:
60 .P
61 .in +4n
62 .EX
63 .RB "$" " ./a.out"
64 First address past:
65 program text (etext) 0x8048568
66 initialized data (edata) 0x804a01c
67 uninitialized data (end) 0x804a024
68 .EE
69 .in
70 .SS Program source
71 \&
72 .\" SRC BEGIN (end.c)
73 .EX
74 #include <stdio.h>
75 #include <stdlib.h>
76 \&
77 extern char etext, edata, end; /* The symbols must have some type,
78 or "gcc \-Wall" complains */
79 \&
80 int
81 main(void)
82 {
83 printf("First address past:\[rs]n");
84 printf(" program text (etext) %10p\[rs]n", &etext);
85 printf(" initialized data (edata) %10p\[rs]n", &edata);
86 printf(" uninitialized data (end) %10p\[rs]n", &end);
87 \&
88 exit(EXIT_SUCCESS);
89 }
90 .EE
91 .\" SRC END
92 .SH SEE ALSO
93 .BR objdump (1),
94 .BR readelf (1),
95 .BR sbrk (2),
96 .BR elf (5)