C startup in /lib/crt0.o
Roland Dirlewanger
rd at lri.UUCP
Tue Apr 29 23:55:47 AEST 1986
In article <100 at cstvax.UUCP> simon at cstvax.UUCP (Simon Brown) writes:
>
>I see that the C startup routine _start in /lib/crt0.o under 4.2BSD
>is a bit over-protective, in that it calls routine _exit (rather than
>the system-call __exit) when it terminates.
>(At least, this is the case >here< - I don't know if its very standard!)
>
>Does anyone know why? (or care, for that matter).
>I suppose it does no harm really (except load in 4k of stdio-library
>garbage, which I could really cope without!).
It is standard, and in almost every Unix system. This needed to flush all
the buffering done by the stdio-library when your process exits.
If you don't use the stdio package, adding these few lines to your programs
will avoid these 4K of garbage to be loaded:
exit (n) {
return _exit (n);
}
Question:
How standard is the stdio package ? I had some troubles with it,
especially on a SUN 2 (may be this bug has been corrected in the new
3.0 version of SUN's system). Using stdio's printf caused the next
malloc to return a non-aligned pointer. Using it as pointer to
a short integer obviously core dumped.
Personnaly, I don't use the stdio package.
I have rewritten from scratch my own printf, sprintf and fprintf
(except for floatting point numbers) and I use only reads and
writes for accessing files (sometimes I have to do buffered
I/O myself, if I don't want to access files one character at a time).
Roland Dirlewanger
More information about the Comp.unix.wizards
mailing list