This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __main call for c++ on sparc-elf target
- From: Brenner Joel <joel dot brenner at nemerix dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 27 Jun 2003 07:50:28 +0200
- Subject: Re: __main call for c++ on sparc-elf target
- Organization: Nemerix SA
- References: <3EF7E9C0.2030308@nemerix.com> <3EF89B44.2070401@tuliptree.org>
- Reply-to: joel dot brenner at nemerix dot com
Jim Wilson wrote:
Brenner Joel wrote:
Why gcc does not insert the call to __main ? I suppose __main should
be in gcclib.a, but it isn't there, why?
__main is archaic. ELF systems use the .init/.fini sections to run
static construtors/destructors. crti.o defines function prologues for
init/fini, crtn.o defines function epilogues, crt0.o branches to the
init function at startup, and registers passes the fini function to
atexit. There various minor variations of this scheme. There are
many working ELF targets that you can look at to see how this is done.
Some of the older embedded ELF targets aren't using .init/.fini yet,
but should be fixed to do so. Perhaps sparc-elf is one of them? It
could be broken from lack of maintenance. Fixing it to use
.init/.fini is the best long term option. In the short term, adding a
define for INVOKE__main should get you the __main call back.
Jim
I'm fully agree to use .init/.fini mechanism but I need some more
detailed description of how use it because I need to use my own CRT0
modified for my embedded target. Can somebody tell me where can I find a
description of how this mechanism should work ?
An other problem using sparc-elf gcc is that crti, crtn artbegin and
crtend is only built for solaris but I'm using soft/v8 target.
Joel Brenner