From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,e482f92c6f7365f8,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-12-04 06:53:10 PST Path: archiver1.google.com!news2.google.com!postnews1.google.com!not-for-mail From: moshel@yahoo.com (Moshe Livne) Newsgroups: comp.unix.tru64 Subject: dlopen() problem with symbols. very strange. Date: 4 Dec 2001 06:53:09 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 213.8.140.85 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1007477589 6976 127.0.0.1 (4 Dec 2001 14:53:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 4 Dec 2001 14:53:09 GMT Xref: archiver1.google.com comp.unix.tru64:6084 Hi, We noticed that when loading a dynamic library using dlopen on Tru64, if a symbol exist on both the library and the main, the symbols inside the library are resolved to the symbols in the main program. so, if I have a function a() in my main. I am loading a library that has function a() inside it as well, dynamically resolve b() (that calls a()) from the library, call it, it will call a() from the main. As I think I managed to confuse myself as well, I am including a super simple source that demonstrates the problem: dll_main.c: #include void a() { printf("in a in dll_main\n"); } void dll_stam() { printf("in dll_stam\n"); a(); } ********** compile with cc -c dll_main.c ld dll_main.o -shared -o dll.so -lc -lpthread ******************************************************** test.c: #include #include #include #include void (*dll_f)() ; void a() { printf("a in main!\n"); } main() { void *dll_handle ; dll_handle = dlopen("./dll.so" , RTLD_LOCAL) ; if ( dll_handle == NULL ) { printf("failed to load dll2.so, error is %s\n" , dlerror()) ; return(1) ; } dll_f = (void *)dlsym(dll_handle , "dll_stam") ; if ( dll_f == NULL ) { printf("failed to map dll_f\n") ; return(2) ; } (*dll_f)(); dlclose(dll_handle) ; return(0) ; } ******** compile with cc test.c -o test -lpthread the output I get: bash-2.01# ./test in dll_stam a in main! As you can see, the wrong a() was called. Thanks, Moshe