OSDN Git Service

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