[net.emacs] About crt0

daveb%llama@SUN.COM (05/06/86)

From: daveb%llama@SUN.COM (Dave Brower)

Echoing David Robinson's query about crt0.  I found trying to set that
up one of the hardest parts to porting gnu to a new machine.  Would
someone (rms if not too busy) please explain clearly what is going on
there, and why it is not desireable to use the one that comes standard
with the machine.  There's description of the mechanics for a number of
machines in crt0.c, but not much high level rationale.  

BTW, does anyone know of progress on the programmer's manual?

-dB

martillo@ATHENA.MIT.EDU (05/06/86)

From: Yakim Martillo <martillo@ATHENA.MIT.EDU>


crt0.c or crt0.s contains the true entry point for execution of a C
program.  When a program is loaded into memory, the pc is set at fixed
location.  The first executable statement of the crt0.o is loaded into
that location.  Exactly what that instruction and the instruction
which follows are depends on the nature of the machine, but the
executable code must among other things set up the global variable
environ and  the last thing which the executable code in crt0.o
must do is set up the stack and call main so that main appears to have
been invoked with 3 arguments, argc, argv, and envp.

Many machines really do not need to have their own rewritten crt0.c or
crt0.s but a few treat environ as initialized data rather than unitialized
bss.  Since temacs dumps itself and users run xemacs, the executable code
must be sure to set up the environ variable properly for dumped version
of emacs as well as the temacs version. The environment from temacs must
not be the environment when temacs is run.  Also, data locations less than
&pure[PURESIZE] are moved into the text segment in some dumped versions of
xemacs.  You would not want this to happen to the environ.

Therefor on some machines rewriting crt0.o is necessary.