[Mesa-stable] [PATCH] mapi: avoid text relocation in x86 tsd stubs

Jonathan Gray jsg at jsg.id.au
Thu Nov 1 04:08:43 UTC 2018


Make similiar changes to libglvnd to avoid a text relocation in
x86 tsd stubs fixing the build with lld.

Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
Cc: mesa-stable at lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108541
---
 src/mapi/entry_x86_tsd.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h
index 0c28c8ff068..e08a02f3db2 100644
--- a/src/mapi/entry_x86_tsd.h
+++ b/src/mapi/entry_x86_tsd.h
@@ -31,7 +31,7 @@
 #define HIDDEN
 #endif
 
-#define X86_ENTRY_SIZE 32
+#define X86_ENTRY_SIZE 64
 
 __asm__(".text\n"
         ".balign 32\n"
@@ -44,12 +44,16 @@ __asm__(".text\n"
    func ":"
 
 #define STUB_ASM_CODE(slot)         \
-   "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \
+   "call 1f\n\t"                    \
+   "1:\n\t"                         \
+   "popl %eax\n\t"                  \
+   "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" \
+   "movl " ENTRY_CURRENT_TABLE "@GOT(%eax), %eax\n\t" \
+   "mov (%eax), %eax\n\t"           \
    "testl %eax, %eax\n\t"           \
-   "je 1f\n\t"                      \
-   "jmp *(4 * " slot ")(%eax)\n"    \
+   "jne 1f\n\t"                     \
+   "call " ENTRY_CURRENT_TABLE_GET "@PLT\n\t" \
    "1:\n\t"                         \
-   "call " ENTRY_CURRENT_TABLE_GET "\n\t" \
    "jmp *(4 * " slot ")(%eax)"
 
 #define MAPI_TMP_STUB_ASM_GCC
-- 
2.19.1



More information about the mesa-stable mailing list