This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Mips cross-compiled glibc: linker says use libc.so.1 as loader!
- To: bug-glibc at gnu dot org, glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Mips cross-compiled glibc: linker says use libc.so.1 as loader!
- From: Chris Worley <cworley at liberate dot com>
- Date: Tue, 27 Jun 2000 10:28:22 -0600
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
BACKGROUND:
I've built a mips cross compiler from:
binutils 2.8.1-1
egcs 1.0.3a-1
And a myriad of patches. I used this revision & patches because they
were known to work for a mips cross-compiler (as opposed to current egcs
revs that have lots of
reported problems building mips cross compilers).
I built glibc 2.0.7-20 with the cross compiler, also with a myriad of
patches, again supposed to work on mips. I generally followed the
instructions from:
> http://www.fokus.gmd.de/linux/HOWTO/MIPS-HOWTO-8.html
But I used the files and patches from:
> ftp://ftp.place.org/pub/nop/linuxce/
Since I'm building for a board that has a mips 4111x core, but is big
endian (unlike all other boards in the LinuxCE project).
I've also tried the pre-built cross compilers from SGI
> ftp://oss.sgi.com/pub/linux/mips/crossdev/i386-linux/mips-linux/
Both GCC's build a valid (it runs) executable Linux kernel v2.3.21.
PROBLEM:
Programs built with this glibc don't run.
In the kernel, when it goes to run "init" (in my case /bin/sh), it first
looks for the loader to use, which is in the executable. It's told
"libc.so.1"!!!!!! I've never heard of this before... the glibc loader
is ld.so.1. The binfmt_elf.c code says these are the two possible
dynamic loaders. If I do a "strings" on the executable I'm trying to
load, one of the first is "libc.so.1" (libc.so.6 comes later), and
there's no mention of "ld.so.1".
What did I do wrong?
The contortions I use to link might be a hint...
When I link using the gcc cross compiler, it always gives the error
"crt1.o not found" from "ld". I haven't been able to get rid of that
error, so I've been linking in a seperate command line. With the cross
linker, the following command should work:
># mips-linux-gnu-ld -L/hw/export/home/cworley/mips/egcs/lib/ -s -o hello hello.o -lc
But, that gives the errors:
>mips-linux-gnu-ld: warning: ld.so.1, needed by /home/cworley/mips/egcs/lib/libc.so.6, not found (try using --rpath)
>mips-linux-gnu-ld: warning: cannot find entry symbol __start; defaulting to 0000000000400540
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `errno'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_sysdep_start'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_object_relocation_scope'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `__libc_enable_secure'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_lookup_symbol'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_global_scope'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_debug_state'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_global_scope_end'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_init_next'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_debug_initialize'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_relocate_object'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_starting_up'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_default_scope'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_map_object'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_signal_error'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_r_debug'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_catch_error'
>/home/cworley/mips/egcs/lib/libc.so.6: undefined reference to `_dl_map_object_deps'
That looks like an "-ldl" problem, but the only way I could fix it is
referencing "ld.so.1" right on the link command line!!!!
># mips-linux-gnu-ld -L/hw/export/home/cworley/mips/egcs/lib/ -s -o hello hello.o -lc /hw/export/home/cworley/mips/egcs/lib/ld.so.1
That still gives the error:
>mips-linux-gnu-ld: warning: cannot find entry symbol __start; defaulting to 0000000000400550
Which, just like the cross gcc, is not finding crt1.o, so I specify it
("/hw/export/home/cworley/mips/egcs/lib/crt1.o") on the command line,
and now the linker thinks everything is okay... but, it thinks the
loader is "libc.so.1" when trying to execute it.
The above is using the egcs I built. If I use the SGI egcs cross
compiler (referenced at top), I have the same entry point "start"
problems, but don't have to put
"/hw/export/home/cworley/mips/egcs/lib/ld.so.1" as a library on the link
command line. But, the kernel still thinks "libc.so.1" is the loader
rather than "ld.so.1".
Static cross linking is equally curious:
># mips-linux-gnu-ld -static -L/hw/export/home/cworley/mips/egcs/lib/ -s -o hello hello.o -lc
Should work, but gives the error:
>mips-linux-gnu-ld: warning: cannot find entry symbol __start; defaulting to 0000000000404180
So, again, I stick on "crt1.o":
># mips-linux-gnu-ld -static -L/hw/export/home/cworley/mips/egcs/lib/ -s -o hello /hw/export/home/cworley/mips/egcs/lib/crt1.o hello.o -lc
That produces the additional errors:
>/hw/export/home/cworley/mips/egcs/lib/crt1.o(.text+0xb0): undefined reference to `_init'
>/hw/export/home/cworley/mips/egcs/lib/crt1.o(.text+0xd4): undefined reference to `_fini'
So, I add "crti.o":
># mips-linux-gnu-ld -static -L/hw/export/home/cworley/mips/egcs/lib/ -s -o hello /hw/export/home/cworley/mips/egcs/lib/crt1.o /hw/export/home/cworley/mips/egcs/lib/crti.o hello.o -lc
And that builds, but also doesn't execute.
SUMMARY
I've basically got 2 or 3 problems:
o the linker doesn't know how to setup the executables start
address,
o dynamic linking doesn't work right and/or
o the wrong dynamic link loader is being specified
Any clues would be appreciated. I'm guessing I did something horribly
wrong building glibc, but I don't know what.
Thanks,
Chris