Advise needed: gcc initialization (crt0?)

Johan Nilson johan@envi.se
Fri Oct 1 06:26:00 GMT 1999


After much mumbling and grumbling I have finally manged to build my first ever GCC cross-compiler.
I built it with ecgs-1.1.2 for Hitachi SH target.
It "seems" to work (I don't really have a target machine yet), and I think I have even managed
to make a linker script to put code and variables in proper memory areas (embedded target).

There is one thing however that puzzles me.
Where can I find the c initialization routine and/or instructions on what it need to contain.
I imagine there must be a routine for setting up initial register content, stack initialization, zeroing out
uninitialized data, setting up initializard data etc, before jumping to main()?
Also, how do I define size and location of the stack? Is there a .stack segment in addition to .text, .data and .bss?

I have to admit I'm not entirely clear on the directory structure and contents of the compiler I managed to build, but I
did find a few files named crt0.o, and I read somewhere that this would be the routine taking care of this. But why is
there only a object file? How do I know if it handles "ROMable" code, and if not, how do I know how to write my own
initialization routine?

Thankful for advise,

Johan



More information about the Gcc-help mailing list