testing out incompatible glibc with shared executables...possible?

Ken Whaley ken@believe.com
Thu Apr 26 20:43:00 GMT 2001


I'm trying to build and run a dynamically shared executable based on
an install of a "test" build of glibc (2.2.1 in this case) on a x86-linux
system (redhat 6.2) based on glibc 2.1.x.  I'm using gcc 2.95.2.  I've read
the glibc FAQ, and didn't find any usable solution in there.

The static build runs fine, but I can't get the shared version of a
hello world app to work (it links w/out error but seg faults when run
(the glibc 2.1.x gdb on the system is of no help in debugging it, no
surprise there)).

Here's the makefile:

testglibc = /usr/local/testglibc2.2.1
.PHONY: all
all: hello-shared hello-static

hello-shared: hello.o
	gcc -v -shared -fPIC -Wl,-t \
		-B$(testglibc)/lib/ \
		-Wl,-rpath=$(testglibc)/lib \
		-I$(testglibc)/include \
		$< -o $@

hello-static: hello.o
	$(gcc) -v -static \
		-B$(testglibc)/lib/ \
		-I$(testglibc)/include \
		$< -o $@

hello.o: hello.c
 $(gcc) -v -c -g -O0 -I$(testglibc)/include $< -o $@

hello.c is just

#include <stdio.h>
main(){ printf("howdy\n"); }

ldd shows:
% ldd hello-shared
     libc.so.6 => /usr/local/testglibc2.2.1/lib/libc.so.6 (0x40003000)
     ld-linux.so.3 => /usr/local/testglibc2.2.1/lib/ld-linux.so.3
(0x40113000)

I can see from the -v output that all the $(testglibc) files are being used
in the compile, none from /lib.

(I had to change the reference to ld-linux.so.2 in libc.so.6 so
that it would use the test glibc 2.2.1's ld.so, not the system
installed /lib/ld-linux.so.2.  I called this ld-linux.so.3
If there's any cleaner way to do this without damaging the system (i.e.,
preventing the system binaries based on glibc 2.1.x from running),
I'd like to know it, but I don't think this is the problem).

Any hints/ideas would be greatly appreciated.

thanks,

Ken







More information about the Libc-alpha mailing list