Why does windows have such probs with dynamically loaded libs?

Linda Walsh cygwin@tlinx.org
Tue May 31 23:18:00 GMT 2011


Christopher Faylor wrote:
> If you have an application which uses a lot of dlls then best practice
> for Windows DLLs is to build them with unique load addresses.  Barring
> that you could rebase them with cygwin's rebase or rebaseall utilties.
> Setting unique base addresses will actually cause your application to
> load slightly faster whether you use Cygwin or not.
----

Other than the stock answer of poor design, it seems loading a
dynamically linked library at run-time shouldn't be a difficult task.

1) find out # of 'segments' and size.

2) allocate space somewhere 'unused' in the address space. (malloc seems
to usually work for this)

3) load contents

4) get the symbol(s) needed and add them to the loaded address, and pass
that back to the dlopen call for patching it's call tables so future
calls can call the libs directly.

5) enjoy. ... 

So why all these problems with conflicting load addresses?

When Cygwin forks, how different is it from linux (other than stock
answer of 'alot'),  i.e.  Does it create a new process and load the same
static libs in, then have problems with dynamically loaded libs because
they aren't recorded in the static binary?

Does cygwin actually copy, or attempt to setup COW pages that are not
from static libs?   If so, wouldn't that catch dynamically loaded libs?

This may be complete insanity, but given the low level of support of MS's
own Unix subsystem, I wonder if they might be persuaded (if it was
desired) to lend more help or hooks for cygwin to do its magic reliably.  

It seems like it would be a win for MS -- since many Windows users (not
just 'end', but corporate as well) often make use of Cygwin -- you'd
think MS might think kindly toward efforts to help Cygwin work well with
current versions of windows...but then my name is given as an example in
some political dictionaries as an example under 'naïve'  ;-/...



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list