From: Paul S. <pf...@us...> - 2000-12-29 07:47:52
|
Hello Danny, Danny Smith wrote on Wednesday, December 06, 2000: [] DS> There appear to be some fishhooks however. Correct me if I'm wrong but DS> it appears that when symbols are derived from static lib and DS> re-exported in dll they are often marked with DATA tag, whether they DS> are DATA or not. If this is designed behaviour, what is the point of DS> exporting them? The three examples cited above worked because the DS> client exes only tried to import legitimate exports. DS> Here is a C example of what I mean, using libiberty.a: DS> /* cdll.c */ DS> #include <libiberty.h> DS> #include <stdio.h> DS> void my_pwd(){ DS> char* dll_pwd=getpwd(); DS> printf("pwd from dll: %s \n", dll_pwd); DS> return; DS> } DS> /* test.c */ DS> #include <libiberty.h> DS> void my_pwd(); DS> int main(){ DS> char* liberty_pwd=getpwd(); DS> my_pwd(); DS> return 1; DS> } DS> Using this script DS> cc -c cdll.c DS> gcc -shared -Wl,--out-implib,libmycdll.a,--output-def,mycdll.def \ DS> -o mycdll.dll cdll.o -liberty DS> gcc -c main.c DS> rem This works DS> gcc -o test1.exe main.o -L. -lmycdll -liberty DS> test1 DS> rem This doesn't, even though getpwd is exported from dll DS> rem The auto-import warning tells us why DS> gcc -o test2.exe main.o -L. -lmycdll DS> test2 DS> The ouput-def looks like this: DS> EXPORTS DS> _xexit_cleanup @1 DATA DS> getpwd @2 DATA DS> my_pwd @3 DS> xcalloc @4 DS> xexit @5 DATA DS> xmalloc @6 DATA DS> xmalloc_set_program_name @7 DS> xrealloc @8 [] I cannot reproduce this problem with all the latest binutils. I have EXPORTS _xexit_cleanup @1 DATA getpwd @2 my_pwd @3 xcalloc @4 xexit @5 xmalloc @6 xmalloc_failed @7 xmalloc_set_program_name @8 xrealloc @9 and both cases build successfully. Btw, there's no getpwd() in the libiberty as distributed with Mumit's gcc, so I'll replace it with latest from binutils. If you'll answer, please cc: to me, I seem to have mail routing probs with pf...@us..., from which I subscribed. DS> Cheers DS> Danny -- Paul Sokolovsky, IT Specialist http://www.brainbench.com/transcript.jsp?pid=11135 |