About mips-elf-ld (newlib)

Jeff Johnston jjohnstn@redhat.com
Thu Jul 8 02:36:00 GMT 2004

libra wrote:
> At first, thanks for your reply.
> 1. I do not write my own crt0.c
> 2. I compile my program by "mips-elf-gcc t.c"
>    then i get the following error message:
>    warning: cannot find entry symbol _start and
>    undefined reference to `printf'
> I have an experience that to build arm toolchain successfully (--target=arm-
> elf).
> I use the same method to build the mips toolchain (--target=mips-elf).
> I can use the mips-elf-gcc option "-v" to see which file(object) do it links 
> for mips executable file.
> From the information, i compare it with arm gcc (arm-elf-gcc -v t.c),
> i find that it lacks to link crt0.o and -lc option.
> So, i get the above error message.

The gcc compiler does not operate the same for every platform.  In some cases
gcc adds linking info under the covers.  In other cases, you have to manually
specify an ld script.  If you look in libgloss/mips you will see a number of .ld
scripts.  Pick the one appropriate for your board and add -Txxxx.ld to your
compile/link statement (where xxxx.ld is the ld script you chose).  If none of
the .ld scripts are appropriate, you will have to copy the closest one and make
whatever modifications are needed.

> Maybe, i build the mips toolchain with wrong method (especially newlib part).
> Therefore, i get the wrong result.

Just make sure you built libgloss as well.  If you built all, you are fine.  If
you just specified all-target-newlib install-target-newlib, then you need to add
 all-target-libgloss install-target-libgloss

> Anyone has the experience to build the mips toolchain (--target=mips-elf) 
> (binutils gcc newlib gdb)successfully can get me some ideas!!
>                                                    thanks a lot !!
> ----- Original Message ----- 
> From: "Alexander Stante" <mrpac@gmx.de>
> To: "libra" <mr924352@cs.nthu.edu.tw>
> Cc: <newlib@sources.redhat.com>
> Sent: Wednesday, July 07, 2004 5:33 PM
> Subject: Re: About mips-elf-ld (newlib)
>>libra wrote:
>>>The error message is that:
>>>elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 
>>Did you wrote your own crt0? Check if there is the entry point _start in
>>it. You can also change the entry point in your linkskript with
>>>/cygdrive/c/DOCUME~1/libra/LOCALS~1/Temp/ccYfspyO.o(.text+0x3c): In 
> function 
>>>: undefined reference to `printf'
>>>collect2: ld returned 1 exit status
>>It is a bit hard to tell what cause this problem because you didn't
>>supplied the command line with which you compiled you program. You used
>>the -lc switch to use libc but maybe at the wrong position. Try using it
>>at last argument.

More information about the Newlib mailing list