OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / man3 / end.3
1 .\" Copyright (c) 2008, Linux Foundation, written by by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" License.
24 .\"
25 .TH END 3 2008-07-17 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 etext, edata, end \- end of program segments
28 .SH SYNOPSIS
29 .nf
30 .BI extern " etext" ;
31 .BI extern " edata" ;
32 .BI extern " end" ;
33 .fi
34 .SH DESCRIPTION
35 The addresses of these symbols indicate the end of various program
36 segments:
37 .TP
38 .I etext
39 This is the first address past the end of the text segment
40 (the program code).
41 .TP
42 .I edata
43 This is the first address past the end of the
44 initialized data segment.
45 .TP
46 .I end
47 This is the first address past the end of the
48 uninitialized data segment (also known as the BSS segment).
49 .SH CONFORMING TO
50 Although these symbols have long been provided on most UNIX systems,
51 they are not standardized; use with caution.
52 .SH NOTES
53 The program must explicitly declare these symbols;
54 they are not defined in any header file.
55
56 On some systems the names of these symbols are preceded by underscores,
57 thus:
58 .IR _etext ,
59 .IR _edata ,
60 and
61 .IR _end .
62 These symbols are also defined for programs compiled on Linux.
63
64 At the start of program execution,
65 the program break will be somewhere near
66 .IR &end
67 (perhaps at the start of the following page).
68 However, the break will change as memory is allocated via
69 .BR brk (2)
70 or
71 .BR malloc (3).
72 Use
73 .BR sbrk (2)
74 with an argument of zero to find the current value of the program break.
75 .SH EXAMPLE
76 When run, the program below produces output such as the following:
77 .in +4n
78 .nf
79
80 .RB "$" " ./a.out"
81 First address past:
82     program text (etext)       0x8048568
83     initialized data (edata)   0x804a01c
84     uninitialized data (end)   0x804a024
85 .fi
86 .in
87 .SS Program source
88 \&
89 .nf
90 #include <stdio.h>
91 #include <stdlib.h>
92
93 extern char etext, edata, end; /* The symbols must have some type,
94                                    or "gcc \-Wall" complains */
95
96 int
97 main(int argc, char *argv[])
98 {
99     printf("First address past:\\n");
100     printf("    program text (etext)      %10p\\n", &etext);
101     printf("    initialized data (edata)  %10p\\n", &edata);
102     printf("    uninitialized data (end)  %10p\\n", &end);
103
104     exit(EXIT_SUCCESS);
105 }
106 .fi
107 .SH "SEE ALSO"
108 .BR objdump (1),
109 .BR readelf (1),
110 .BR sbrk (2),
111 .BR elf (5)