This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

a dll example


Hi:

I have an example dll problem that builds with gcc in
the attachment.

It works with vc++ and gcc in linux, but not gcc in
cygwin.  I suppose I could be missing something, or
perhaps we can't just get there from here.  Either way
I would be interested in peoples comments on what I am
trying to do.  

Here is the readme in the zip file to help you decide
whether you want to go further.  Thanks! 

craig.stevenson@ieee.org Fri May 19 14:08:05 2000
Craig Stevenson 
Notes on differences between gcc on cygwin and linux.
-------------------------------------------------------------------------------

This is an example of a difference in dynamic library
structure in cygwin and
linux under gcc.  To build it type 'make' and run
'main'.

We have 3 dll's (A, B, and C) and an executable.  A
and B both use C.
The main executable uses A and B.

There is some global data in C.c accessed by some
functions.
A sets the global data and B reads it out.  

Under linux, this works like the champ.

Under cygwin, the address of the global data is
different for each dll,
A and B.  This is naturally undesirable.  Setting
appropriate declspecs on 
the global data does not change the behavior.

I compiled up the example under VC++ (not included
here) and it worked fine.

I'm not including the vc++ portion of the work, since
that does not seem
appropriate for this forum.  But if someone is
interested I'd be happy to
bundle it along.

Notable is the difference between DLLMain calls.  
There is no attempt to detach on the cygwin side, and
it appears to be 
attempting multithreading for some reason.

Also notable is that the -shared and -export-dynamic
flags do not seem to be
honored.  I'm running a recent cygwin 1.1.

<begin trace from gcc>

 DLLMain(C) hInst = 0x654c0000 reason =
DLL_PROCESS_ATTACH

 DLLMain(A) hInst = 0x66000000 reason =
DLL_PROCESS_ATTACH
 DLLMain(A) hInst = 0x66000000 reason =
DLL_THREAD_ATTACH

 DLLMain(C) hInst = 0x654c0000 reason =
DLL_THREAD_ATTACH

 DLLMain(B) hInst = 0x60600000 reason =
DLL_THREAD_ATTACH

 DLLMain(C) hInst = 0x2510000 reason =
DLL_THREAD_ATTACH


 DLLMain(C) hInst = 0x2510000 reason =
DLL_PROCESS_ATTACH

 DLLMain(B) hInst = 0x60600000 reason =
DLL_PROCESS_ATTACH
-> main()
-> DoA()
SetC(): &iC1 = 0x654c2000
GetC(): &iC1 = 0x654c2000
GetC() = 7
<- DoA()
-> DoB()
GetC(): &iC1 = 0x2512000
GetC() = 0
<- DoB()
<- main()
<end trace from gcc>

<begin trace from vc++>

 DLLMain(C) hInst = 00230000 reason =
DLL_PROCESS_ATTACH

 DLLMain(B) hInst = 10000000 reason =
DLL_PROCESS_ATTACH

 DLLMain(A) hInst = 00270000 reason =
DLL_PROCESS_ATTACH
-> main()
-> DoA()
SetC(): &iC1 = 0025E3F0
GetC(): &iC1 = 0025E3F0
GetC() = 7
<- DoA()
-> DoB()
GetC(): &iC1 = 0025E3F0
GetC() = 7
<- DoB()
<- main()

 DLLMain(A) hInst = 00270000 reason =
DLL_PROCESS_DETACH

 DLLMain(B) hInst = 10000000 reason =
DLL_PROCESS_DETACH

 DLLMain(C) hInst = 00230000 reason =
DLL_PROCESS_DETACH
<end trace from vc++>


=====
-- Craig Stevenson
-- Home Page: http://www.sdc.org/~craigs/
-- Recently computed: The 200 billionth digit of pi is 2.

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

dll_test.zip

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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