Subject: misc/2831: end(3) is confusing
To: None <gnats-bugs@gnats.netbsd.org>
From: Mike Long <mike.long@analog.com>
List: netbsd-bugs
Date: 10/11/1996 04:10:19
>Number: 2831
>Category: misc
>Synopsis: end(3) is confusing
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: misc-bug-people (Misc Bug People)
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 11 01:20:02 1996
>Last-Modified:
>Originator: Mike Long <mike.long@analog.com>
>Organization:
Manpage Manglers
>Release: 1.2_BETA
>Environment:
System: NetBSD azathoth 1.2 NetBSD 1.2 (AZATHOTH) #101: Fri Oct 11 02:32:55 EDT 1996 root@azathoth:/usr/src/sys/arch/i386/compile/AZATHOTH i386
>Description:
end(3) lists the descriptions of the end, etext, and edata
variables in a different order from which it lists the variables
themselves. This mixup will cause confusion, and possibly programming
errors.
>How-To-Repeat:
Compare the description in end(3) with the results of the
following simple experiment:
% cat > test.c
#include <stdio.h>
#include <unistd.h>
extern end, etext, edata;
int main()
{
printf("etext = %p\n", &etext);
printf("edata = %p\n", &edata);
printf("end = %p\n", &end);
printf("sbrk(0) = %p\n", sbrk(0));
return 0;
}
% gcc -o test -static test.c
% size test
text data bss dec hex
28672 4096 0 32768 8000
% ./test
etext = 0x7354
edata = 0x8614
end = 0x8df8
sbrk(0) = 0xdffc
>Fix:
Apply the patch below.
*** src/share/man/man3/end.3~ Fri Mar 1 07:19:36 1996
--- src/share/man/man3/end.3 Fri Oct 11 03:36:13 1996
***************
*** 47,66 ****
.Vt extern edata;
.Sh DESCRIPTION
! The global variables
.Va end , etext
and
.Va edata
! correspond to the
! the next address following
! the end of the text segment,
! the end of initialized data segment and
! the end of the data segment
! .Pq Tn BSS .
.Sh SEE ALSO
.Xr brk 2 ,
! .Xr malloc 3
.Sh HISTORY
! A
.Nm end
manual appeared in
.At v6 .
--- 47,75 ----
.Vt extern edata;
.Sh DESCRIPTION
! The globals
.Va end , etext
and
.Va edata
! correspond to addresses in memory.
! .Va etext
! is the next address following the end of the text segment;
! .Va edata
! is the end of initialized data segment; and
! .Va end
! is the end of the data segment
! .Pq Tn BSS
! when the program is loaded. Use
! .Fn sbrk 0
! to find the current end of the data segment.
.Sh SEE ALSO
.Xr brk 2 ,
! .Xr malloc 3 ,
! .Xr a.out 5
.Sh HISTORY
! An
.Nm end
manual appeared in
.At v6 .
+ .Sh BUGS
+ It is no longer valid to assume that the text segment starts at
+ address zero.
>Audit-Trail:
>Unformatted: