88
87
return (mapi_func) (x86_64_entry_start + slot * 32);
92
entry_patch(mapi_func entry, int slot)
94
char *code = (char *) entry;
99
*((unsigned int *) (code + offset)) = slot * sizeof(mapi_func);
103
entry_generate(int slot)
105
const char code_templ[] = {
107
/* movq %fs:0, %r11 */
108
0x64, 0x4c, 0x8b, 0x1c, 0x25, 0x00, 0x00, 0x00, 0x00,
109
/* jmp *0x1234(%r11) */
110
0x41, 0xff, 0xa3, 0x34, 0x12, 0x00, 0x00,
112
/* movl %fs:0, %r11d */
113
0x64, 0x44, 0x8b, 0x1c, 0x25, 0x00, 0x00, 0x00, 0x00,
114
/* movl 0x1234(%r11d), %r11d */
115
0x67, 0x45, 0x8b, 0x9b, 0x34, 0x12, 0x00, 0x00,
120
unsigned long long addr;
124
__asm__("movq _glapi_tls_Dispatch@GOTTPOFF(%%rip), %0"
126
if ((addr >> 32) != 0xffffffff)
130
code = u_execmem_alloc(sizeof(code_templ));
134
memcpy(code, code_templ, sizeof(code_templ));
136
*((unsigned int *) (code + 5)) = addr;
137
entry = (mapi_func) code;
138
entry_patch(entry, slot);
143
91
#endif /* MAPI_MODE_BRIDGE */