]>
Commit | Line | Data |
---|---|---|
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 | .\" |
4c1c5274 | 6 | .TH end 3 (date) "Linux man-pages (unreleased)" |
37da8d97 MK |
7 | .SH NAME |
8 | etext, 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 | |
16 | The addresses of these symbols indicate the end of various program | |
17 | segments: | |
18 | .TP | |
19 | .I etext | |
20 | This is the first address past the end of the text segment | |
21 | (the program code). | |
22 | .TP | |
038fcbb1 | 23 | .I edata |
37da8d97 MK |
24 | This is the first address past the end of the |
25 | initialized data segment. | |
26 | .TP | |
27 | .I end | |
28 | This is the first address past the end of the | |
29 | uninitialized data segment (also known as the BSS segment). | |
3113c7f3 | 30 | .SH STANDARDS |
4131356c AC |
31 | None. |
32 | .SH HISTORY | |
008f1ecc | 33 | Although these symbols have long been provided on most UNIX systems, |
038fcbb1 | 34 | they are not standardized; use with caution. |
37da8d97 MK |
35 | .SH NOTES |
36 | The program must explicitly declare these symbols; | |
37 | they are not defined in any header file. | |
c6d039a3 | 38 | .P |
37da8d97 MK |
39 | On some systems the names of these symbols are preceded by underscores, |
40 | thus: | |
41 | .IR _etext , | |
42 | .IR _edata , | |
43 | and | |
44 | .IR _end . | |
45 | These symbols are also defined for programs compiled on Linux. | |
c6d039a3 | 46 | .P |
37da8d97 MK |
47 | At the start of program execution, |
48 | the program break will be somewhere near | |
1ae6b2c7 | 49 | .I &end |
37da8d97 MK |
50 | (perhaps at the start of the following page). |
51 | However, the break will change as memory is allocated via | |
52 | .BR brk (2) | |
53 | or | |
54 | .BR malloc (3). | |
55 | Use | |
56 | .BR sbrk (2) | |
57 | with an argument of zero to find the current value of the program break. | |
a14af333 | 58 | .SH EXAMPLES |
37da8d97 | 59 | When run, the program below produces output such as the following: |
c6d039a3 | 60 | .P |
37da8d97 | 61 | .in +4n |
e646a1ba | 62 | .EX |
b43a3b30 | 63 | .RB "$" " ./a.out" |
37da8d97 MK |
64 | First address past: |
65 | program text (etext) 0x8048568 | |
66 | initialized data (edata) 0x804a01c | |
67 | uninitialized data (end) 0x804a024 | |
b8302363 | 68 | .EE |
37da8d97 | 69 | .in |
9c330504 | 70 | .SS Program source |
d84d0300 | 71 | \& |
b0b6ab4e | 72 | .\" SRC BEGIN (end.c) |
e7d0bb47 | 73 | .EX |
37da8d97 MK |
74 | #include <stdio.h> |
75 | #include <stdlib.h> | |
fe5dba13 | 76 | \& |
37da8d97 | 77 | extern char etext, edata, end; /* The symbols must have some type, |
c3074d70 | 78 | or "gcc \-Wall" complains */ |
fe5dba13 | 79 | \& |
37da8d97 | 80 | int |
7ffb8e37 | 81 | main(void) |
37da8d97 | 82 | { |
d1a71985 MK |
83 | printf("First address past:\en"); |
84 | printf(" program text (etext) %10p\en", &etext); | |
85 | printf(" initialized data (edata) %10p\en", &edata); | |
86 | printf(" uninitialized data (end) %10p\en", &end); | |
fe5dba13 | 87 | \& |
37da8d97 MK |
88 | exit(EXIT_SUCCESS); |
89 | } | |
e7d0bb47 | 90 | .EE |
b0b6ab4e | 91 | .\" SRC END |
47297adb | 92 | .SH SEE ALSO |
37da8d97 MK |
93 | .BR objdump (1), |
94 | .BR readelf (1), | |
038fcbb1 MK |
95 | .BR sbrk (2), |
96 | .BR elf (5) |