This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
inserting a library(*.so) into a runing processe's adress space
- From: "ranjith kumar" <ranjithproxy at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 30 Nov 2008 13:12:55 +0530
- Subject: inserting a library(*.so) into a runing processe's adress space
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.