This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Building a Gcc cross-compiler for a new system (init not working)
- From: Ian Lance Taylor <iant at google dot com>
- To: "Thomas Epperson" <epperson at doors-software dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 11 Oct 2008 19:50:59 -0700
- Subject: Re: Building a Gcc cross-compiler for a new system (init not working)
- References: <3f9ff4db0810111454r721126ecl6af50601c5d948a8@mail.gmail.com> <3f9ff4db0810111459t1b2e85f1y4f3f9a2dde716643@mail.gmail.com>
"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