[2/2] kernel32: force 4096 byte page alignment.

Tijl Coosemans tijl at FreeBSD.org
Tue Feb 3 03:16:33 CST 2015

On Mon, 02 Feb 2015 22:20:57 +0200 David Naylor <dbn at freebsd.org> wrote:
> FreeBSD prefers to use a 0x200000 (super) page alignment however this causes
> the image base to be displaced from the requested 0x7b800000.  Forcing a
> smaller page size ensures FreeBSD can place the image starting at 0x7b800000.

Just to clarify, the output of "readelf -l kernel32.dll.so" gives this:

  Type Offset   VirtAddr   PhysAddr   FileSiz  MemSiz   Flg Align
  LOAD 0x000000 0x7b800000 0x7b800000 0x0c9e74 0x0c9e74 R E 0x200000
  LOAD 0x0ca000 0x7baca000 0x7baca000 0x1a7eb0 0x1a8550 RW  0x200000

The segments have an alignment of 0x200000 bytes.  This places the first
segment at 0x7b800000 and the second at 0x7ba00000+Offset.  With a
MemSiz of 0x1a8550 this pushes the second segment over 0x7bc00000 where
ntdll has been mapped already so loading kernel32 at 0x7b800000 fails.

The patch forces a smaller alignment so the second segment fits below

More information about the wine-devel mailing list