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: Jim Wilson <wilson at tuliptree dot org>
- To: joel dot brenner at nemerix dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 24 Jun 2003 11:41:08 -0700
- Subject: Re: __main call for c++ on sparc-elf target
- References: <3EF7E9C0.2030308@nemerix.com>
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