overriding the dynamic library


 
Thread Tools Search this Thread
Top Forums Programming overriding the dynamic library
# 1  
Old 05-28-2007
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.
# 2  
Old 05-28-2007
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.
# 3  
Old 05-28-2007
Quote:
Originally Posted by Raom
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.
# 4  
Old 05-29-2007
Quote:
Originally Posted by porter
When a ld.so loads a library the fixups get set.
can you please help me gettin details of this "fixups"


Cheers
# 5  
Old 05-29-2007
Quote:
Originally Posted by Raom
can you please help me gettin details of this "fixups"
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.

Last edited by vino; 05-29-2007 at 05:30 AM.. Reason: disable smilies
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Specifying dynamic library path to linker at compile time

I would like to compile a binary that doesnot depend on LD_LIBRARY_PATH as this binary will be setuid to owner and used by other users and since setuid doesnot support LD_LIBRARY_PATH making it independent of LD_LIBRARY_PATH would be great. But I am not able to specify the path of the shared... (1 Reply)
Discussion started by: waavman
1 Replies

2. Programming

problem in dynamic library*.so

hello I apologize if my question bothers you I work on a code developed in C + + which worked well on mac os, this code will help create libraries *.so from *.cc and *.h I used this as flags:CXXFLAGS = -g -O2 -fPIC -Wall -ldl -D_GNU_SOURCE ,CXX := g++ and $(CXX)-shared -o $(LIBNAME) $(CLIBLIB)... (0 Replies)
Discussion started by: pheapc
0 Replies

3. Programming

Dynamic library load with dlopen

Hi, I created two library libsum.so and libproduct.so. In the libproduct.so is defined function "product" that use function "sum" defined in libsum.so. So libproduct depends on libsum. In main function I called product function by a dlopen request. Unfortunaly, when I execute program I have an... (5 Replies)
Discussion started by: shade82
5 Replies

4. UNIX for Dummies Questions & Answers

Problem with shared dynamic library files

I am having a major problem. Most of the commands that i am running on my centos 5 system is giving the error of type: <dynamic shared library file>:open failed: No such file or directory For example: libgcc_s.so.1: open failed: No such file or directory How can i solve this? (6 Replies)
Discussion started by: proactiveaditya
6 Replies

5. UNIX for Dummies Questions & Answers

How to obtain list of object files in a shared (dynamic) library?

How can I simply obtain a list of the object files in a shared (dynamic) library. I am looking for the equivalent of "ar -t <lib>" for archived (static) libraries. Thanks in advance. :rolleyes: ---------- Post updated at 01:47 PM ---------- Previous update was at 12:16 PM ---------- The... (1 Reply)
Discussion started by: chatieremerrill
1 Replies

6. Programming

C++ overriding Vs hiding

class B { public: void fns(void){//base def;} }; class D:public B { public: void fns(void) {//new def;} }; I was thinking the above is overriding but somewhere else i found the above is just hiding.Only virtual functions can be considered as overriding? This is the exact statement ... (1 Reply)
Discussion started by: johnbach
1 Replies

7. Shell Programming and Scripting

Overriding PATH

Hello, I'm using Sun solaris . I'm trying to override the environmental variable in my script, however when I execute the script, the PATH whatever being set in .profile is taking precedence. I have done the sanity checks like order of my entry in path, permissions for the user etc., To... (1 Reply)
Discussion started by: brainyoung
1 Replies

8. Programming

loading a dynamic library in linux

is there a way to load a dynamic library in linux? I know tht in AIX u can do it using the loadAndInit() function. Please guide me (2 Replies)
Discussion started by: jacques83
2 Replies

9. Linux

load dynamic and shared library in kernel

hi how can i load dynamic or shared library in linux kernel modules . mtaghiloo@yahoo.com (0 Replies)
Discussion started by: mtaghiloo
0 Replies

10. Programming

how to auto load a dynamic library

hi, every body. i have in trouble that how to load a dynamic library by hand. for example, i know how to generate a dynamic library and how to link a dynamic library in makefile. generate a dynamic library: add -dy -G behind cc link a dynamic library in makefile: add -dy -Bdynamic behind cc... (0 Replies)
Discussion started by: subrain
0 Replies
Login or Register to Ask a Question