This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: Three Dumb Questions


Paul Andrews wrote:
> 
> > -----Original Message-----
> > From: Thunder Scientific Corporation
> > Sent: Tuesday, March 28, 2000 9:23 AM
> > To: crossgcc@sourceware.cygnus.com
> > Subject: Three Dumb Questions
> 
> > I really want to know is what manual (where?) should I read?
> > My questions
> > are:
> >
> >       1)  Where can I find documentation on what the somewhat cryptic
> > assembly
> >            commands used by GNU "__asm__" do?  (I've looked
> > through "Using
> > and
> >            Porting GNU CC" by Richard Stallman, but haven't found it.)
> 
> I believe that these are the same as used by the machine description format.
> If you look in UAPGCC on page 166 it says "The constraints use the same
> language used in the machine description..." with more detail on the page.

It sort of is in the UAPGCC manual. Your page numbers may vary depending
on your specified paper format (unless you bought the hardcopy). I found
that I needed to look at some examples to understand the constraints.

> 
> >       2)  What is the function in gcc of crti.o?  Where can I find the
> > source?
> 
> I'm guessing it is the same as crt0.o which is the start up file. You will
> find
> it with your C library (such as newlib) and is specific to each processor.
> 

It is not the same as crt0.o. In some environments (I think all ELF
environements), gcc emits calls to initialization and finalization
functions in .init and .fini sections per compilation unit (i.e.
functions needed to initialize and finalize modules are contained in the
corresponding .o file, and the calls to these functions are thrown in
.init and .fini sections rather than the .text section). In these
environments, the linker must synthesize two functions, _init() and
_fini(), which consist of sequences of function calls to the
initialization and finalization functions. Your crt0.o file, or some
other startup function, is then responsible for calling _init() at
startup time, and to arrange for _fini() to be called at exit time (say,
with atexit(__fini).

crti.o contains function prologues for the _init() and _fini()
functions. crtn.o contains the matching function epilogues. Your linker
scripts must accumulate the content of all .init and .fini sections
between the corresponding function prologues and epilogues with
something like:

    PROVIDE (_init = .);
    *crti.o(.init)
    *(.init)
    *crtn.o(.init)
    
    PROVIDE (_fini = .);
    *crti.o(.fini)
    *(.fini)
    *crtn.o(.fini)


The function prologues and epilogues are processor specific (and
possible ABI specific). You will find the source in the
gcc/config/processor directories. t-crtstuff adds make rules for these
two files, and the crtbegin.o and crtend.o files. crtstuff.c contains
the code to handle construction and destructio of static objects and to
deal with exception handling. crti/crtn are often used in conjunction
with crtbegin/crtend.

Depending on your target environment, you may not need any of this
stuff. The classic startup mechanism is to have gcc insert a call to
__main() at the beginning of main. collect2 is then used to collect the
initialization and finalization code as well as constructors and
destructors for static objects from the various object modules before
invoking ld so that the __main function can find all that is needs in
"predefined places". The new init/fini approach does not require
collect2 since the work in passed on to ld.


> >       3)  How can I insert commands in a Makefile to dump (selected)
> > diagnostic
> >            information near a failure point?  (I've got GNU make
> > documentation
> >            for versions 3.74 and 3.75) in .ps format, but I'm
> > still looking
> > for
> >            suggestions.)
> 
> Don't know :-( what info did you want to print??
> 
> > This newbie would appreciate some guidance.
> >
> > Richard Bowser
> > Engineer
> > Thunder Scientific Corporation
> >
> > email:    richardb@thunderscientific.com
> >
> >
> >
> > ------
> > Want more information?  See the CrossGCC FAQ,
> > http://www.objsw.com/CrossGCC/
> > Want to unsubscribe? Send a note to
> > crossgcc-unsubscribe@sourceware.cygnus.com
> >
> 
> ------
> Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

-- 
Charles-Antoine Gauthier
Institute for Information Technology   Institut de technologie de
l'information
National Research Council of Canada    Conseil national de recherches du
Canada

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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