Fix TSD stubs for non-initial-exec case (fixes #5667).

ppc64le TSD disabled for now since I am insufficiently familiar with ppc
asm. x86 pthread stubs deleted because adding USE_ELF_TLS to the #if is
isn't worth the effort since it only saves a single function call on
initial entry (TSD stubs are not used for read-only text now). also
potentially fix non-pthread TSD builds (_glapi_Dispatch was undefined),
but untested (could still be broken).

Tested-by: Jesse Natalie <jenatali@microsoft.com>
Tested-by: Jan Beich <jbeich@freebsd.org>
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13935>
This commit is contained in:
Alex Xu (Hello71) 2021-11-23 15:24:38 -05:00
parent b713fca495
commit 3aab34171d
3 changed files with 6 additions and 29 deletions

View File

@ -47,8 +47,6 @@
#endif
/* REALLY_INITIAL_EXEC implies USE_ELF_TLS and __GNUC__ */
/* Use TSD stubs for non-IE ELF TLS even though first access is slower because
* future accesses will be patched */
#if defined(USE_X86_ASM) && defined(REALLY_INITIAL_EXEC)
#include "entry_x86_tls.h"
#elif defined(USE_X86_ASM) && !defined(GLX_X86_READONLY_TEXT) && defined(__GNUC__)
@ -57,7 +55,8 @@
#include "entry_x86-64_tls.h"
#elif defined(USE_PPC64LE_ASM) && UTIL_ARCH_LITTLE_ENDIAN && defined(REALLY_INITIAL_EXEC)
#include "entry_ppc64le_tls.h"
#elif defined(USE_PPC64LE_ASM) && UTIL_ARCH_LITTLE_ENDIAN && defined(__GNUC__)
/* ppc64le non-IE TSD stubs are possible but not currently implemented */
#elif defined(USE_PPC64LE_ASM) && UTIL_ARCH_LITTLE_ENDIAN && !defined(USE_ELF_TLS) && defined(__GNUC__)
#include "entry_ppc64le_tsd.h"
#else

View File

@ -69,7 +69,7 @@ __asm__(".balign 32\n"
"popl %ecx\n\t" \
"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx\n\t" \
LOC_END_SET_ECX \
"movl " ENTRY_CURRENT_TABLE "@GOT(%ecx), %eax\n\t" \
"movl _glapi_Dispatch@GOT(%ecx), %eax\n\t" \
"mov (%eax), %eax\n\t" \
"testl %eax, %eax\n\t" \
"jne 1f\n\t" \

View File

@ -70,7 +70,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('#endif')
print('')
print('')
print('#ifdef USE_ELF_TLS')
print('#ifdef REALLY_INITIAL_EXEC')
print('')
print('#ifdef GLX_X86_READONLY_TEXT')
print('# define CTX_INSNS MOV_L(GS:(EAX), EAX)')
@ -86,17 +86,6 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('\tCTX_INSNS ; \\')
print('\tJMP(GL_OFFSET(off))')
print('')
print('#elif defined(HAVE_PTHREAD)')
print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\')
print('ALIGNTEXT16;\t\t\t\t\t\t\\')
print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
print('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
print('\tTEST_L(EAX, EAX) ;\t\t\t\t\\')
print('\tJE(1f) ;\t\t\t\t\t\\')
print('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\')
print('1:\tCALL(_x86_get_dispatch) ;\t\t\t\\')
print('\tJMP(GL_OFFSET(off))')
print('#else')
print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\')
print('ALIGNTEXT16;\t\t\t\t\t\t\\')
@ -121,7 +110,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('')
print('SEG_TEXT')
print('')
print('#ifdef USE_ELF_TLS')
print('#ifdef REALLY_INITIAL_EXEC')
print('')
print('\tGLOBL\tGLNAME(_x86_get_dispatch)')
print('\tHIDDEN(GLNAME(_x86_get_dispatch))')
@ -133,19 +122,8 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax')
print('\tret')
print('')
print('#elif defined(HAVE_PTHREAD)')
print('EXTERN GLNAME(_glapi_Dispatch)')
print('EXTERN GLNAME(_gl_DispatchTSD)')
print('EXTERN GLNAME(pthread_getspecific)')
print('')
print('ALIGNTEXT16')
print('GLNAME(_x86_get_dispatch):')
print('\tSUB_L(CONST(24), ESP)')
print('\tPUSH_L(GLNAME(_gl_DispatchTSD))')
print('\tCALL(GLNAME(pthread_getspecific))')
print('\tADD_L(CONST(28), ESP)')
print('\tRET')
print('#else')
print('EXTERN GLNAME(_glapi_Dispatch)')
print('EXTERN GLNAME(_glapi_get_dispatch)')
print('#endif')
print('')