This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: crt{i,n}.o


On Tue, Oct 24, 2000 at 11:09:06PM -0700, Geoff Keating wrote:
> > Date: Wed, 25 Oct 2000 00:23:48 -0500
> > From: Bill Wendling <wendling@ncsa.uiuc.edu>
> > Cc: obrien@FreeBSD.org, gcc@gcc.gnu.org
> > Content-Disposition: inline
> > User-Agent: Mutt/1.2i
> > 
> > This brings my (naive) question: What are the crt*.o files for?
> 
> Constructors and destructors (for crt[in].o).  They work together with
> gcc to create a single routine that runs all the initialisation and
> finalisation routines for shared objects.

Typically where you have paired object files such as crtbegin.o and crtend.o,
it is to allow the runtime libraries to know where the beginning and end of
various sections are (one object is linked before the user modules and the
other is linked after).  As Geoff points out, constructors and destructors are
one such reason.  Zeroing out (multiple) bss sections; copying data from a PROM
(programmable read only memory) to read/write data areas; relocating pointers
for embedded PIC support are other reasons that some processors use.  Since the
OS/library support is often times provided by different people than the
compiler support, it is not unknown to have two begin modules (one for system,
and the other for the compiler) and two end modules.

Often times there is also an additional module (usually crt0.o) that is linked
before everything, and that provides the necessary glue to start the program.
In many systems different crt0.o files provide for profiling support, etc.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]