This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: __main undefined symbol


Peter Popov wrote:

> You can specify the entry point in your linker script file.

The entry point specification in a linker command file doesn't do anything to the
output image if the format is a binary type, i.e. SREC, afaik.  The "entry point" on
these systems is whatever gets put in the reset vector, which ld doesn't know (or
care) about.  This is as it should be.

The ENTRY command *does* cause a proper S7 record to be emitted.  Kudos, especially
considering SREC's lack of use on the desktop.

> but for a custom embedded system you're better off writing your own library.

Actually, probably not, if time-to-market is an issue.  Gimme newlib and the stuff
that comes with gcc, and gimme now.  :^)

> You can then tell the compiler not to link against the standard libs, write your
> own linker script, and not worry about _main or crt.o.  Then you'll know exactly
> what's going on under the hood, and personally, I feel a lot better that way.

Except that when GCC compiles your main(), it always inserts a call to _main() on
all the targets I'm familiar with.  So you always need a _main() if you have a
main(), regardless of your use of crt0, libgcc, etc. etc.

BTW, I *do* write my own linker scripts and crt0, which is how I came across this
_main() thing in the first place.  And, yes, I *do* know what's going on under the
hood.  Which is why I'm so keen on GNU.

Now that I understand the reason (thanks, Jeff!), putting a dummy _main() in my C
code is a very minor wart, considering the alternative.

For the record, despite the fact that GCC started out life as a compiler for
"desktop" environments, it makes very few assumptions about "under the hood"
subjects.  In this respect, it's better than any commercial compiler I've dealt with
in my nine years of experience doing embedded work.

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


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