]>
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 | .\" |
bffbb22f | 6 | .TH END 3 2020-06-09 "GNU" "Linux Programmer's Manual" |
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). | |
30 | .SH CONFORMING TO | |
008f1ecc | 31 | Although these symbols have long been provided on most UNIX systems, |
038fcbb1 | 32 | they are not standardized; use with caution. |
37da8d97 MK |
33 | .SH NOTES |
34 | The program must explicitly declare these symbols; | |
35 | they are not defined in any header file. | |
847e0d88 | 36 | .PP |
37da8d97 MK |
37 | On some systems the names of these symbols are preceded by underscores, |
38 | thus: | |
39 | .IR _etext , | |
40 | .IR _edata , | |
41 | and | |
42 | .IR _end . | |
43 | These symbols are also defined for programs compiled on Linux. | |
847e0d88 | 44 | .PP |
37da8d97 MK |
45 | At the start of program execution, |
46 | the program break will be somewhere near | |
1ae6b2c7 | 47 | .I &end |
37da8d97 MK |
48 | (perhaps at the start of the following page). |
49 | However, the break will change as memory is allocated via | |
50 | .BR brk (2) | |
51 | or | |
52 | .BR malloc (3). | |
53 | Use | |
54 | .BR sbrk (2) | |
55 | with an argument of zero to find the current value of the program break. | |
a14af333 | 56 | .SH EXAMPLES |
37da8d97 | 57 | When 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 |
62 | First 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 | ||
74 | extern char etext, edata, end; /* The symbols must have some type, | |
c3074d70 | 75 | or "gcc \-Wall" complains */ |
37da8d97 MK |
76 | |
77 | int | |
78 | main(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) |