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