diff --git a/library/loader.c b/library/loader.c index 20e29e6b73f..556295256a8 100644 --- a/library/loader.c +++ b/library/loader.c @@ -220,18 +220,9 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr ) assert( size <= page_size ); - if (nt_descr->OptionalHeader.ImageBase) - { - addr = wine_anon_mmap( (void *)nt_descr->OptionalHeader.ImageBase, - page_size, PROT_READ|PROT_WRITE, MAP_FIXED ); - if (addr != (BYTE *)nt_descr->OptionalHeader.ImageBase) return NULL; - } - else - { - /* this will leak memory; but it should never happen */ - addr = wine_anon_mmap( NULL, page_size, PROT_READ|PROT_WRITE, 0 ); - if (addr == (BYTE *)-1) return NULL; - } + /* module address must be aligned on 64K boundary */ + addr = (BYTE *)((nt_descr->OptionalHeader.ImageBase + 0xffff) & ~0xffff); + if (wine_anon_mmap( addr, page_size, PROT_READ|PROT_WRITE, MAP_FIXED ) != addr) return NULL; dos = (IMAGE_DOS_HEADER *)addr; nt = (IMAGE_NT_HEADERS *)(dos + 1); diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 01f19f37c7d..7284f9bc37a 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -550,7 +550,7 @@ void BuildSpec32File( FILE *outfile ) fprintf( outfile, "#endif\n" ); fprintf( outfile, "asm(\".section \\\".text\\\"\\n\\t\"\n" ); fprintf( outfile, " \".align %d\\n\"\n", get_alignment(page_size) ); - fprintf( outfile, " \"" __ASM_NAME("pe_header") ":\\t.skip %ld\\n\\t\");\n", page_size ); + fprintf( outfile, " \"" __ASM_NAME("pe_header") ":\\t.skip 65536\\n\\t\");\n" ); fprintf( outfile, "#ifndef __GNUC__\n" ); fprintf( outfile, "}\n" ); fprintf( outfile, "#endif\n" );