Changeset 19433


Ignore:
Timestamp:
Jul 18, 2002, 1:52:56 PM (23 years ago)
Author:
achimha
Message:

documented PE DLL memory layout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/kernel32/windllpeldr.cpp

    r16576 r19433  
    1 /* $Id: windllpeldr.cpp,v 1.9 2001-06-15 09:42:48 bird Exp $ */
     1/* $Id: windllpeldr.cpp,v 1.10 2002-07-18 11:52:56 achimha Exp $ */
    22
    33/*
     
    3333#define DBG_LOCALLOG    DBG_windllpeldr
    3434#include "dbglocal.h"
     35
     36//******************************************************************************
     37// Design information on PE DLL memory layout - AH 2002-07-18
     38//
     39// We are currently using (high) private memory for all PE objects, including the
     40// read/execute code segments, constant data segments and global data segments.
     41// Global data segments might not be implemented correctly at all as we've never
     42// encountered any applictions making use of them. Therefore we are actually
     43// wasting memory when running multiple processes using the same PE DLLs.
     44//
     45// There are several reasons for this design decisions. Both OS/2 (LX) and
     46// Windows NT put all DLL segments into the shared arena. What they do for
     47// instance data is map it for each process to read-only pages initially. When
     48// a write attempt is made by a process, an exception will be triggered. This
     49// makes the operating system to copy the data to a new page that is read/write
     50// and change the page table of the process to map the linear process in the
     51// shared arena to private memory (this is called "copy-on-write").
     52// Even though an application is not guaranteed any virtual address for instance
     53// data segments, they always end up in the shared region and the virtual addreses
     54// are contiguous. An application could therefore make nasty assumptions.
     55// Unfortunately, it is not possible for us from ring 3 to replicate the behavior
     56// for our PE loader. While we can make the page read only and catch the
     57// exception, we have no method to remap the pages to private memory.
     58//
     59// One solution would be to create another reagion with the private region,
     60// i.e. define some address space range as reserved in Odin (configurable to
     61// workaround issues with certain PE images requiring those addresses). We
     62// could then load the instance data segments of PE DLLs into this private
     63// memory arena and still guarantee identical virtual addresses for each
     64// process.
     65//
     66// While the above method should work fine (assuming an application does not
     67// make any nasty assumptions), there is one major problem. If we enable the
     68// PE on-demand loader (i.e. the mmap loads each page from the PE file when
     69// it is accesses for the first time - very much like NT), then we would have
     70// nasty concurrency issues. A process could access a page for the first time
     71// and the exception is triggered. We commit the page read the data in using
     72// a call to DosRead. If the very same page is accessed from a different
     73// process after we have committed it but before we have finished the DosRead,
     74// we would run into problems. Unfortunately, there does not seem to be any
     75// solution for this.
     76//
     77// The bottomline is that we put everything into private memory and accept the
     78// drawback of wasting memory.
     79//******************************************************************************
    3580
    3681
Note: See TracChangeset for help on using the changeset viewer.