Subject: crt*.o
To: None <netbsd-help@netbsd.org>
From: Richard Rauch <rkr@olib.org>
List: netbsd-help
Date: 12/11/2003 17:15:42
(I asked on port-amd64, but have had no answer and suspect that the
question is more general, so I'm asking again over here.)


Okay, I know that the "crt" object file is the "C Run-Time" library/module.
It basically has pre-main() and post-main() code that takes care of things
like setting up {argv, argc} and such.

On UNIX, I've never had occasion to worry about which crt was used (or even
noticed that there was more than one to choose from).

The other day, I was making a stab at porting GNU EMACS to NetBSD/amd64.
My first effort was to weakly-adapt a standard machine template.h into an
amd64.h.  This compiled (with numerous warnings) but seemed to work.  Then
some GNU/LINUX porting work on EMACS to the AMD64 was also brought to my
attention (or rather, their modified sources).

Their machine .h file was more careful than mine and produced fewer warnings
when I compiled.  Great!

But I can't link.  It wants crt1.o, which NetBSD (at least /amd64) does not
have.  They specifically insisted on this, rather than letting the default
selection be made.  NetBSD/amd64 has crti.o and crtn.o.

How do these crt*.o files differ from one another?  Does it really matter
which one I go with?  Is there a no-brainer choice to provide equivalent
functionality to the GNU/LINUX AMD64 version of crt1.o, or do I need to
hunt down some penguins and modulate them with C lions until they tell
me what crt1.o is good for?

(And where would I find a rundown of these files for NetBSD, since they
are apparently system-dependant to some degree?  The GCC info pages tell
you how to choose a crt*.o file, or disable its use, but not why you
should care about one or another.)


-- 
  "I probably don't know what I'm talking about."  http://www.olib.org/~rkr/