Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

linking in a custom libc

1,034 views
Skip to first unread message

Federico David Sacerdoti

unread,
May 25, 2001, 6:59:59 PM5/25/01
to

I would like to link in a version of the glibc shared library with debugging
symbols in it. I have sucessfully compiled such a version of the library,
libc-2.2.2.so. But since the linker automatically links in the standard libc
without being told, I am having problems redirecting it to my freshly compiled
version.

Is there a config file that the linker reads to know what libraries to link in
by default? I have tried to explicitly link in -lc but that didn't seem to
work, and neither did messing with /etc/ld.so.conf in Linux.

I tried moving my new libc library with the debugging symbols into the master
location in /lib, but since I didn't want to loose my old one I renamed it
first. Bad idea. The mv command stopped working along with everything else and
the machine basically came to a halt. I didn't think to use rpm which is
statically linked to force a reinstall of the glibc pakage, but whatever,
I have a Tom's rescue disk.

Thanks
Dave

Joe Durusau

unread,
May 26, 2001, 10:44:22 AM5/26/01
to
In general, name your lib something else,
tell gcc to link it in, and use something like -nostdlib
to tell gcc to bypass the standard lib(s). You don't
EVER want to mess with the std libc, as you now know.
Note: -nostdlib is from a vague memory, you might need to look
at the gcc docs, or if you want to go to a lot of trouble,
use gcc -v to see what it does, then use gcc -c to compile,
and ld to link. Just be prepared for a loe of heartburn.

A better solution might be to put an abort in your
prog somewhere, and use gdb to analyze the mess.

Speaking only for myself,

Joe Durusau

Ken Whaley

unread,
Jun 7, 2001, 2:07:28 PM6/7/01
to
Here's a makefile with the magic required to do this. Someone
should add this to the glibc FAQ/HowTo, as the current ones do
not tell you everything you must do to get this to work. This
is for a shared build, if you want a static build I think all
you have to do is add -static to the link line, but I haven't
tested that.

testglibc = /usr/local/glibc2.2.3
gcc = gcc

.PHONY: all
all: hello

hello: hello.o
$(gcc) -Wl,--dynamic-linker=$(testglibc)/lib/ld-linux.so.2 \
-B$(testglibc)/lib/ \
-Wl,-rpath=$(testglibc)/lib \
$< -o $@

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

clean:
rm -f hello hello.o


"Joe Durusau" <dur...@bellsouth.net> wrote in message
news:3B0FC146...@bellsouth.net...

0 new messages