public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* problem: symbol resolution in shared library
@ 2006-07-30 10:09 ÈîÑÇƽ
  0 siblings, 0 replies; 2+ messages in thread
From: ÈîÑÇƽ @ 2006-07-30 10:09 UTC (permalink / raw)
  To: gcc-help

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* problem: symbol resolution in shared library
@ 2006-07-30 10:09 ÈîÑÇƽ
  0 siblings, 0 replies; 2+ messages in thread
From: ÈîÑÇƽ @ 2006-07-30 10:09 UTC (permalink / raw)
  To: gcc-help

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-30 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-30 10:09 problem: symbol resolution in shared library ÈîÑÇƽ
  -- strict thread matches above, loose matches on Subject: below --
2006-07-30 10:09 ÈîÑÇƽ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).