This is the mail archive of the gcc-help@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: Problem in using powerpc-eabi cross linker...


Jeffi Edward.J wrote:

Again the doubt is on powerpc-eabi cross toolchain with newlib.


Although I built the tool chain, I'm facing problem in using the cross built
tools.

I wrote a simple hello world test program and compiled.
The following errors are issued from linker:

powerpc-eabi-ld: warning: cannot find entry symbol _start; defaulting to
01800074
libgcc.a(eabi.o): In function `__eabi':
eabi.S:232: undefined reference to `__init'
libgcc.a(eabi.o):(.got2+0x8): undefined reference to `__SDATA_START__'
libgcc.a(eabi.o):(.got2+0xc): undefined reference to `__SBSS_END__'
libgcc.a(eabi.o):(.got2+0x14): undefined  reference to `__SDATA2_START__'
...
...
libgcc.a(eabi.o):(.got2+0x50): undefined reference to `__EXCEPT_END__'
collect2: ld returned 1 exit status

If I add -msim or -mads, it is compiled and linked succesfully.

Powerpc-eabi-gcc requires that you specify or supply a library (essentially, the board support package, BSP) which provides the low-level support routines. When you specify -mads or -msim, the correct library name is automatically passed to the linker.

I'm not able to understand what '-mads' is for. Could any one please beief
this?

From info gcc, but not really helpful:


-mads'
     On embedded PowerPC systems, assume that the startup module is
     called `crt0.o' and the standard C libraries are `libads.a' and
     `libc.a'.

This really means that the target board is a Motorola ADS board.


Moreover, when I invoked the compiler and linker separately, linker issues error.

powerpc-eabi-gcc -c test.c -> test.o is generated.

I tried the following variant options for linker.

powerpc-eabi-ld test.o
powerpc-eabi-ld /path_to_startup/crt0.o test.o -lc

All resulted in error as above.

Yes, you need to supply the target board library to the linker.


what are all the extra options I should supply to linker? Or is it the
problem in building of my tool chain?
Can't the linker automatically look for standard libraries like libc.a,
libm.c and the startup module crt0.o?

The linker does look for libc.a and libm.a. But it can't know what target board you want to execute on unless you tell it, so it doesn't know which crt0.o to use.

I used --target=powerpc-eabi to build my tool chain. Should I use specific
target like powerpc-eabisim (for simulator)?

Only if you want to run on the simulator.


My target is an embedded PowerPC processor with non-linux OS running in
big-endian mode.

If it is one of the boards supported by powerpc-eabi (look in "info gcc") then you can specify the board name as "-m<name>". If not, then you need to create a BSP for that board which includes crt0.c, etc. You will likely need to create a linker script as well which describes where various sections are loaded.


-- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077


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