]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/end.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / end.3
CommitLineData
66d90115 1.\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
37da8d97
MK
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
37da8d97
MK
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.
4b72fb64 24.\" %%%LICENSE_END
37da8d97 25.\"
9ba01802 26.TH END 3 2019-03-06 "GNU" "Linux Programmer's Manual"
37da8d97
MK
27.SH NAME
28etext, 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
36The addresses of these symbols indicate the end of various program
37segments:
38.TP
39.I etext
40This is the first address past the end of the text segment
41(the program code).
42.TP
038fcbb1 43.I edata
37da8d97
MK
44This is the first address past the end of the
45initialized data segment.
46.TP
47.I end
48This is the first address past the end of the
49uninitialized data segment (also known as the BSS segment).
50.SH CONFORMING TO
008f1ecc 51Although these symbols have long been provided on most UNIX systems,
038fcbb1 52they are not standardized; use with caution.
37da8d97
MK
53.SH NOTES
54The program must explicitly declare these symbols;
55they are not defined in any header file.
847e0d88 56.PP
37da8d97
MK
57On some systems the names of these symbols are preceded by underscores,
58thus:
59.IR _etext ,
60.IR _edata ,
61and
62.IR _end .
63These symbols are also defined for programs compiled on Linux.
847e0d88 64.PP
37da8d97
MK
65At the start of program execution,
66the program break will be somewhere near
2914a14d 67.IR &end
37da8d97
MK
68(perhaps at the start of the following page).
69However, the break will change as memory is allocated via
70.BR brk (2)
71or
72.BR malloc (3).
73Use
74.BR sbrk (2)
75with an argument of zero to find the current value of the program break.
a14af333 76.SH EXAMPLES
37da8d97 77When run, the program below produces output such as the following:
e646a1ba 78.PP
37da8d97 79.in +4n
e646a1ba 80.EX
b43a3b30 81.RB "$" " ./a.out"
37da8d97
MK
82First address past:
83 program text (etext) 0x8048568
84 initialized data (edata) 0x804a01c
85 uninitialized data (end) 0x804a024
b8302363 86.EE
37da8d97 87.in
9c330504 88.SS Program source
d84d0300 89\&
e7d0bb47 90.EX
37da8d97
MK
91#include <stdio.h>
92#include <stdlib.h>
93
94extern char etext, edata, end; /* The symbols must have some type,
c3074d70 95 or "gcc \-Wall" complains */
37da8d97
MK
96
97int
98main(int argc, char *argv[])
99{
d1a71985
MK
100 printf("First address past:\en");
101 printf(" program text (etext) %10p\en", &etext);
102 printf(" initialized data (edata) %10p\en", &edata);
103 printf(" uninitialized data (end) %10p\en", &end);
37da8d97
MK
104
105 exit(EXIT_SUCCESS);
106}
e7d0bb47 107.EE
47297adb 108.SH SEE ALSO
37da8d97
MK
109.BR objdump (1),
110.BR readelf (1),
038fcbb1
MK
111.BR sbrk (2),
112.BR elf (5)