inserting a library(*.so) into a runing processe's adress space

ranjith kumar ranjithproxy@gmail.com
Sun Nov 30 07:54:00 GMT 2008


Hi,

I have c file (1.c) and a sharedlibrary file (libmy.so).
I know that using dlopen() in 1.c we can insert libmy.so into address
space of 1.c and call any function defined in that library.

1)My question is how to insert a library into a running process when
it doen not contain dlopen() inside its source code???
 I have little bit information about this. By adjusting heap area of
the process we can insert a call to dlopen(). I want to know
  how to access heap area of  a running process and insert a call to
dlopen(). I know about ptrace() can be used to stop a process and look
inside its code.
 Any links or material please.
Is there any other method to insert a library into a process???

2) If a  library is inserted in a process dynamically  how and who
will replace a function call ie)  jump address(in the context  of
binary code) with correct address?

3) I know how to produce a lib******.so files.
    example: gcc -shared -o libmy.so my.o
But what is the significanc of 'lib' prefix in libmy.so
I saw some files(.so) without 'lib' prefix(for example  my.so).
 How to produce such files and what is the difference between libmy.so
and my.so??

4) I produced an executable by
     gcc -o explample1 1.o lib.o
   and another by
 gccc -o exmple2 1.o libmy.so (libmy.so is made from lib.o)
Which will run faster example1 or example2? why?

I am sorry if 1st question is beyond the scope of gcc(compilers).
Please suggest any mailing lists I can subscribe to ask such
questions.
Thanks in advance.



More information about the Gcc-help mailing list