man-pages/man3/end.3.html
2021-03-31 01:06:50 +01:00

168 lines
4.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of END</TITLE>
</HEAD><BODY>
<H1>END</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
etext, edata, end - end of program segments
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>extern</B><I> etext</I><B>;</B>
<B>extern</B><I> edata</I><B>;</B>
<B>extern</B><I> end</I><B>;</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The addresses of these symbols indicate the end of various program
segments:
<DL COMPACT>
<DT id="1"><I>etext</I>
<DD>
This is the first address past the end of the text segment
(the program code).
<DT id="2"><I>edata</I>
<DD>
This is the first address past the end of the
initialized data segment.
<DT id="3"><I>end</I>
<DD>
This is the first address past the end of the
uninitialized data segment (also known as the BSS segment).
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>CONFORMING TO</H2>
Although these symbols have long been provided on most UNIX systems,
they are not standardized; use with caution.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
The program must explicitly declare these symbols;
they are not defined in any header file.
<P>
On some systems the names of these symbols are preceded by underscores,
thus:
<I>_etext</I>,
<I>_edata</I>,
and
<I>_end</I>.
These symbols are also defined for programs compiled on Linux.
<P>
At the start of program execution,
the program break will be somewhere near
<I>&amp;end</I>
(perhaps at the start of the following page).
However, the break will change as memory is allocated via
<B><A HREF="/cgi-bin/man/man2html?2+brk">brk</A></B>(2)
or
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3).
Use
<B><A HREF="/cgi-bin/man/man2html?2+sbrk">sbrk</A></B>(2)
with an argument of zero to find the current value of the program break.
<A NAME="lbAG">&nbsp;</A>
<H2>EXAMPLE</H2>
When run, the program below produces output such as the following:
<P>
$<B> ./a.out</B>
First address past:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;program&nbsp;text&nbsp;(etext)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x8048568
<BR>&nbsp;&nbsp;&nbsp;&nbsp;initialized&nbsp;data&nbsp;(edata)&nbsp;&nbsp;&nbsp;0x804a01c
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uninitialized&nbsp;data&nbsp;(end)&nbsp;&nbsp;&nbsp;0x804a024
<A NAME="lbAH">&nbsp;</A>
<H3>Program source</H3>
#include &lt;<A HREF="file:///usr/include/stdio.h">stdio.h</A>&gt;
#include &lt;<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>&gt;
<P>
extern char etext, edata, end; /* The symbols must have some type,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;&quot;gcc&nbsp;-Wall&quot;&nbsp;complains&nbsp;*/
<P>
int
main(int argc, char *argv[])
{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;First&nbsp;address&nbsp;past:\n&quot;);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;&nbsp;&nbsp;&nbsp;&nbsp;program&nbsp;text&nbsp;(etext)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%10p\n&quot;,&nbsp;&amp;etext);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;&nbsp;&nbsp;&nbsp;&nbsp;initialized&nbsp;data&nbsp;(edata)&nbsp;&nbsp;%10p\n&quot;,&nbsp;&amp;edata);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;&nbsp;&nbsp;&nbsp;&nbsp;uninitialized&nbsp;data&nbsp;(end)&nbsp;&nbsp;%10p\n&quot;,&nbsp;&amp;end);
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;exit(EXIT_SUCCESS);
}
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+objdump">objdump</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+readelf">readelf</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?2+sbrk">sbrk</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?5+elf">elf</A></B>(5)
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="7"><A HREF="#lbAE">CONFORMING TO</A><DD>
<DT id="8"><A HREF="#lbAF">NOTES</A><DD>
<DT id="9"><A HREF="#lbAG">EXAMPLE</A><DD>
<DL>
<DT id="10"><A HREF="#lbAH">Program source</A><DD>
</DL>
<DT id="11"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="12"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:39 GMT, March 31, 2021
</BODY>
</HTML>