From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson) Subject: Re: Initialising gnuwin DLLs 3 Feb 1998 22:52:36 -0800 Message-ID: <19980204163912.29355.cygnus.gnu-win32@mundook.cs.mu.OZ.AU> References: <199802031457 DOT OAA16133 AT jaguar DOT rpms DOT ac DOT uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Matthew Brett , gnu-win32 AT cygnus DOT com On 03-Feb-1998, Mikey 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 | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".