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


Scott A Sumner writes:
 > Bill/Everyone:
 > 
 > I tried the _main() wart trick on my embedded system, but got a linker
 > error so had to back it out.

Can't help without a lot more detail ... :-)

 > Time to vent:  On a related (startup code) and again frustrating note, my
 > implementation of gcc requires me to have a crt0.o file.  This is not so
 > bad in itself (although I can't rename it or change its extension), but
 > what bugs me to no end is that it has to be in a subdirectory in the
 > compiler's directory tree.  We like to keep our tools on a readonly
 > network drive, so you can imagine the difficulties that arise with crt0.o
 > when it needs to change.  Is there a way around this?  If not, why would
 > the designers of my gcc implementation do what seems a dumb thing?  Or am
 > I wrong in thinking it is a dumb thing to segregate crt0.o from the rest
 > of the object modules?

What do you mean when you say "my implementation of gcc"?
That's not enough info to go on.

Certainly it is the case that if you write your own linker script
and/or mess with -specs [which I recommend avoiding if there are
alternatives], you don't need this magical crt0.o.  Depending upon
how the crt0.o is passed to the linker (either via gcc on the command
line or via a linker script) then -nostartfiles may work for you.
[The fact that I have to qualify whether or not -nostartfiles
will work is one aspect of the rats-nest that I was refering to.]
Note that this can work for hosted systems too, not that I recommend it.

One way to tell gcc where to find crt0.o with the -B option.
This only works if gcc specifies crt0.o to the linker via the command
line [as opposed to having crt0.o appear in a linker script].
[Also, just to be pedantically correct, the file isn't necessarily
names crt0.o.  That's just its canonical name.]
If you've rolled your own crt0.o in /foo/bar then pass
-B/foo/bar/ to gcc [the last trailing / is important].
Note however that -B is also used to tell gcc lots
of other things [where to find the assembler, linker, libgcc],
so don't have any files named "as", "ld", in there
[unless of course you want gcc to use them].
There are games you can play with -B.  gcc just prepends the -B
argument to the file name so if you pass -B/foo/bar/baz- to gcc,
then gcc will use /foo/bar/baz-crt0.o if it exists.
It will also try to use /foo/bar/baz-as ....

------
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]