Hi, the below patches are supposed to help with an annoying DLL problem on Cygwin. Since Windows doesn't provide a native fork implementation, Cygwin emulates fork by creating a new process and overwrites the forkee's memory with data from the forker. This method only works if the OS doesn't randomly decide where to put DLLs into the memory of the new process. However, DLLs are linked with a default image base of 0x10000000, thus requiring the runtime loader to relocate the DLLs to some other memory base, which sometimes results in different locations for DLLs in forker and forkee. This in turn breaks fork.
One way to ease the pain is to rebase the DLLs manually, using a tool called rebase. If all DLLs in a Cygwin installation are based on different memory locations the problem is much less frequently observed, next to never. The disadvantage of this approach is that it requires the manual intervention. What we're trying to do now in Cygwin is this: Binutils' ld allows to create pseudo-random image base addresses by giving the command line option --enable-auto-image-base. It chooses the image base for the DLL by creating a hash value from the DLL's name. This lowers the chance of DLL collisions a lot, and manual rebasing is most of the time not necessary anymore. The below two patches change Makefile.shared so that the shared libs on Cygwin are built with --enable-auto-image-base. The first patch is against current CVS, the second patch is against the 0.9.8 release. I hope both are ok for inclusion. Thanks in advance, Corinna === Current CVS === Index: Makefile.shared =================================================================== RCS file: /home/cvs/cvsroot/src/openssl/Makefile.shared,v retrieving revision 1.63 diff -p -u -r1.63 Makefile.shared --- Makefile.shared 25 Mar 2007 15:20:35 -0000 1.63 +++ Makefile.shared 29 Mar 2007 09:34:02 -0000 @@ -255,7 +255,7 @@ link_o.cygwin: SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \ ALLSYMSFLAGS='-Wl,--whole-archive'; \ NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ - SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-s,-Bsymbolic"; \ + SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-s,-Bsymbolic"; \ $(LINK_SO_O) link_a.cygwin: @ $(CALC_VERSIONS); \ @@ -273,8 +273,7 @@ link_a.cygwin: extras="$$extras rc.o"; \ ALLSYMSFLAGS='-Wl,--whole-archive'; \ NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ - base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \ - SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \ + SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \ [ -f apps/$$dll_name ] && rm apps/$$dll_name; \ [ -f test/$$dll_name ] && rm test/$$dll_name; \ $(LINK_SO_A) || exit 1; \ === 0.9.8 === --- Makefile.shared 2007-01-18 17:05:21.540291400 +0100 +++ Makefile.shared 2007-03-29 11:38:48.552858700 +0200 @@ -242,7 +242,7 @@ link_o.cygwin: SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \ ALLSYMSFLAGS='-Wl,--whole-archive'; \ NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ - SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \ + SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \ $(LINK_SO_O) link_a.cygwin: @ $(CALC_VERSIONS); \ @@ -253,8 +253,7 @@ link_a.cygwin: SHLIB_SOVER=-$(LIBVERSION); \ ALLSYMSFLAGS='-Wl,--whole-archive'; \ NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ - base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \ - SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \ + SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \ [ -f apps/$$SHLIB$$SHLIB_SUFFIX ] && rm apps/$$SHLIB$$SHLIB_SUFFIX; \ [ -f test/$$SHLIB$$SHLIB_SUFFIX ] && rm test/$$SHLIB$$SHLIB_SUFFIX; \ $(LINK_SO_A) || exit 1; \ === end === -- Corinna Vinschen Cygwin Project Co-Leader Red Hat ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]