__main undefined symbol

William Gatliff gatliff@haulpak.com
Sat Apr 1 00:00:00 GMT 2000


Doug:


> Startup code is one of the rats nests in GCC.

Actually, not really, at least in my opinion.  The only thing I've seen that I
don't like is that GCC adds a call to _main when it compiles main, which is
totally inconsistent to me.

I would rather see the _main called in crt0, because my application may not even
*have* a main--- I heavily modify crt0 to do lots of wierd things not normally
done in a desktop environment, and if GCC makes certain assumptions (like calling
_main on its terms), then I lose control that I may need.

> You have to remember that GCC supports M different cpus and several file
> formats, ALL of which have their own way of doing things and ALL of which GCC
> has to do correctly for their respective environments.

Which is why ELF (from what little I know about it) will save us all--- except in
my world, where SREC and other binary-oriented formats are king.

This is also why GCC shouldn't even *try* to do startup-specific stuff like
calling _main.  That's crt0's job.

> libgcc.a contains most of the runtime support that GCC compiled programs needs.
> [snip]  Another thing it contains [for targets that need it] is __main, and its
> job is to run the constructors for global objects.

This seems like the right place to put _main's implementation, but I still don't
like the idea that, when GCC sees that it's compiling main, it inserts a call to
_main in it.  *That's* a wart, in my book.

b.g.

--
William A. Gatliff
Senior Design Engineer
Komatsu Mining Systems
To teach is to learn.




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com



More information about the crossgcc mailing list