[mupen64plus-core] 72/310: Prevent over-optimization of rjump related data

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 05:57:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-core.

commit fd08038bc30172f0e55bb78930362e2393404eae
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Jun 5 18:36:28 2011 +0200

    Prevent over-optimization of rjump related data
    
    GCC tries to remove and/or rename local symbols when trying to optimize
    the code. This is a common problem when using link time optimization or
    other optimization with deep inspection of dataflow. Inline assembler
    code has to be annotated when it tries to access data behind such
    symbols to prevent over optimization and to correctly name these
    symbols.
    
    This also removes partially the requirement of having different
    implementation of the rjump code for different combination of OS and
    PIC/PIE targets.
---
 debian/changelog                   |   1 +
 debian/patches/rjump_globber.patch | 230 +++++++++++++++++++++++++++++++++++++
 debian/patches/series              |   1 +
 3 files changed, 232 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index fb65317..75a6aeb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ mupen64plus-core (1.99.4-2) UNRELEASED; urgency=low
   * debian/patches:
     - Add rtc.patch, Add support for n64 internal clock
     - Add n64_romswap.patch, Fix swapping of n64 images
+    - Add rjump_globber.patch. Prevent over-optimization of rjump related data
   * Upgraded to policy 3.9.2, no changes required
   * Update Vcs-* fields to new anonscm.debian.org URLs in debian/control
 
