From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10474 invoked by alias); 10 Sep 2008 14:40:09 -0000 Received: (qmail 10466 invoked by uid 22791); 10 Sep 2008 14:40:08 -0000 X-Spam-Check-By: sourceware.org Received: from mta-out.inet.fi (HELO kirsi2.inet.fi) (195.156.147.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 10 Sep 2008 14:39:25 +0000 Received: from [192.168.0.2] (88.193.134.7) by kirsi2.inet.fi (8.5.014) id 488DC54E020EC38E; Wed, 10 Sep 2008 17:39:00 +0300 Message-ID: <48C7DCB5.4090608@wippies.com> Date: Wed, 10 Sep 2008 14:40:00 -0000 From: Kai Ruottu User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Ralf Jahr CC: gcc-help@gcc.gnu.org Subject: Re: Trouble building cross-compiler i686-pc-linux-gnu => mipsel-elf References: <48C7952D.8070508@informatik.uni-augsburg.de> <48C79669.7060404@redhat.com> <48C7CFF3.5070602@informatik.uni-augsburg.de> In-Reply-To: <48C7CFF3.5070602@informatik.uni-augsburg.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-09/txt/msg00069.txt.bz2 Ralf Jahr wrote: > Andrew Haley wrote: >> Ralf Jahr wrote: >>> I try to build a cross-compiler for a mips-target. >>> Well, i assumed that I would get a compiler which can build executables. >>> Unfortunately but this does not work; I get the following error message: >>> >>> /usr/cross-mips/lib/gcc/mipsel-elf/4.3.2/../../../../mipsel-elf/bin/ld: >>> crti.o: No such file: No such file or directory >>> collect2: ld returned 1 exit status >> >> crti.o is part of the C library. You haven't installed a C library, so >> your programs won't link. > > OK, thanks for the inspiration. :-) I got newlibc to compile even > without being able to generate executables. > I can now generate executables and use objdump on them. But I get a > warning message: > > /mipsel-elf-gcc -O3 hello.c -msoft-float -static > /usr/cross-mips/lib/gcc/mipsel-elf/4.3.2/../../../../mipsel-elf/bin/ld: > warning: cannot find entry symbol _start; defaulting to 0000000000400050 > > I think I can live with this. But if I want to use printf I get another > error: > (.text+0xd4): undefined reference to `printf' > collect2: ld returned 1 exit status > > Even adding the compiled libc.a does not help: > Do you have any ideas how I can get rid of this error, too? Ok, you now learned that producing executables requires a C library with startups... But what is still required is some "real" target for "which" to produce executables! The 'mipsel' in the target name is the "cpu/endianess" type, the 'elf' is only the object format, and these two don't yet define the interfaces to the target system, its I/O-system, its memory layout, possible 'syscall' (calls to the 'opsys') etc. The newlib C library has some "glue" libraries for some HW/firmware systems like the PMON-monitor firmware on a MIPS-board, the 'libpmon.a' probably was the name for this glue library. Another real target is an IDT-borad with some IDT-monitor.... There are many ways to tell what that "real target" is, one of these is to edit a default one into the GCC's 'specs' file. I myself have used this because mainly producing executables to the MIPS-simulator coming with the GNU debugger, 'GDB', and this can run apps made for IDT. The important (edited) rows in my gcc-3.2.3 'specs' are : --------------- clip --------------------------------- *endfile: crtend%O%s crtn%O%s -T idt.ld%s *link: %(endian_spec) %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips64} %{bestGnum} %{shared} %{non_shared} *lib: *libgcc: -lgcc *startfile: crti%O%s crtbegin%O%s --------------- clip --------------------------------- The long row after '*link' may be seen as two rows but there is only one and then an empty row after each "spec"... Generally only the startfiles (linked first) and the endfiles (linked last) are defined, the 'libgcc' too, everything else is in that 'linker script' for the IDT-board, 'idt.ld', also this being provided in an installed newlib for mips*-elf. The important thing in editing 'specs' is that it has ist own 'strict' format : Those '%s' ("search and parse this") etc things were described somewhere, the '-T' option for 'ld' should be described in the linker documents... When testing the edited 'specs', using a '-v' in the 'compile and link' command will teach things... Putting a '-Wl,-verbose' onto it will then show what happens during the link phase ("verbosely", with all details)...