[Python-Dev] microsoft dlls apparently don't support data. implications: PyAPI functions required to access data across modules.

Curt Hagenlocher curt at hagenlocher.org
Mon Jan 26 08:15:01 CET 2009

On Sun, Jan 25, 2009 at 10:45 AM, Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
> from http://en.wikipedia.org/wiki/Dynamic-link_library:
> "Third, dynamic linking is inherently the wrong model for paged memory
> managed systems. Such systems work best with the idea that code is
> invariant from the time of assembly/compilation on.
> ........... Data references do not need to be so vectored because
>  DLLs do not share data."

That section ("The case against DLLs") should probably be ignored.  It
appears to have been written by a single individual with a particular
axe to grind.  Much of what it contains is opinion rather than fact,
and some of its facts are downright inaccurate -- at least by my

I haven't thought much about any of this in well over ten years, but
here's what I remember:

The reason for the vectored importing of function addresses is
strictly performance -- it means that you only need to fixup one
location with the address of the target function instead of each
location in the code.  This also has obvious advantages for paging.
But this may very well be a feature of the linker rather than the
operating system; I imagine the loader will happily fixup the same
address multiple times if you ask it to.

There are differences between importing code and importing data: the
code produced by the compiler for calling a function does not depend
on whether or not that function is defined in the current module or in
a different one -- under x86, they're both just CALL instructions.
But when accessing data, addresses in the current module can be used
directly while those in a different module must be indirected -- which
means that different opcodes must be generated.  I don't know if it's
up-to-date, but the page at
http://sourceware.org/binutils/docs/ld/WIN32.html suggests some ways
of dealing with this for cygwin/mingw.  Look for the section entitled
"automatic data imports".

If you have specific questions related to DLL or loader behavior under
Windows, feel free to ping me off-list.  I can't guarantee that I can
provide an answer, but I may be able to point you in a particular

Curt Hagenlocher
curt at hagenlocher.org

More information about the Python-Dev mailing list