[OT] Windows DLL and shared memory (was: Die GNU autotools)

[OT] Windows DLL and shared memory (was: Die GNU autotools)

Shachar Shemesh shachar at shemesh.biz
Wed Jan 12 17:26:54 IST 2011


On 12/01/11 17:11, Oleg Goldshmidt wrote:
>
> I admit I am not up-to-date (but my recollection refers to years ago, 
> too). Windows DLLs were not equivalent to UNIX/Linux shared libraries 
> - they contained "relocatable" and not "position-independent" code, 
> and each process had its own copy mapped into memory (yes, runtime 
> memory).
Not exactly.

It is true that Windows DLLs are relocatable (rather than position 
independent), but that does not necessarily mean that are relocated. 
Each DLL comes with a recommended load address (in virtual memory), and 
if no collision with another DLL happens, that is where it will be 
loaded. If that is the case, Windows will happily share the same 
physical memory for all copies of the text and read only segments of the 
DLL. When compiling a single project, it is fairly easy to make sure 
that all DLLs fit into memory together without being relocated.

Even on the rare occasion that the DLL does need to be relocated, the 
Windows kernel is aware that this page, while faulted, can be discarded 
and later recalculated from the file. As such, it is a candidate to be 
released from memory, despite being "changed" compared to the image on disk.

Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com




More information about the Linux-il mailing list