Rémi Bernon : winegcc: Align sections in PE files to page size.

Alexandre Julliard julliard at winehq.org
Thu Jul 23 16:36:58 CDT 2020


Module: wine
Branch: master
Commit: e36bed4f37de27d38494ece999c5a63adf4eb996
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e36bed4f37de27d38494ece999c5a63adf4eb996

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon Jul 13 19:49:22 2020 +0200

winegcc: Align sections in PE files to page size.

This makes sure it will be possible to mmap the section directly instead
of having to copy them. It then also makes perf able to figure the code
origin for Wine modules.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/psapi/tests/psapi_main.c | 25 ++++++++++++-------------
 tools/winegcc/winegcc.c       |  3 +++
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index da7524dd60..c92423ee19 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -791,7 +791,7 @@ free_page:
 }
 
 static void check_QueryWorkingSetEx(PVOID addr, const char *desc, DWORD expected_valid,
-    DWORD expected_protection, DWORD expected_shared, BOOL todo, BOOL todo_shared)
+                                    DWORD expected_protection, DWORD expected_shared, BOOL todo)
 {
     PSAPI_WORKING_SET_EX_INFORMATION info;
     BOOL ret;
@@ -814,7 +814,6 @@ static void check_QueryWorkingSetEx(PVOID addr, const char *desc, DWORD expected
     ok(info.VirtualAttributes.LargePage == 0, "%s expected LargePage=0 but got %u\n",
         desc, info.VirtualAttributes.LargePage);
 
-    todo_wine_if(todo_shared)
     ok(info.VirtualAttributes.Shared == expected_shared || broken(!info.VirtualAttributes.Valid) /* w2003 */,
         "%s expected Shared=%u but got %u\n", desc, expected_shared, info.VirtualAttributes.Shared);
     if (info.VirtualAttributes.Valid && info.VirtualAttributes.Shared)
@@ -838,44 +837,44 @@ static void test_QueryWorkingSetEx(void)
     }
 
     addr = GetModuleHandleA(NULL);
-    check_QueryWorkingSetEx(addr, "exe", 1, PAGE_READONLY, 1, FALSE, TRUE);
+    check_QueryWorkingSetEx(addr, "exe", 1, PAGE_READONLY, 1, FALSE);
 
     ret = VirtualProtect(addr, 0x1000, PAGE_NOACCESS, &prot);
     ok(ret, "VirtualProtect failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "exe,noaccess", 0, 0, 1, FALSE, TRUE);
+    check_QueryWorkingSetEx(addr, "exe,noaccess", 0, 0, 1, FALSE);
 
     ret = VirtualProtect(addr, 0x1000, prot, &prot);
     ok(ret, "VirtualProtect failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "exe,readonly1", 0, 0, 1, TRUE, TRUE);
+    check_QueryWorkingSetEx(addr, "exe,readonly1", 0, 0, 1, TRUE);
 
     *(volatile char *)addr;
     ok(ret, "VirtualProtect failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "exe,readonly2", 1, PAGE_READONLY, 1, FALSE, TRUE);
+    check_QueryWorkingSetEx(addr, "exe,readonly2", 1, PAGE_READONLY, 1, FALSE);
 
     addr = VirtualAlloc(NULL, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     ok(addr != NULL, "VirtualAlloc failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "valloc", 0, 0, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc", 0, 0, 0, FALSE);
 
     *(volatile char *)addr;
-    check_QueryWorkingSetEx(addr, "valloc,read", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,read", 1, PAGE_READWRITE, 0, FALSE);
 
     *(volatile char *)addr = 0x42;
-    check_QueryWorkingSetEx(addr, "valloc,write", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,write", 1, PAGE_READWRITE, 0, FALSE);
 
     ret = VirtualProtect(addr, 0x1000, PAGE_NOACCESS, &prot);
     ok(ret, "VirtualProtect failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "valloc,noaccess", 0, 0, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,noaccess", 0, 0, 0, FALSE);
 
     ret = VirtualProtect(addr, 0x1000, prot, &prot);
     ok(ret, "VirtualProtect failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "valloc,readwrite1", 0, 0, 0, TRUE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,readwrite1", 0, 0, 0, TRUE);
 
     *(volatile char *)addr;
-    check_QueryWorkingSetEx(addr, "valloc,readwrite2", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,readwrite2", 1, PAGE_READWRITE, 0, FALSE);
 
     ret = VirtualFree(addr, 0, MEM_RELEASE);
     ok(ret, "VirtualFree failed with %d\n", GetLastError());
-    check_QueryWorkingSetEx(addr, "valloc,free", FALSE, 0, 0, FALSE, FALSE);
+    check_QueryWorkingSetEx(addr, "valloc,free", FALSE, 0, 0, FALSE);
 }
 
 START_TEST(psapi_main)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 29c1b0549d..274f93f40f 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -521,6 +521,9 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
         if (opts->debug_file && strendswith(opts->debug_file, ".pdb"))
             strarray_add(link_args, strmake("-Wl,-pdb,%s", opts->debug_file));
 
+        if (!try_link( opts->prefix, link_args, "-Wl,--file-alignment,0x1000" ))
+            strarray_add( link_args, "-Wl,--file-alignment,0x1000" );
+
         strarray_addall( link_args, flags );
         return link_args;
 




More information about the wine-cvs mailing list