ntdll: Support the Android Java %fs register being a GDT selector.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-12-08 12:46:17 +01:00
parent 2bf8293e8f
commit 6ddd6e836c
3 changed files with 6 additions and 1 deletions

View File

@ -1671,6 +1671,7 @@ static jstring wine_init_jni( JNIEnv *env, jobject obj, jobjectArray cmdline, jo
{
unsigned short java_fs;
__asm__( "mov %%fs,%0" : "=r" (java_fs) );
if (!(java_fs & 4)) java_gdt_sel = java_fs;
__asm__( "mov %0,%%fs" :: "r" (0) );
start_main_thread();
__asm__( "mov %0,%%fs" :: "r" (java_fs) );

View File

@ -258,9 +258,11 @@ static inline void wrap_java_call(void) { __asm__( "mov %0,%%fs" :: "r" (java_
static inline void unwrap_java_call(void) { __asm__( "mov %0,%%fs" :: "r" (orig_fs) ); }
static inline void init_java_thread( JavaVM *java_vm )
{
java_fs = *p_java_gdt_sel;
__asm__( "mov %%fs,%0" : "=r" (orig_fs) );
__asm__( "mov %0,%%fs" :: "r" (java_fs) );
(*java_vm)->AttachCurrentThread( java_vm, &jni_env, 0 );
__asm__( "mov %%fs,%0" : "=r" (java_fs) );
if (!*p_java_gdt_sel) __asm__( "mov %%fs,%0" : "=r" (java_fs) );
__asm__( "mov %0,%%fs" :: "r" (orig_fs) );
}

View File

@ -622,6 +622,7 @@ static void load_android_libs(void)
JavaVM **p_java_vm = NULL;
jobject *p_java_object = NULL;
unsigned short *p_java_gdt_sel = NULL;
static BOOL process_attach(void)
{
@ -635,6 +636,7 @@ static BOOL process_attach(void)
p_java_vm = dlsym( ntdll, "java_vm" );
p_java_object = dlsym( ntdll, "java_object" );
p_java_gdt_sel = dlsym( ntdll, "java_gdt_sel" );
object = *p_java_object;