overriding the dynamic library

Hi,

I wonder how can we override the dynamic library loaded by ld on start up.(dynamic linked application). so that linker uses the new library to find symbols.

Is it possible to do.

Cheers.

again !!!

I did this .....

i used dlopen to find the Link_map and lib handle of particular library loaded by ld.

this closed this lib using dlclose.

pointed the link_map to new library which i loaded using dlopen again(both libs are same but differ in some symbols) .

my apps does not complain or exit, but hanged forever.

You might consider hanging forever to be a complaint.

When a ld.so loads a library the fixups get set. What you did was remove the library to which all the fixups were pointing to.

can you please help me gettin details of this "fixups"

Cheers

First what is the platform? Is it ELF?

Anyhow, a shared library works by exporting a number of functions by name. A program linked to those libraries has dangling pointers to those functions that need to be resolved at load time. This is what ld.so does.

So when a program starts "printf" really does point at libc.so.4::printf etc. If you then unload libc.so.4 or whatever the printf function disappears but the fixed up pointers dont change.

Some platforms support you supplying a "shim" shared library that will go between the application and the original, some don't.