end(3)
β¨ end(3) β bestie edition β¨
okay so you know how your program is like, a bunch of segments all stacked up? π«Ά This page is about the lil boundary markers that tell you where each one stops. Their names are etext, edata, and end, and they live in the end(3) section of the library functions manual. no cap, that's literally the whole vibe.
πΈ NAME πΈ
etext, edata, end β the end of program segments π
π SYNOPSIS π
extern etext;
extern edata;
extern end;
π DESCRIPTION π
So the addresses of these three symbols point at the end of various program segments. That's it, that's the whole thing. Here's the breakdown, one by one:
etextβ this is the first address past the end of the text segment (aka the program code, your actual instructions π).edataβ this is the first address past the end of the initialized data segment.endβ this is the first address past the end of the uninitialized data segment, which also goes by the slay name of the BSS segment.
β¨ STANDARDS β¨
None. π Not a single one. It's giving lawless.
π¦ HISTORY π¦
Okay so tea: even though these symbols have been provided on most UNIX systems for a long time (like, ancient blessed ancestry), they are not standardized. So use with caution, bestie. β οΈ
π NOTES π
A few things you absolutely need to know before you go messing with these:
- You must explicitly declare these symbols yourself in your program. They are not defined in any header file. So no
#includeis gonna save you here, you have to write the declaration. periodt. - On some systems, the names of these symbols are preceded by underscores, like this:
_etext,_edata, and_end. And fun fact, these underscore versions are also defined for programs compiled on Linux. π - At the start of program execution, the program break will be somewhere near
&endβ maybe right at the start of the following page, maybe not, it's a little mysterious π. However, that break is gonna move around as memory gets allocated viabrk(2)ormalloc(3). So if you want to know the current value of the program break, usesbrk(2)with an argument of zero. boom, there it is.
π EXAMPLES π
When you run the program below, it produces output like this:
$ ./a.out
First address past:
program text (etext) 0x8048568
initialized data (edata) 0x804a01c
uninitialized data (end) 0x804a024
π§ Program source
#include <stdio.h>
#include <stdlib.h>
extern char etext, edata, end; /* The symbols must have some type,
or "gcc -Wall" complains */
int
main(void)
{
printf("First address past:\n");
printf(" program text (etext) %10p\n", &etext);
printf(" initialized data (edata) %10p\n", &edata);
printf(" uninitialized data (end) %10p\n", &end);
exit(EXIT_SUCCESS);
}
bestie note: that comment in the source is real. the symbols must have some type, otherwise gcc -Wall will complain at you. don't skip the type. π
π₯ SEE ALSO π₯
and that's the whole page, you ate it fr fr. π«Ά this lil beauty comes to you from Linux man-pages 6.20, dated 2025-09-21, and it's page end(3). iconic. π β¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms