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

Reply via email to