[pocket-linux] Chapter 3. The dreaded libc.so.6
David Horton
dhorton at speakeasy.net
Thu Oct 28 08:33:49 CDT 2004
> -----Original Message-----
> From: Miguel Servin [mailto:El.Servas at gmail.com]
> Sent: Thursday, October 28, 2004 05:16 AM
> To: 'Support for Pocket Linux Guide'
> Subject: Re: [pocket-linux] Chapter 3. The dreaded libc.so.6
>
> I followed the directions for the chapter 2 (Build a statically-linked
> bash) but using compressed image in the rootdisk, from chapter 3.
>
> As was predicted, the statically-linked bash (3.00) worked wonderfully
> when loaded from the compressed image in the rootdisk.
>
> The problem arises when I compile bash without the --enable-static-link option.
>
> The output from 'ldd bash' when compiled using './configure
> --enable-minimal-config' and then 'make' is:
> libdl.so.2 => /lib/libdl.so.2 (0x40026000)
> libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
> /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
>
> (note the reference to /lib/tls/libc.so.6, instead of the 'default'
> /lib/libc.so.6)
>
> So, in my [compressed] rootdisk I created the aditional directory
> /lib/tls and added a symlink there, pointing to the file in /lib, but
> still no go.
> (/lib/tls/libc.so.6 -> /lib/libc.so.6)
>
> The kernel boots, loads the compressed image into the ramdisk, tries
> to execute /bin/sh and dies because the binary can't find libc.so.6 :(
>
> Is there a way (maybe involving ld.so.conf and ldconfig, I don't
> know...) to specify the compiler NOT to use the libraries in /lib/tls
> when building bash, but just the ones in /lib?
>
> Thank you.
>
It should not matter if you put a link in /lib/tls that points to a library in /lib or if you just put the library in /lib. It's up to the linker, ld-linux.so.2, to figure out where the library is located. For example, you see the line "libc.so.6 => /lib/tls/libc.so.6 (0x42000000)" when you do 'ldd bash' on your Redhat machine. This means that bash is looking for libdl.so.2 and asks ld-linux.so.2 to find it. ld-linux.so.2 is smart enough to look in various places to find it. /lib and /usr/lib are default locations, but it can also look in directories specified by /etc/ld.so.conf. Now, this is where things get strange... On your Redhat box the ld.so.conf is set up to also look in /lib/tls (as well as the defaults of /lib and /usr/lib) and /lib/tls is where the libc.so.6 library resides on the Redhat box. But, since ld-linux.so.2 is taking care of finding the libraries it does not matter if it is in /lib/tls, /lib or /usr/lib. The Poket Linux setup does not use /lib/tls, but that's okay since it's ld-linux.so.2's job to find the library and it will always look in the default locations of /lib and /usr/lib.
That long-winded explaination does not solve your problem, but it does rule out one possible trouble spot. For further troubleshooting let me ask you if you are booting the diskettes on the same machine that you are building on. If not, that might be the problem. If you build on a fast 686 machine and then boot on a 486 it may have trouble with the libraries. If that is the case you can use libraries from http://www.happy-monkey.net/architect/bin-pkgs/ since these are compiled for a 386.
Hope it helps,
Dave
More information about the Pocket-Linux
mailing list