get_end.3   [plain text]


.TH GET_END 3  "April 10, 1998" "Apple Computer, Inc."
.SH NAME
get_end, get_etext, get_edata \- get values of UNIX link editor defined symbols
.SH SYNOPSIS
.nf
.PP
#include <mach-o/getsect.h>
.sp
unsigned long \fBget_end()\fR;
unsigned long \fBget_etext()\fR;
unsigned long \fBget_edata()\fR;
.fi
.SH DESCRIPTION
These routines provide a stopgap measure to programs that use the
.SM UNIX
link-editor defined symbols.  Use of these routines is very strongly
discouraged.  The problem is that any program that is using
.SM UNIX
link editor defined symbols (_end, _etext or _edata) is making assumptions that
the program has the memory layout of a UNIX program. 
.PP
This is an incorrect assumption for a program built by the Mach-O link
editor.  The reason that these routines are provided is that if very minimal
assumptions about the layout are used and the default format and memory layout
of the Mach-O link editor is used to build the program, some things may work by
using the values returned by these routines in place of the addresses of their
UNIX link-editor defined symbols.  So use at your own risk, and only if you
know what your doing.
Or better yet, convert the program to use the appropriate Mach or Mach-O
functions.  If you are trying to allocate memory use
.IR vm_allocate (2),
if you are trying to find out about your address space use
.IR vm_region (2)
and if you are trying to find out where your program is loaded use the
.IR dyld (3)
functions.
.PP
The values of the UNIX link-editor defined symbols _etext, _edata and _end are
returned by the routines get_etext, get_edata, and get_end respectively.
In a Mach-O file they have the following values:
get_etext returns the first address after the
.SM (\_\^\_TEXT,\_\^\_text)
section, note this my or may not be the only section in the \_\^\_TEXT segment.
get_edata returns the first address after the
.SM (\_\^\_DATA,\_\^\_data)
section, note this my or may not be the last non-zero fill section in
the \_\^\_DATA segment.
get_end returns the first address after
the last segment in the executable, note a shared library may be loaded at this
address.
.SH "SEE ALSO"
ld(1), dyld(3)