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


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



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