[Mesa-stable] [PATCH v2] mapi: avoid text relocation in x86 tsd stubs
Jonathan Gray
jsg at jsg.id.au
Sun Nov 11 04:47:35 UTC 2018
Make similiar changes to libglvnd to avoid a text relocation in
x86 tsd stubs fixing the build with lld.
v2:
- store the address of the GOT in ebx required before calling PLT stub
- change .balign values to match X86_ENTRY_SIZE
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 | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h
index 0c28c8ff068..1dec3ed86c4 100644
--- a/src/mapi/entry_x86_tsd.h
+++ b/src/mapi/entry_x86_tsd.h
@@ -31,25 +31,31 @@
#define HIDDEN
#endif
-#define X86_ENTRY_SIZE 32
+#define X86_ENTRY_SIZE 64
__asm__(".text\n"
- ".balign 32\n"
+ ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"
"x86_entry_start:");
#define STUB_ASM_ENTRY(func) \
".globl " func "\n" \
".type " func ", @function\n" \
- ".balign 32\n" \
+ ".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n" \
func ":"
#define STUB_ASM_CODE(slot) \
- "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \
+ "push %ebx\n\t" \
+ "call 1f\n" \
+ "1:\n\t" \
+ "popl %ebx\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx\n\t" \
+ "movl " ENTRY_CURRENT_TABLE "@GOT(%ebx), %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" \
"1:\n\t" \
- "call " ENTRY_CURRENT_TABLE_GET "\n\t" \
+ "pop %ebx\n\t" \
"jmp *(4 * " slot ")(%eax)"
#define MAPI_TMP_STUB_ASM_GCC
@@ -57,7 +63,7 @@ __asm__(".text\n"
#ifndef MAPI_MODE_BRIDGE
-__asm__(".balign 32\n"
+__asm__(".balign " U_STRINGIFY(X86_ENTRY_SIZE) "\n"
"x86_entry_end:");
#include <string.h>
--
2.19.1
More information about the mesa-stable
mailing list