aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLepton Wu <[email protected]>2019-10-25 17:27:04 -0700
committerMatt Turner <[email protected]>2019-10-29 17:18:06 -0700
commitb2b8639d8e901008b4501e35957d27da170de042 (patch)
tree50029959bf989fc77da597ee23f271db077a0126
parent1fb75bee90d769111573d6b6dd696b9cbd6d976a (diff)
mapi: Clean up entry_patch_public for x86 tls
Remove hard coded 16 and use entry_generate_or_patch to patch public stubs. The generated code actually is sightly tighter than before since the "nop" instructions before the final "jmp" get removed. Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Lepton Wu <[email protected]>
-rw-r--r--src/mapi/entry_x86_tls.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/mapi/entry_x86_tls.h b/src/mapi/entry_x86_tls.h
index a4e2a766382..b9386799792 100644
--- a/src/mapi/entry_x86_tls.h
+++ b/src/mapi/entry_x86_tls.h
@@ -33,6 +33,8 @@
#define HIDDEN
#endif
+#define X86_ENTRY_SIZE 16
+
__asm__(".text");
__asm__("x86_current_tls:\n\t"
@@ -87,23 +89,18 @@ void
entry_patch_public(void)
{
#ifndef GLX_X86_READONLY_TEXT
- char patch[8] = {
- 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */
- 0x90, 0x90 /* nop's */
- };
char *entry;
-
- *((unsigned long *) (patch + 2)) = x86_current_tls();
-
- for (entry = x86_entry_start; entry < x86_entry_end; entry += 16)
- memcpy(entry, patch, sizeof(patch));
+ int slot = 0;
+ for (entry = x86_entry_start; entry < x86_entry_end;
+ entry += X86_ENTRY_SIZE, ++slot)
+ entry_generate_or_patch(slot, entry, X86_ENTRY_SIZE);
#endif
}
mapi_func
entry_get_public(int slot)
{
- return (mapi_func) (x86_entry_start + slot * 16);
+ return (mapi_func) (x86_entry_start + slot * X86_ENTRY_SIZE);
}
void