[Bug 50171] New: 32-bit PE entry point no longer called through BaseThreadInitThunk() assembly wrapper when Wine is built with LLVM MinGW
WineHQ Bugzilla
wine-bugs at winehq.org
Mon Nov 23 06:30:12 CST 2020
https://bugs.winehq.org/show_bug.cgi?id=50171
Bug ID: 50171
Summary: 32-bit PE entry point no longer called through
BaseThreadInitThunk() assembly wrapper when Wine is
built with LLVM MinGW
Product: Wine
Version: 5.22
Hardware: x86-64
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: kernel32
Assignee: wine-bugs at winehq.org
Reporter: focht at gmx.net
Distribution: ---
Hello folks,
while investigating bug 28332 I found a regression introduced by
https://source.winehq.org/git/wine.git/commitdiff/0c631ebb2354334eaf309bc0765d3283654cf902
("kernel32: Build with msvcrt.").
With 32-bit kernel32 cross-compiled to PE format, the stack on app entry point
is now aligned to 16-byte boundary. This makes the game from bug 28332
"magically" work while the 32-bit non-PE kernel32 causes a crash (expected due
to Wine quartz bug).
https://bugs.winehq.org/show_bug.cgi?id=28332#c17
The stack alignment from entry point, including selected functions from the
call chain up to alloca() caller.
--- snip ---
EIP | PE ESP | non-PE ESP | comment
0x42D5E3 | 0x31FF60 +00 | 0x31FF44 +00 | entry point main thread
0x42A720 | 0x31FEA0 +C0 | 0x31FE84 +C0 |
0x4200C5 | 0x31FE54 +4C | 0x31FE38 +4C |
0x40D8B7 | 0x31FE4C +08 | 0x31FE30 +08 |
0x40D570 | 0x31FE48 +04 | 0x31FE2C +04 |
0x40D6FF | 0x31FB1C +32C | 0x31FB00 +32C | before alloca(0)
0x40D704 | 0x31FB10 +0C | 0x31FB00 +00 | after alloca(0)
--- snip ---
It seems in 32-bit PE kernel32.dll, the thread entry point is called through
the fastcall "C" version of BaseThreadInitThunk() instead of the fastcall
assembly wrapper.
32-bit non-PE kernel32.dll.so works correctly, the thread entry point is called
through __fastcall_BaseThreadInitThunk() assembly wrapper.
https://source.winehq.org/git/wine.git/blob/bedfb9cae224a369efa4588332a5518dbee57035:/dlls/kernel32/thread.c#l36
--- snip ---
36 #ifdef __i386__
37 __ASM_STDCALL_FUNC( __fastcall_BaseThreadInitThunk, 12,
38 "pushl %ebp\n\t"
39 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
40 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
41 "movl %esp,%ebp\n\t"
42 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
43 "pushl %ebx\n\t"
44 __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
45 "movl 8(%ebp),%ebx\n\t"
46 /* deliberately mis-align the stack by 8, Doom 3 needs
this */
47 "pushl 4(%ebp)\n\t" /* Driller expects readable
address at this offset */
48 "pushl 4(%ebp)\n\t"
49 "pushl %ebx\n\t"
50 "call *%edx\n\t"
51 "movl %eax,(%esp)\n\t"
52 "call " __ASM_STDCALL( "RtlExitUserThread", 4 ))
53 #endif
54
55 /***********************************************************************
56 * BaseThreadInitThunk (KERNEL32.@)
57 */
58 void __fastcall BaseThreadInitThunk( DWORD unknown, LPTHREAD_START_ROUTINE
entry, void *arg )
59 {
60 RtlExitUserThread( entry( arg ) );
61 }
--- snip ---
https://source.winehq.org/git/wine.git/blob/bedfb9cae224a369efa4588332a5518dbee57035:/dlls/kernel32/kernel32.spec#l185
--- snip ---
185 @ stdcall -fastcall BaseThreadInitThunk(long ptr ptr)
--- snip ---
cross-toolchain used: LLVM MinGW 20201020 with LLVM stable 11.0.0
https://github.com/mstorsjo/llvm-mingw
https://github.com/mstorsjo/llvm-mingw/releases
https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-ucrt-ubuntu-18.04.tar.xz
$ wine --version
wine-5.22
Regards
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list