]>
Commit | Line | Data |
---|---|---|
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 | .\" |
4b8c67d9 | 26 | .TH END 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
37da8d97 MK |
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 | |
038fcbb1 | 43 | .I edata |
37da8d97 MK |
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 | |
008f1ecc | 51 | Although these symbols have long been provided on most UNIX systems, |
038fcbb1 | 52 | they are not standardized; use with caution. |
37da8d97 MK |
53 | .SH NOTES |
54 | The program must explicitly declare these symbols; | |
55 | they are not defined in any header file. | |
847e0d88 | 56 | .PP |
37da8d97 MK |
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. | |
847e0d88 | 64 | .PP |
37da8d97 MK |
65 | At the start of program execution, |
66 | the program break will be somewhere near | |
2914a14d | 67 | .IR &end |
37da8d97 MK |
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: | |
e646a1ba | 78 | .PP |
37da8d97 | 79 | .in +4n |
e646a1ba | 80 | .EX |
b43a3b30 | 81 | .RB "$" " ./a.out" |
37da8d97 MK |
82 | First 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 | ||
94 | extern char etext, edata, end; /* The symbols must have some type, | |
c3074d70 | 95 | or "gcc \-Wall" complains */ |
37da8d97 MK |
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 | } | |
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) |