Re: [Mesa-dev] [PATCH] mapi: Fix tls with shared/es-glapi on x86-64
On Wed, Jun 8, 2011 at 10:07 PM, Benjamin Franzke benjaminfran...@googlemail.com wrote: 2011/6/7 Chia-I Wu olva...@gmail.com: How is that the case? It seems the symbol is not used elsewhere. Right, seems i tried solve the wrong side of the problem. x86_64_entry_start is declared similar to a global static variable in the asm code, so it will be bound local. But in entry_get_public its declared as extern, the compiler will generate code to lookup a global object, not a local. By declaring x86_64_entry_start as static the correct local address is loaded here. I got this warning after applying the patch ../../../src/mapi/mapi/entry_x86-64_tls.h:69:1: warning: ‘x86_64_current_tls’ used but never defined Maybe the function declaration should be decorated with extern? Patch attached. -- o...@lunarg.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mapi: Fix tls with shared/es-glapi on x86-64
2011/6/7 Chia-I Wu olva...@gmail.com: How is that the case? It seems the symbol is not used elsewhere. Right, seems i tried solve the wrong side of the problem. x86_64_entry_start is declared similar to a global static variable in the asm code, so it will be bound local. But in entry_get_public its declared as extern, the compiler will generate code to lookup a global object, not a local. By declaring x86_64_entry_start as static the correct local address is loaded here. Patch attached. From 7ca323bf472004066f35dbec51791c90a671a42e Mon Sep 17 00:00:00 2001 From: Benjamin Franzke benjaminfran...@googlemail.com Date: Wed, 8 Jun 2011 15:50:25 +0200 Subject: [PATCH] mapi: Fix tls with shared/es-glapi on x86-64 x86_64_entry_start needs to be declared static in the C code, in order to have the correct address in entry_get_public (seems not to be needed on x86). The compiler needs to lookup a local not a global object. Otherwise addresses needed for _glapi_proc_address will be computed from some random offset (0x6400229a61058b48 in my case). Do the same for x86_64_current_tls. --- src/mapi/mapi/entry_x86-64_tls.h |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h index d3b606c..95dffcc 100644 --- a/src/mapi/mapi/entry_x86-64_tls.h +++ b/src/mapi/mapi/entry_x86-64_tls.h @@ -65,7 +65,7 @@ __asm__(x86_64_current_tls:\n\t movq ENTRY_CURRENT_TABLE @GOTTPOFF(%rip), %rax\n\t ret); -extern unsigned long +static unsigned long x86_64_current_tls(); #include string.h @@ -76,10 +76,12 @@ entry_patch_public(void) { } +static char +x86_64_entry_start[]; + mapi_func entry_get_public(int slot) { - extern char x86_64_entry_start[]; return (mapi_func) (x86_64_entry_start + slot * 32); } -- 1.7.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mapi: Fix tls with shared/es-glapi on x86-64
x86_64_entry_start needs to be bound global, in order to have the correct address in entry_get_public (seems not to be needed on x86). Otherwise addresses needed for _glapi_proc_address will be computed from some random offset (0x6400229a61058b48 in my case). --- src/mapi/mapi/entry_x86-64_tls.h |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h index d3b606c..dad596a 100644 --- a/src/mapi/mapi/entry_x86-64_tls.h +++ b/src/mapi/mapi/entry_x86-64_tls.h @@ -28,6 +28,12 @@ #include u_macros.h +#ifdef __GNUC__ +# define HIDDEN(x) .hidden U_STRINGIFY(x) \n +#else +# define HIDDEN(x) +#endif + #ifdef __linux__ __asm__(.section .note.ABI-tag, \a\\n\t .p2align 2\n\t @@ -43,6 +49,8 @@ __asm__(.section .note.ABI-tag, \a\\n\t __asm__(.text\n .balign 32\n +.globl x86_64_entry_start\n +HIDDEN(x86_64_entry_start) x86_64_entry_start:); #define STUB_ASM_ENTRY(func) \ -- 1.7.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mapi: Fix tls with shared/es-glapi on x86-64
On Wed, Jun 8, 2011 at 2:33 AM, Benjamin Franzke benjaminfran...@googlemail.com wrote: x86_64_entry_start needs to be bound global, in order to have the correct address in entry_get_public (seems not to be needed on x86). Otherwise addresses needed for _glapi_proc_address will be computed from some random offset (0x6400229a61058b48 in my case). How is that the case? It seems the symbol is not used elsewhere. I don't have a x86-64 machine to verify at the moment. --- src/mapi/mapi/entry_x86-64_tls.h | 8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h index d3b606c..dad596a 100644 --- a/src/mapi/mapi/entry_x86-64_tls.h +++ b/src/mapi/mapi/entry_x86-64_tls.h @@ -28,6 +28,12 @@ #include u_macros.h +#ifdef __GNUC__ +# define HIDDEN(x) .hidden U_STRINGIFY(x) \n +#else +# define HIDDEN(x) +#endif + #ifdef __linux__ __asm__(.section .note.ABI-tag, \a\\n\t .p2align 2\n\t @@ -43,6 +49,8 @@ __asm__(.section .note.ABI-tag, \a\\n\t __asm__(.text\n .balign 32\n + .globl x86_64_entry_start\n + HIDDEN(x86_64_entry_start) x86_64_entry_start:); #define STUB_ASM_ENTRY(func) \ -- 1.7.3.4 -- o...@lunarg.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev