On i386 macOS allowing the dynamic loader to do so results in eax and ebx being cleared.
Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/ntdll/unix/thread.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 97b191e1a5b..c337e672acc 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -140,6 +140,7 @@ static void start_thread( TEB *teb ) struct debug_info debug_info; BOOL suspend; ULONG_PTR cookie; + static void *pRtlUserThreadStart;
debug_info.str_pos = debug_info.out_pos = 0; thread_data->debug_info = &debug_info; @@ -151,7 +152,24 @@ static void start_thread( TEB *teb ) RtlActivateActivationContext( 0, info->actctx, &cookie ); RtlReleaseActivationContext( info->actctx ); } - signal_start_thread( info->entry, info->arg, suspend, RtlUserThreadStart, teb ); + + if (!pRtlUserThreadStart) + { + static const WCHAR ntdll[] = {'n','t','d','l','l','.','d','l','l',0}; + UNICODE_STRING mod_name; + ANSI_STRING fn_name; + HMODULE module; + void *addr; + + RtlInitUnicodeString( &mod_name, ntdll ); + RtlInitAnsiString( &fn_name, "RtlUserThreadStart" ); + + LdrGetDllHandle( NULL, 0, &mod_name, &module ); + LdrGetProcedureAddress( module, &fn_name, 0, &addr ); + pRtlUserThreadStart = addr; + } + + signal_start_thread( info->entry, info->arg, suspend, pRtlUserThreadStart, teb ); }
Huw Davies huw@codeweavers.com writes:
On i386 macOS allowing the dynamic loader to do so results in eax and ebx being cleared.
This should go through the import table, not the dynamic loader. Where do the registers get cleared?
On Mon, Jun 15, 2020 at 02:27:19PM +0200, Alexandre Julliard wrote:
Huw Davies huw@codeweavers.com writes:
On i386 macOS allowing the dynamic loader to do so results in eax and ebx being cleared.
This should go through the import table, not the dynamic loader. Where do the registers get cleared?
Ah, I see, eax isn't getting cleared, but it's being clobbered by __wine_spec_get_pc_thunk_eax .
Huw.
Huw Davies huw@codeweavers.com writes:
On Mon, Jun 15, 2020 at 02:27:19PM +0200, Alexandre Julliard wrote:
Huw Davies huw@codeweavers.com writes:
On i386 macOS allowing the dynamic loader to do so results in eax and ebx being cleared.
This should go through the import table, not the dynamic loader. Where do the registers get cleared?
Ah, I see, eax isn't getting cleared, but it's being clobbered by __wine_spec_get_pc_thunk_eax .
Ah right, macOS is still using PIC. Anyway, these import thunks should go away soon (the ultimate goal being for the Unix library to never implicitly call back into PE).