I'd like to install and use a non-primary glibc 2.2.x on a system with glibc
2.1.x as the primary glibc (2.2.x and 2.1.x are incompatible). All system
binaries are shared and expect glibc 2.1.x. My goal is to build and run
shared binaries using the non-primary glibc 2.2.x on the same system as
well.
All the FAQs and HOWTOs that I've seen about using non-primary glibc2
assume that the primary glibc is glibc1. This is pretty easy, since glibc1
used ld-linux.so.1, and glibc2 uses ld-linux.so.2, so there's no
collision between the dynamic linker/loaders. But glibc 2.1.x and
glibc 2.2.x BOTH use "ld-linux.so.2". I've worked around this by changing
the
link in mynon-primary glibc2.2.1 (installed in /usr/local/testglibc2.2.1)
from
"ld-linux.so.2" to "ld-linux.so.3", and binary-patched the 2.2.x libc.so.6
to refer to the ld-linux.so.3 (if I don't do this, the system uses
/lib/ld-linux.so.2, which points to ld-2.1.3.so, and the glibc 2.2.x
shared binary doesn't load).
My makefile for a simple hello world shared binary (using the non-primary
glibc 2.2.x) is as follows:
testglibc = /usr/local/testglibc2.2.1
gcc = gcc
.PHONY: all
all: hello
hello: hello.o
$(gcc) -v -shared -fPIC -Wl,-t \
-Wl,--dynamic-linker=$(testglibc)/lib/ld-2.2.1.so \
-B$(testglibc)/lib/ \
-Wl,-rpath=$(testglibc)/lib \
hello.o: hello.c
clean:
rm -f hello hello.o
The resulting binary compiles and links, and ldd shows all the right
libraries being referenced (all in /usr/local/testglibc2.2.1/lib),
but when run it seg faults.
Several people I've talked to about this say "yeah, I've done that"
but haven't offered any concrete instructions or makefiles, etc., on
how to do this. Again, the glibc FAQ that I can see does NOT address
this scenario. Any light that anyone can shed on the matter would be
most appreciated.