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