ranjith kumar wrote: > 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??? You could certainly do it with ptrace by calling dlopen() in the context of the process. To figure out how, read the ptrace docs and inspect gdb source. > 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? ptrace can do this too. > 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?? It's just a naming convention that the tools use. > 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? It's generally faster not to use shared libraries. Your concerns cross a number of groups. binutils can help you for some of this. Andrew.