Delayed Import on PowerPC Part 2

Pierre d'Herbemont stegefin at free.fr
Wed Jul 14 17:02:22 CDT 2004


Hi!

This patch fix delay import on PowerPC. The lis and li instructions 
previously used weren't the right, since li erase the register content, 
before loading its lower part. Delay import were only working when 
there weren't many imports.
Also is included a fix for the Stack Size on Darwin, 56 bits  is more 
accurate than the previous 24 bits.

Thanks,

Pierre
ChangeLog:
- Be more accurate on Darwin stack size
- Delay Import fix on PowerPC Hosts.

-------------- next part --------------
Index: tools/winebuild/import.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/import.c,v
retrieving revision 1.66
diff -u -r1.66 import.c
--- tools/winebuild/import.c	14 Jul 2004 21:42:18 -0000	1.66
+++ tools/winebuild/import.c	14 Jul 2004 21:56:10 -0000
@@ -899,8 +899,8 @@
     fprintf( outfile, "    \"\\tjmp %%o0\\n\\trestore\\n\"\n" );
 #elif defined(__powerpc__)
 # if defined(__APPLE__)
-/* On darwin an extra 24 bytes must be allowed for the linkage area */
-#  define extra_stack_storage    24
+/* On darwin an extra 56 bits must be allowed for the linkage area+param area */
+#  define extra_stack_storage    56
 # else
 #  define extra_stack_storage    0
 # endif
@@ -973,11 +973,27 @@
             fprintf( outfile, "    \"\\tset %d, %%g1\\n\"\n", (idx << 16) | j );
             fprintf( outfile, "    \"\\tb,a __wine_delay_load_asm\\n\"\n" );
 #elif defined(__powerpc__)
-            /* g0 is a function scratch register or so I understand. */
-            /* First load the upper half-word, and then the lower part */
-            fprintf( outfile, "    \"\\tlis %s, %d\\n\"\n", ppc_reg[0], idx);
-            fprintf( outfile, "    \"\\tli %s, %d\\n\"\n", ppc_reg[0], j);
+#ifdef __APPLE__
+            /* On Darwin we can use r0 and r2 */
+            /* Upper part in r2 */
+            fprintf( outfile, "    \"\\tlis %s, %d\\n\"\n", ppc_reg[2], idx);
+            /* Lower part + r2 -> r0, Note we can't use r0 directly */
+            fprintf( outfile, "    \"\\taddi %s, %s, %d\\n\"\n", ppc_reg[0], ppc_reg[2], j);
             fprintf( outfile, "    \"\\tb " __ASM_NAME("__wine_delay_load_asm") "\\n\"\n");
+#else /* __APPLE__ */
+            /* On linux we can't use r2 since r2 is not a scratch register (hold the TOC) */
+            /* Save r13 on the stack */
+            fprintf( outfile, "    \"addi %s, %s, -0x4\\n\"\n", ppc_reg[1], ppc_reg[1]);
+            fprintf( outfile, "    \"\\tstw  %s, 0(%s)\\n\"\n",    ppc_reg[13], ppc_reg[1]);
+            /* Upper part in r13 */
+            fprintf( outfile, "    \"\\tlis %s, %d\\n\"\n", ppc_reg[13], idx);
+            /* Lower part + r13 -> r0, Note we can't use r0 directly */
+            fprintf( outfile, "    \"\\taddi %s, %s, %d\\n\"\n", ppc_reg[0], ppc_reg[13], j);
+            /* Restore r13 */
+            fprintf( outfile, "    \"\\tstw  %s, 0(%s)\\n\"\n",    ppc_reg[13], ppc_reg[1]);
+            fprintf( outfile, "    \"addic %s, %s, 0x4\\n\"\n", ppc_reg[1], ppc_reg[1]);
+            fprintf( outfile, "    \"\\tb " __ASM_NAME("__wine_delay_load_asm") "\\n\"\n");
+#endif /* __APPLE__ */
 #else
 #error You need to defined delayed import thunks for your architecture!
 #endif


More information about the wine-patches mailing list