This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __main call for c++ on sparc-elf target


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]