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]

Re: Initialising gnuwin DLLs


On 03-Feb-1998, Mikey <jeffdbREMOVETHIS@netzone.com> wrote:
> 
> Code for dll's written under cygwin32, that
> use the cygwin.dll libc services must initialize struct _reent.
> 
> Msvc apps that want to link in these dll's would
> have to 
> (A) start the link with cygwin's crt0.o (to correctly initialize libc)
> (B) link with libcygwin.a themselves (currently not possible except when using my patched ld.exe)

Why is step (B) necessary?  Is that just to satisfy some symbol references
in crt0.o?

> (C) call into each user dll to initialize it's copy of
> struct _reent with the values of the exe's copy of
> struct _reent.

Step (C) is not necessary if you initialize it in dll_entry().

> I thought for a while about retrofitting B18 with
> a crt0.o and dllcrt0.o that would handle this automatically.
> (yes you have to go through these same hoops
> when linking straight cygwin32 apps if you want to
> use cygwin.dll libc services in user dll's ;^)

Well, steps (A) and (B) are automatic for cygwin32 apps, and since step (C)
is not necessary, that doesn't leave any left-over hoops.

> >Could you not can you not 
> >intialise _reent from the DLL code - e.g in the
> >PROCESS_ATTACH routine - to initialise the Cygwin DLL from
> >our new DLL?
> 
> Nope thought about that, the dll would have to know the name of the
> .exe to get a handle to it, and have a callback function linked in to the .exe
> to get the correct values for the exe's _reent passed back to it.
> it wouldn't be that hard to write for special circumstances, but
> to me it looked like a mess to use as a general solution.

That's not necessary: as Sergei pointed out to me, the DLL can access
the EXE's reent data via `__imp_reent_data' using the usual dynamic
linking mechanism.  See the code from Makefile.DLLs in my other post.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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