This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem: symbol resolution in shared library


Hi,
I am using SuseLinux9, I am facing the following problems, can you please help any body.

Problem 1:-
Main Program A:test2()   redefined private version: strcpy(), malloc().
Shared LibrayB:test1()   test2()
A:
strcpy() {...}
mlloc() {....}
test2() {...}
main() {  test1();}

B:test1 ,test2 in two translate unit.
test1() { test2();  strcpy(...) ; malloc(....);}
test2(){...}

A,B static linked.
I noticed that the call to test2 and malloc in test1,goto the define in A. and the call to
strcpy remain to the one in libc.so.
I have heart the malloc/free is using a func pointer to forward to the one in A (malloc hack) .
My question is : is  any reference to symbol in libc.so(except malloc/free) were permanently binded and other symbol(even the symbol exist in the same lib) delayed to load time ?

Problem 2:-
x) Similarly, if A, B dynamic linked(use dlopen(RTLD_NOW,RTLD_GLOBAL)),  the call to test2 in test1 goto the define in A.
y) but if I  delete the test2 definition in B, when use dlopen to load B, there will be error, reference to test2 can't be
resolution.
This confused me , I don't use -rdynamic in compile A, that means y) is correct,  but why x) present?


Thanks,

Stephen


ruan_yaping@pku.org.cn



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]