This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Problem creating an executable for simulator with newlib


Reed, Dan writes:
 > I've created crosscompiler tools that run under Cygwin (even gdb). I'll post how I did this since there were a few tricks after I verify that this actually worked.
 > 
 > Target=powerpc-eabi
 > 
 > Sources (I used Cygwin sources where they had them.
 >  Although I don't really know how you correspond the Cygwin releases to standard gnu
 > releases):
 > newlib-1.11.0
 > gcc-3.2-3
 > binutils-20030307-1
 > gdb-20030303-1
 > 
 > After creating the tools I compile a standard hello.c (actually test.c) file as such:
 > 
 > powerpc-eabi-gcc -v -nostdlib -static -mcpu=603e -msim -g -o test $LIBDIR/sim-crt0.o \
 >  test.c -lc -lsim -Wl,-Bstatic
 > 
 > It gives me:
 > 
 > /cygdrive/d/gnutemp/test.c:4: undefined reference to `__eabi'

You're passing -nostdlib and then not specifying -lgcc, that's where __eabi is.
Why pass -nostdlib?
If you must, specify -lgcc after everything else.
[pedantic: gcc specifies it internally as -lgcc -lc -lgcc just in case there
are circular references]

Also, the -static and -Wl,-Bstatic seem dubious.
For embedded targets they're generally no-ops (things are already
statically linked by default).

Also, explicitly specifying sim-crt0.o is a bit odd but it's been
awhile since I've played with powerpc-eabi.

For grin's sake, what happens if you do

powerpc-eabi-gcc -v -mcpu=603e -msim -g -o test test.c

Ideally that's what you want to be able to do.
Whether that's the case for powerpc-eabi, I dunno.

Another way to find out how to link programs is to run the gcc
testsuite and study how it does it.
i.e. run "make check RUNTESTFLAGS=execute.exp" in obj/gcc
and then study obj/gcc/testsuite/gcc.log

You'll need to install dejagnu and specify either $DEJAGNU
or --target-board.


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


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