1end(3)                     Library Functions Manual                     end(3)
2
3
4

NAME

6       etext, edata, end - end of program segments
7

SYNOPSIS

9       extern etext;
10       extern edata;
11       extern end;
12

DESCRIPTION

14       The addresses of these symbols indicate the end of various program seg‐
15       ments:
16
17       etext  This is the first address past the end of the text segment  (the
18              program code).
19
20       edata  This  is  the first address past the end of the initialized data
21              segment.
22
23       end    This is the first address past the end of the uninitialized data
24              segment (also known as the BSS segment).
25

STANDARDS

27       None.
28

HISTORY

30       Although  these  symbols  have long been provided on most UNIX systems,
31       they are not standardized; use with caution.
32

NOTES

34       The program must explicitly declare these symbols; they are not defined
35       in any header file.
36
37       On some systems the names of these symbols are preceded by underscores,
38       thus: _etext, _edata, and _end.  These symbols  are  also  defined  for
39       programs compiled on Linux.
40
41       At  the start of program execution, the program break will be somewhere
42       near &end (perhaps at the start of the following page).   However,  the
43       break  will change as memory is allocated via brk(2) or malloc(3).  Use
44       sbrk(2) with an argument of zero to find the current value of the  pro‐
45       gram break.
46

EXAMPLES

48       When run, the program below produces output such as the following:
49
50           $ ./a.out
51           First address past:
52               program text (etext)       0x8048568
53               initialized data (edata)   0x804a01c
54               uninitialized data (end)   0x804a024
55
56   Program source
57
58       #include <stdio.h>
59       #include <stdlib.h>
60
61       extern char etext, edata, end; /* The symbols must have some type,
62                                          or "gcc -Wall" complains */
63
64       int
65       main(void)
66       {
67           printf("First address past:\n");
68           printf("    program text (etext)      %10p\n", &etext);
69           printf("    initialized data (edata)  %10p\n", &edata);
70           printf("    uninitialized data (end)  %10p\n", &end);
71
72           exit(EXIT_SUCCESS);
73       }
74

SEE ALSO

76       objdump(1), readelf(1), sbrk(2), elf(5)
77
78
79
80Linux man-pages 6.05              2023-05-03                            end(3)
Impressum