The future of __main (was Re: __main call for c++ on sparc-elf target)
Jim Wilson
wilson@tuliptree.org
Thu Jun 26 18:35:00 GMT 2003
On Thu, 2003-06-26 at 08:54, Chris Lattner wrote:
> I just wanted to say that I hope that __main never goes away:
I think it will go away eventually, for ELF targets at least.
Another problem with __main is that there is no guarantee that there is
a function called main. The C standard does not require a main function
for freestanding programs.
Some of your criticisms of init/fini are fixed by the follow on
init_array/fini_array ELF sections. init/fini contain code, but
init_array/fini_array are just lists of function addresses. They are
similar to the ctor/dtor lists we have now, except that the code that
runs them is now in the loader instead of in the program. I think that
solves most of your size problem. It also makes them more transparent
to a whole program optimizer. See the ELF standard for more info.
The GNU tools have been very slow to move to init_array/fini_array, but
there is support for them in glibc and binutils now. So it is mostly a
matter of fixing gcc to use them exclusively now instead of init/fini
sections when possible. There is some gcc support for this already, but
I don't know how complete it is.
Jim
More information about the Gcc
mailing list