Building a Gcc cross-compiler for a new system (init not working)
Ian Lance Taylor
iant@google.com
Sun Oct 12 02:52:00 GMT 2008
"Thomas Epperson" <epperson@doors-software.com> writes:
> I am working on a cross-compiler for gcc for a system (os) I am
> creating. Everything is fine, except for the fact that initialization
> routines (_init and others related to it) just don't work. I have
> followed the guide here (http://wiki.osdev.org/OS_Specific_Toolchain)
> and I am using newlib. I am looking for some guidance to get the
> initialization routines working.
> I have tried adding crti.o and crtn.o to extra_parts, but have had no
> luck with that. I tried looking at other parts that had init routines
> (like rtems), but I couldn't make sense of them.
> I also read http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gccint/Initialization.html
> This helped out some, but still confused me.
Your startup code has to run the initialization routines. Basically,
when using ELF, it has to call _init before calling main.
On GNU/Linux, the startup code, written in assembler, will call
__libc_start_main, and pass it the address of __libc_csu_init. The
latter function will call _init. This is all part of glibc.
Ian
More information about the Gcc-help
mailing list