Linking problem in m68k-uclinux toolchain: crt0.o not found

Denis Vlasenko vda.linux at googlemail.com
Tue Jun 26 14:02:12 UTC 2007


Hi Paul, Rob, folks,

At http://qemu.org/download.html I see:

coldfire-test-0.1.tar.bz2 Coldfire Linux 2.6 test kernel and initrd
disk image (thanx to Paul Brook)

I downloaded and it works for me. I plan to test newer busybox in a
similar way. I built a cross-compiler toolchain using current releases
of needed tools:

binutils-2.17-m68k-uclinux
gcc-4.1.2-m68k-uclinux
uclibc-0.9.29-m68k-uclinux

And I try to cross-compile busybox. It works up to the final link,
where it complains about crt0.o missing. I tried to cross compile
trivial C program and got the same error:

 /usr/app/gcc-4.1.2-m68k-uclinux/libexec/gcc/m68k-uclinux/4.1.2/collect2
 crt0.o
 -L/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-uclinux/4.1.2
 -L/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc
 -L/usr/lib/../m68k-uclinux/lib
 /tmp/cccr3rdn.o -lgcc -lc -lgcc
/usr/lib/../m68k-uclinux/bin/ld: crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status

I do not see crt0.o anywhere in my cross-compiling toolchain. Not in
binutils, not in gcc, not in uclibc. So where should it come from?

I am not experienced in this, but IIUC crt0.o is used by toolchains
which support static linking only, because I see that native compiler
and AMB64 cross-compiler does not try to link against crt0.o, but uses
crt1.o etc instead, even if I use -static on gcc command line.

Thus maybe the problem is that I failed to explain to uclibc that it
needs to produce crt0.o, or maybe I chose wrong cross-compiling prefix
(did I need to build m68k-elf cross instead?).

If you know what's wrong then please let me know.

If you don't know what's wrong but have a working cross-compiling
toolchain installed, please save

int main() { return 0; }

as a t.c, run

<your-cross-compiler>-gcc -v t.c

and send me output. I'll try to figure out it myself. I am interested
in output of any kind of cross compiler, not necessarily
m68k-something.

For me, m68k-uclinux-gcc -v t.c says:

Using built-in specs.
Target: m68k-uclinux
Configured with: /usr/src/gcc-4.1.2/configure
--prefix=/usr/app/gcc-4.1.2-m68k-uclinux
--exec-prefix=/usr/app/gcc-4.1.2-m68k-uclinux --bindi
Thread model: single
gcc version 4.1.2
 /usr/app/gcc-4.1.2-m68k-uclinux/libexec/gcc/m68k-uclinux/4.1.2/cc1
-quiet -v -iprefix
/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-u
ignoring nonexistent directory
"/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-uclinux/4.1.2/../../../../m68k-uclinux/sys-include"
ignoring nonexistent directory
"/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-uclinux/4.1.2/../../../../m68k-uclinux/include"
ignoring nonexistent directory "/usr/lib/gcc/m68k-uclinux/4.1.2/include"
ignoring nonexistent directory "/usr/lib/../m68k-uclinux/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-uclinux/4.1.2/include
 /usr/lib/../m68k-uclinux/include
End of search list.
GNU C version 4.1.2 (m68k-uclinux)
        compiled by GNU C version 4.1.2.
GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=47845
Compiler executable checksum: e5aea9b75e0114862c1dad52dfd4453a
 /usr/lib/../m68k-uclinux/bin/as -mc68020 -o /tmp/cccr3rdn.o /tmp/cciVYOtf.s

 /usr/app/gcc-4.1.2-m68k-uclinux/libexec/gcc/m68k-uclinux/4.1.2/collect2
 crt0.o
 -L/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc/m68k-uclinux/4.1.2
 -L/usr/app/gcc-4.1.2-m68k-uclinux/bin/../lib/gcc
 -L/usr/lib/../m68k-uclinux/lib
 /tmp/cccr3rdn.o -lgcc -lc -lgcc

/usr/lib/../m68k-uclinux/bin/ld: crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status

This last command, collect2, is invoked differently (and successfully)
by other compilers here:

AMD64:

 /usr/app/gcc-4.1.1-x86_64/libexec/gcc/x86_64-pc-linux-gnu/4.1.1/collect2
 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
 /usr/lib/../x86_64-pc-linux-gnu/lib/crt1.o
 /usr/lib/../x86_64-pc-linux-gnu/lib/crti.o
 /usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbegin.o
 -L/usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1
 -L/usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc
 -L/usr/lib/../x86_64-pc-linux-gnu/lib
 /tmp/ccqDPKwa.o -lgcc -lc -lgcc
 /usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtend.o
 /usr/lib/../x86_64-pc-linux-gnu/lib/crtn.o

AMD64 -static:

 /usr/app/gcc-4.1.1-x86_64/libexec/gcc/x86_64-pc-linux-gnu/4.1.1/collect2
 -m elf_x86_64 -static
 /usr/lib/../x86_64-pc-linux-gnu/lib/crt1.o
 /usr/lib/../x86_64-pc-linux-gnu/lib/crti.o
 /usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbeginT.o
 -L/usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1
 -L/usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc
 -L/usr/lib/../x86_64-pc-linux-gnu/lib
 /tmp/ccewZ9o3.o --start-group -lgcc -lc --end-group
 /usr/app/gcc-4.1.1-x86_64/bin/../lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtend.o
 /usr/lib/../x86_64-pc-linux-gnu/lib/crtn.o

Native i386 -static:

 /usr/app/gcc-4.1.2/libexec/gcc/i386-pc-linux-gnu/4.1.2/collect2
 -m elf_i386 -static
 /usr/lib/crt1.o
 /usr/lib/crti.o
 /usr/app/gcc-4.1.2/bin/../lib/gcc/i386-pc-linux-gnu/4.1.2/crtbeginT.o
 -L/usr/app/gcc-4.1.2/bin/../lib/gcc/i386-pc-linux-gnu/4.1.2
 -L/usr/app/gcc-4.1.2/bin/../lib/gcc
 -L/usr/app/gcc-4.1.2/bin/../lib/gcc/i386-pc-linux-gnu/4.1.2/../../..
 /tmp/ccWpyMak.o
 --start-group -lgcc -lgcc_eh -lc --end-group
 /usr/app/gcc-4.1.2/bin/../lib/gcc/i386-pc-linux-gnu/4.1.2/crtend.o
 /usr/lib/crtn.o

--
vda



More information about the busybox mailing list