[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

linking against an older glibc?



Hello all.  This is a general glibc question, and does not have to deal with
Debian directly.  Sorry for the off-topic posting, but I don't know of
another open forum for glibc discussion (libc-hackers being closed).

I have built and installed glibc 2.2.4 in a non-system directory (i.e, not
in /lib or /usr/lib) that I wish to build against.  I believe this is needed
in order to have working binaries that are forwards-compatible with that
version and later glibc versioned symbols (ie, usable on woody, sarge, RH
7.2 and RHEL 3).  The actual system glibc on this machine is 2.3.3.

So, is there any documentation how to get a working shippable binary
available?  I've tried building a simple 'hello world' program, but it fails
in various ways involving ld-linux.so.2.

If I use a simple gcc -I$prefix/include -L$prefix/lib, it fails to link,
first using the system crt1.o (with missing symbols) and then showing
missing versioned symbols that are present in the 2.2.4
$prefix/lib/ld-linux.so.2 but not in the /lib/ld-linux.so.2 (eg:
_dl_lazy@GLIBC_2.1.1, dl_out_of_memory@GLIBC_2.2, etc.).  Specifying
-nostdlib and the $prefix/lib/crt1.o seems to solve that portion of the
problem.

However, if I include $prefix/lib/ld-linux.so.2 on the link line, it links,
but then get a segfault when trying to run it, in fixup() from
/lib/ld-linux.so.2.

If I try to use the -dynamic-linker $prefix/lib/ld-linux.so.2 option when
linking, it won't execute the resulting binary:

> make
echo "#include <stdio.h>" > helloworld.c
echo 'int main() { printf("hello world\n"); return 0; }' >> helloworld.c
/usr/local/fbe/3.0/bin/gcc -c -g -I/usr/local/fbe/3.0/glibc/include -o helloworld.o helloworld.c
/usr/local/fbe/3.0/bin/gcc -g -I/usr/local/fbe/3.0/glibc/include -o helloworld helloworld.o -nostdlib -L/usr/local/fbe/3.0/glibc/lib -lc /usr/local/fbe/3.0/glibc/lib/crt1.o /usr/local/fbe/3.0/glibc/lib/crti.o /usr/local/fbe/3.0/glibc/lib/ld-linux.so.2 -dynamic-linker /usr/local/fbe/3.0/glibc/lib/ld-linux.so.2 
> ./helloworld 
./helloworld: Command not found.
> ldd ./helloworld
/usr/bin/ldd: line 1: ./helloworld: No such file or directory


I don't know if this matters, but this glibc was built after gcc and
binutils, which have no knowledge of it.

Any ideas, hints or direction to documentation would be appreciated.  

Thanks all,
-Chris

--
Chris Ruvolo
Veritas Software
cruvolo@veritas.com



Reply to: