From 3ba2f86ae731aff8f751ccacec4996eb57e11d0d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 17 May 2018 16:03:59 -0700 Subject: Switch x86/x64 trampolines to use __attribute__((naked)) Switching to clang++ means __attribute__((optimize)) is no longer recognized. However, we do get __attribute__((naked)). Slightly larger change than I'd like because __attribute__((naked)) doesn't permit C variable declarations. Change-Id: I558ccaf292e381d33e10c5034053cdc651eff5f2 Bug: b/79574249 Test: TBC --- opengl/libs/EGL/getProcAddress.cpp | 42 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp index 0183621299..fedc7893db 100644 --- a/opengl/libs/EGL/getProcAddress.cpp +++ b/opengl/libs/EGL/getProcAddress.cpp @@ -80,46 +80,44 @@ namespace android { #elif defined(__i386__) - #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api + #define API_ENTRY(_api) __attribute__((naked)) _api #define CALL_GL_EXTENSION_API(_api) \ - register void** fn; \ __asm__ volatile( \ - "mov %%gs:0, %[fn]\n" \ - "mov %P[tls](%[fn]), %[fn]\n" \ - "test %[fn], %[fn]\n" \ - "cmovne %P[api](%[fn]), %[fn]\n" \ - "test %[fn], %[fn]\n" \ + "mov %%gs:0, %%eax\n" \ + "mov %P[tls](%%eax), %%eax\n" \ + "test %%eax, %%eax\n" \ + "cmovne %P[api](%%eax), %%eax\n" \ + "test %%eax, %%eax\n" \ "je 1f\n" \ - "jmp *%[fn]\n" \ - "1:\n" \ - : [fn] "=r" (fn) \ + "jmp *%%eax\n" \ + "1: ret\n" \ + : \ : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ [api] "i" (__builtin_offsetof(gl_hooks_t, \ ext.extensions[_api])) \ - : "cc" \ + : "eax", "cc" \ ); #elif defined(__x86_64__) - #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api + #define API_ENTRY(_api) __attribute__((naked)) _api #define CALL_GL_EXTENSION_API(_api) \ - register void** fn; \ __asm__ volatile( \ - "mov %%fs:0, %[fn]\n" \ - "mov %P[tls](%[fn]), %[fn]\n" \ - "test %[fn], %[fn]\n" \ - "cmovne %P[api](%[fn]), %[fn]\n" \ - "test %[fn], %[fn]\n" \ + "mov %%fs:0, %%rax\n" \ + "mov %P[tls](%%rax), %%rax\n" \ + "test %%rax, %%rax\n" \ + "cmovne %P[api](%%rax), %%rax\n" \ + "test %%rax, %%rax\n" \ "je 1f\n" \ - "jmp *%[fn]\n" \ - "1:\n" \ - : [fn] "=r" (fn) \ + "jmp *%%rax\n" \ + "1: ret\n" \ + : \ : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ [api] "i" (__builtin_offsetof(gl_hooks_t, \ ext.extensions[_api])) \ - : "cc" \ + : "rax", "cc" \ ); #elif defined(__mips64) -- cgit v1.2.3-59-g8ed1b