diff --git a/debian/patches/rjump_globber.patch b/debian/patches/rjump_globber.patch
new file mode 100644
index 0000000..b48448d
--- /dev/null
+++ b/debian/patches/rjump_globber.patch
@@ -0,0 +1,230 @@
+Description: Prevent over-optimization of rjump related data
+ GCC tries to remove and/or rename local symbols when trying to optimize the
+ code. This is a common problem when using link time optimization or other
+ optimization with deep inspection of dataflow. Inline assembler code has to be
+ annotated when it tries to access data behind such symbols to prevent over
+ optimization and to correctly name these symbols.
+ .
+ This also removes partially the requirement of having different implementation
+ of the rjump code for different combination of OS and PIC/PIE targets.
+Author: Sven Eckelmann <sven at narfation.org>
+
+---
+diff --git a/src/r4300/x86/rjump.c b/src/r4300/x86/rjump.c
+index 0c767a09b9442aeeb580f935062a8faae0d65486..0fb8bba01e076549d223954ead414d1143a969a6 100644
+--- a/src/r4300/x86/rjump.c
++++ b/src/r4300/x86/rjump.c
+@@ -92,55 +92,39 @@ void dyna_start(void (*code)(void))
+      mov edi, save_edi
+    }
+ #elif defined(__GNUC__) && defined(__i386__)
+-  #if defined(PIC)
++  #if defined(__PIC__)
+     /* for -fPIC (shared libraries) */
+-    asm volatile
+-      (" movl %%ebp,  save_ebp at GOTOFF(%%ebx)\n"
+-       " movl %%esp,  save_esp at GOTOFF(%%ebx)\n"
+-       " movl %%esi,  save_esi at GOTOFF(%%ebx)\n"
+-       " movl %%edi,  save_edi at GOTOFF(%%ebx)\n"
+-       " call    1f                         \n"
+-       " jmp     2f                         \n"
+-       "1:                                  \n"
+-       " popl %%eax                         \n"
+-       " movl %%eax,  save_eip at GOTOFF(%%ebx)\n"
+-       " call *%[codeptr]                   \n"
+-       "2:                                  \n"
+-       " call  __i686.get_pc_thunk.bx       \n"
+-       " addl $_GLOBAL_OFFSET_TABLE_, %%ebx \n"
+-       " movl save_ebp at GOTOFF(%%ebx), %%ebp \n"
+-       " movl save_esp at GOTOFF(%%ebx), %%esp \n"
+-       " movl save_esi at GOTOFF(%%ebx), %%esi \n"
+-       " movl save_edi at GOTOFF(%%ebx), %%edi \n"
+-       :
+-       : [codeptr]"r"(code)
+-       : "eax", "ecx", "edx", "memory"
+-       );
++    #define STORE_EBX
++    #define LOAD_EBX "call  __i686.get_pc_thunk.bx       \n" \
++                     "addl $_GLOBAL_OFFSET_TABLE_, %%ebx \n"
+   #else
+     /* for non-PIC binaries */
+-    asm volatile 
+-      (" movl %%ebp, save_ebp \n"
+-       " movl %%esp, save_esp \n"
+-       " movl %%ebx, save_ebx \n"
+-       " movl %%esi, save_esi \n"
+-       " movl %%edi, save_edi \n"
+-       " call 1f              \n"
+-       " jmp 2f               \n"
+-       "1:                    \n"
+-       " popl %%eax           \n"
+-       " movl %%eax, save_eip \n"
+-       " call *%[codeptr]     \n"
+-       "2:                    \n"
+-       " movl save_ebp, %%ebp \n"
+-       " movl save_esp, %%esp \n"
+-       " movl save_ebx, %%ebx \n"
+-       " movl save_esi, %%esi \n"
+-       " movl save_edi, %%edi \n"
+-       :
+-       : [codeptr]"r"(code)
+-       : "eax", "ecx", "edx", "memory"
+-       );
++    #define STORE_EBX "movl %%ebx, %[save_ebx] \n"
++    #define LOAD_EBX  "movl %[save_ebx], %%ebx \n"
+   #endif
++
++  asm volatile
++    (STORE_EBX
++     " movl %%ebp, %[save_ebp] \n"
++     " movl %%esp, %[save_esp] \n"
++     " movl %%esi, %[save_esi] \n"
++     " movl %%edi, %[save_edi] \n"
++     " call    1f              \n"
++     " jmp     2f              \n"
++     "1:                       \n"
++     " popl %%eax              \n"
++     " movl %%eax, %[save_eip] \n"
++     " call *%[codeptr]        \n"
++     "2:                       \n"
++     LOAD_EBX
++     " movl %[save_ebp], %%ebp \n"
++     " movl %[save_esp], %%esp \n"
++     " movl %[save_esi], %%esi \n"
++     " movl %[save_edi], %%edi \n"
++     : [save_ebp]"=m"(save_ebp), [save_esp]"=m"(save_esp), [save_ebx]"=m"(save_ebx), [save_esi]"=m"(save_esi), [save_edi]"=m"(save_edi), [save_eip]"=m"(save_eip)
++     : [codeptr]"r"(code)
++     : "eax", "ecx", "edx", "memory"
++     );
+ #endif
+ 
+     /* clear flag; stack is back to normal */
+diff --git a/src/r4300/x86_64/rjump.c b/src/r4300/x86_64/rjump.c
+index d7d936ff3ea6b3dd4f9f15cf1a0b05d42da74d92..8913f598e89e423d2697543057786268ffaa1fd7 100644
+--- a/src/r4300/x86_64/rjump.c
++++ b/src/r4300/x86_64/rjump.c
+@@ -58,97 +58,33 @@ void dyna_start(void (*code)(void))
+   /* It will jump to label 2, restore the base and stack pointers, and exit this function */
+   DebugMessage(M64MSG_INFO, "R4300: starting 64-bit dynamic recompiler at: 0x%lx", (unsigned long) code);
+ #if defined(__GNUC__) && defined(__x86_64__)
+-  #if defined(PIC)
+-    /* for -fPIC (shared libraries) */
+-    #if defined(__APPLE__)
+-      /* OSX uses underscores before the symbols names in 64-bit PIC compilation */
+-      asm volatile
+-        (" push %%rbx           \n"  /* we must push an even # of registers to keep stack 16-byte aligned */
+-         " push %%r12           \n"
+-         " push %%r13           \n"
+-         " push %%r14           \n"
+-         " push %%r15           \n"
+-         " push %%rbp           \n"
+-         " mov  %%rsp, _save_rsp(%%rip) \n"
+-         " lea  _reg(%%rip), %%r15      \n" /* store the base location of the r4300 registers in r15 for addressing */
+-         " call 1f              \n"
+-         " jmp 2f               \n"
+-         "1:                    \n"
+-         " pop  %%rax           \n"
+-         " mov  %%rax, _save_rip(%%rip) \n"
+-         " call *%%rbx          \n"
+-         "2:                    \n"
+-         " mov  _save_rsp(%%rip), %%rsp \n"
+-         " pop  %%rbp           \n"
+-         " pop  %%r15           \n"
+-         " pop  %%r14           \n"
+-         " pop  %%r13           \n"
+-         " pop  %%r12           \n"
+-         " pop  %%rbx           \n"
+-         :
+-         : "b" (code)
+-         : "%rax", "memory"
+-         );
+-    #else
+-      /* Linux and other unix variants do not use underscores */
+-      asm volatile
+-        (" push %%rbx           \n"  /* we must push an even # of registers to keep stack 16-byte aligned */
+-         " push %%r12           \n"
+-         " push %%r13           \n"
+-         " push %%r14           \n"
+-         " push %%r15           \n"
+-         " push %%rbp           \n"
+-         " mov  %%rsp, save_rsp(%%rip) \n"
+-         " lea  reg(%%rip), %%r15      \n" /* store the base location of the r4300 registers in r15 for addressing */
+-         " call 1f              \n"
+-         " jmp 2f               \n"
+-         "1:                    \n"
+-         " pop  %%rax           \n"
+-         " mov  %%rax, save_rip(%%rip) \n"
+-         " call *%%rbx          \n"
+-         "2:                    \n"
+-         " mov  save_rsp(%%rip), %%rsp \n"
+-         " pop  %%rbp           \n"
+-         " pop  %%r15           \n"
+-         " pop  %%r14           \n"
+-         " pop  %%r13           \n"
+-         " pop  %%r12           \n"
+-         " pop  %%rbx           \n"
+-         :
+-         : "b" (code)
+-         : "%rax", "memory"
+-         );
+-      #endif
+-  #else
+-    /* for non-PIC binaries (this is normally not used, because the core is always compiled as a shared library) */
+-    asm volatile
+-      (" push %%rbx           \n"  /* we must push an even # of registers to keep stack 16-byte aligned */
+-       " push %%r12           \n"
+-       " push %%r13           \n"
+-       " push %%r14           \n"
+-       " push %%r15           \n"
+-       " push %%rbp           \n"
+-       " mov  %%rsp, save_rsp \n"
+-       " lea  reg, %%r15      \n" /* store the base location of the r4300 registers in r15 for addressing */
+-       " call 1f              \n"
+-       " jmp 2f               \n"
+-       "1:                    \n"
+-       " pop  %%rax           \n"
+-       " mov  %%rax, save_rip \n"
+-       " call *%%rbx          \n"
+-       "2:                    \n"
+-       " mov  save_rsp, %%rsp \n"
+-       " pop  %%rbp           \n"
+-       " pop  %%r15           \n"
+-       " pop  %%r14           \n"
+-       " pop  %%r13           \n"
+-       " pop  %%r12           \n"
+-       " pop  %%rbx           \n"
+-       :
+-       : "b" (code)
+-       : "%rax", "memory"
+-       );
+-  #endif
++  asm volatile
++    (" push %%rbx              \n"  /* we must push an even # of registers to keep stack 16-byte aligned */
++     " push %%r12              \n"
++     " push %%r13              \n"
++     " push %%r14              \n"
++     " push %%r15              \n"
++     " push %%rbp              \n"
++     " mov  %%rsp, %[save_rsp] \n"
++     " lea  %[reg], %%r15      \n" /* store the base location of the r4300 registers in r15 for addressing */
++     " call 1f                 \n"
++     " jmp 2f                  \n"
++     "1:                       \n"
++     " pop  %%rax              \n"
++     " mov  %%rax, %[save_rip] \n"
++     " call *%%rbx             \n"
++     "2:                       \n"
++     " mov  %[save_rsp], %%rsp \n"
++     " pop  %%rbp              \n"
++     " pop  %%r15              \n"
++     " pop  %%r14              \n"
++     " pop  %%r13              \n"
++     " pop  %%r12              \n"
++     " pop  %%rbx              \n"
++     : [save_rsp]"=m"(save_rsp), [save_rip]"=m"(save_rip)
++     : "b" (code), [reg]"m"(*reg)
++     : "%rax", "memory"
++     );
+ #endif
+ 
+     /* clear flag; stack is back to normal */
diff --git a/debian/patches/series b/debian/patches/series
index 5bbc674..9241cbd 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ printf_fixup.patch
 api_header.patch
 rtc.patch
 n64_romswap.patch
+rjump_globber.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-core.git



More information about the Pkg-games-commits mailing list