Added __wine_set_signal_fs function to avoid sharing the

SYSLEVEL_Win16CurrentTeb variable between kernel and ntdll.
On the kernel side, replaced SYSLEVEL_Win16CurrentTeb by
CallTo16_TebSelector stored directly in the asm relay code to avoid a
run-time relocation.
This commit is contained in:
Alexandre Julliard 2003-10-08 22:59:22 +00:00
parent 2de67b8428
commit 67d9f38059
4 changed files with 28 additions and 15 deletions

View File

@ -46,8 +46,10 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
}; };
static SYSLEVEL Win16Mutex = { { &critsect_debug, -1, 0, 0, 0, 0 }, 1 }; static SYSLEVEL Win16Mutex = { { &critsect_debug, -1, 0, 0, 0, 0 }, 1 };
/* Global variable to save current TEB while in 16-bit code */ #ifdef __i386__
extern WORD SYSLEVEL_Win16CurrentTeb; extern unsigned int CallTo16_TebSelector;
extern void __wine_set_signal_fs( unsigned int fs );
#endif
/************************************************************************ /************************************************************************
@ -114,7 +116,11 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] ); lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
#ifdef __i386__ #ifdef __i386__
if (lock == &Win16Mutex) SYSLEVEL_Win16CurrentTeb = wine_get_fs(); if (lock == &Win16Mutex)
{
__wine_set_signal_fs( wine_get_fs() );
CallTo16_TebSelector = wine_get_fs();
}
#endif #endif
} }

View File

@ -1071,6 +1071,7 @@
# signal handling # signal handling
@ cdecl __wine_set_signal_handler(long ptr) @ cdecl __wine_set_signal_handler(long ptr)
@ cdecl -norelay -i386 __wine_set_signal_fs(long)
################################################################ ################################################################
# Wine dll separation hacks, these will go away, don't use them # Wine dll separation hacks, these will go away, don't use them

View File

@ -417,8 +417,8 @@ static wine_signal_handler handlers[256];
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
/* Global variable to save current TEB while in 16-bit code (FIXME) */ /* Global variable to save the thread %fs register while in 16-bit code (FIXME) */
WORD SYSLEVEL_Win16CurrentTeb = 0; static unsigned int signal_fs;
/*********************************************************************** /***********************************************************************
* dispatch_signal * dispatch_signal
@ -542,7 +542,7 @@ static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext )
* SS is still non-system segment. This is why both CS and SS * SS is still non-system segment. This is why both CS and SS
* are checked. * are checked.
*/ */
wine_set_fs( SYSLEVEL_Win16CurrentTeb ); wine_set_fs( signal_fs );
wine_set_gs( NtCurrentTeb()->gs_sel ); wine_set_gs( NtCurrentTeb()->gs_sel );
} }
#ifdef __HAVE_VM86 #ifdef __HAVE_VM86
@ -650,7 +650,7 @@ static void init_handler( const SIGCONTEXT *sigcontext )
if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext)) || if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext)) ||
!IS_SELECTOR_SYSTEM(SS_sig(sigcontext))) /* 16-bit mode */ !IS_SELECTOR_SYSTEM(SS_sig(sigcontext))) /* 16-bit mode */
{ {
wine_set_fs( SYSLEVEL_Win16CurrentTeb ); wine_set_fs( signal_fs );
wine_set_gs( NtCurrentTeb()->gs_sel ); wine_set_gs( NtCurrentTeb()->gs_sel );
} }
#ifdef __HAVE_VM86 #ifdef __HAVE_VM86
@ -1193,6 +1193,15 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
} }
/***********************************************************************
* __wine_set_signal_fs (NTDLL.@)
*/
void __wine_set_signal_fs( unsigned int fs )
{
signal_fs = fs;
}
/********************************************************************** /**********************************************************************
* SIGNAL_Init * SIGNAL_Init
*/ */

View File

@ -169,11 +169,11 @@ static void BuildCallFrom16Core( FILE *outfile, int reg_func, int thunk, int sho
if ( UsePIC ) if ( UsePIC )
{ {
fprintf( outfile, "\tmovl " __ASM_NAME("SYSLEVEL_Win16CurrentTeb@GOT") "(%%ecx), %%edx\n" ); fprintf( outfile, "\tmovl " __ASM_NAME("CallTo16_TebSelector@GOT") "(%%ecx), %%edx\n" );
fprintf( outfile, "\tmovw (%%edx), %%fs\n" ); fprintf( outfile, "\tmovw (%%edx), %%fs\n" );
} }
else else
fprintf( outfile, "\tmovw " __ASM_NAME("SYSLEVEL_Win16CurrentTeb") ", %%fs\n" ); fprintf( outfile, "\tmovw " __ASM_NAME("CallTo16_TebSelector") ", %%fs\n" );
fprintf( outfile, "\t.byte 0x64\n\tmovl (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) ); fprintf( outfile, "\t.byte 0x64\n\tmovl (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) );
@ -615,11 +615,6 @@ static void BuildCallTo16Core( FILE *outfile, int reg_func )
*/ */
static void BuildRet16Func( FILE *outfile ) static void BuildRet16Func( FILE *outfile )
{ {
/*
* Note: This must reside in the .data section to allow
* run-time relocation of the SYSLEVEL_Win16CurrentTeb symbol
*/
function_header( outfile, "CallTo16_Ret" ); function_header( outfile, "CallTo16_Ret" );
/* Save %esp into %esi */ /* Save %esp into %esi */
@ -637,7 +632,7 @@ static void BuildRet16Func( FILE *outfile )
#endif #endif
fprintf( outfile, "\tmovw %%di,%%es\n" ); fprintf( outfile, "\tmovw %%di,%%es\n" );
fprintf( outfile, "\tmovw " __ASM_NAME("SYSLEVEL_Win16CurrentTeb") ",%%fs\n" ); fprintf( outfile, "\t.byte 0x2e\n\tmovl " __ASM_NAME("CallTo16_TebSelector") "-" __ASM_NAME("Call16_Ret_Start") ",%%fs\n" );
fprintf( outfile, "\t.byte 0x64\n\tmovl (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) ); fprintf( outfile, "\t.byte 0x64\n\tmovl (%d),%%gs\n", STRUCTOFFSET(TEB,gs_sel) );
@ -658,6 +653,8 @@ static void BuildRet16Func( FILE *outfile )
fprintf( outfile, "\n\t.align %d\n", get_alignment(4) ); fprintf( outfile, "\n\t.align %d\n", get_alignment(4) );
fprintf( outfile, "\t.globl " __ASM_NAME("CallTo16_DataSelector") "\n" ); fprintf( outfile, "\t.globl " __ASM_NAME("CallTo16_DataSelector") "\n" );
fprintf( outfile, __ASM_NAME("CallTo16_DataSelector") ":\t.long 0\n" ); fprintf( outfile, __ASM_NAME("CallTo16_DataSelector") ":\t.long 0\n" );
fprintf( outfile, "\t.globl " __ASM_NAME("CallTo16_TebSelector") "\n" );
fprintf( outfile, __ASM_NAME("CallTo16_TebSelector") ":\t.long 0\n" );
} }