Here is a patch which fix the problem with darwin's asm. I would like to know if linux assembler is ok with this patch.
By the way I have some modifications which are Darwin specific (Mach-O related). I would like to know how you would like me to integrate them. For example:
fprintf( outfile, "\".section\\t\\\".text\\\"\");\n#ifndef __GNUC__\n}\n#endif\n\n" );
needs to be changed to:
fprintf( outfile, "\".text\");\n#ifndef __GNUC__\n}\n#endif\n\n" );
Thanks,
Pierre
ChangeLog:
- Change PowerPC assembler syntax to match darwin's asm syntax
- Fix the PowerPC li mnemonic which load only 16bits at one time
Modified Files:
tool/winebuild/import.c
Index: tools/winebuild/import.c =================================================================== RCS file: /home/wine/wine/tools/winebuild/import.c,v retrieving revision 1.50 diff -u -r1.50 import.c --- tools/winebuild/import.c 14 May 2003 19:36:28 -0000 1.50 +++ tools/winebuild/import.c 23 Jun 2003 11:24:56 -0000 @@ -819,24 +819,24 @@ } #elif defined(__PPC__) - fprintf(outfile, "\taddi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 9, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 8, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 7, 0(1)\\n\"\n"); - - fprintf(outfile, "\t\"\\tlis 9,imports+%d@ha\\n\"\n", pos); - fprintf(outfile, "\t\"\\tla 8,imports+%d@l(9)\\n\"\n", pos); - fprintf(outfile, "\t\"\\tlwz 7, 0(8)\\n\"\n"); - fprintf(outfile, "\t\"\\tmtctr 7\\n\"\n"); - - fprintf(outfile, "\t\"\\tlwz 7, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tlwz 8, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tlwz 9, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); + fprintf(outfile, "\taddi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r9, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r8, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r7, 0(r1)\\n\"\n"); + + fprintf(outfile, "\t\"\\tlis r9,ha16(_imports+%d)\\n\"\n", pos); + fprintf(outfile, "\t\"\\tla r8,lo16(_imports+%d)(r9)\\n\"\n", pos); + fprintf(outfile, "\t\"\\tlwz r7, 0(r8)\\n\"\n"); + fprintf(outfile, "\t\"\\tmtctr r7\\n\"\n"); + + fprintf(outfile, "\t\"\\tlwz r7, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tlwz r8, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tlwz r9, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); fprintf(outfile, "\t\"\\tbctr\\n"); #else #error You need to define import thunks for your architecture! @@ -846,7 +846,7 @@ pos += 4; } fprintf( outfile, "\".section\\t\\\".text\\\"\");\n#ifndef __GNUC__\n}\n#endif\n\n" ); - + done: return nb_imm; } @@ -983,49 +983,50 @@ fprintf( outfile, " \"\\tjmp %%o0\\n\\trestore\\n\"\n" ); #elif defined(__PPC__) /* Save all callee saved registers into a stackframe. */ - fprintf( outfile, " \"\\tstwu %%r1, -48(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r3, 4(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r4, 8(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r5, 12(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r6, 16(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r7, 20(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r8, 24(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r9, 28(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r10, 32(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r11, 36(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r12, 40(%%r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstwu r1, -48(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r3, 4(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r4, 8(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r5, 12(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r6, 16(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r7, 20(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r8, 24(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r9, 28(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r10, 32(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r11, 36(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tstw r12, 40(r1)\\n\"\n" ); /* r0 -> r3 (arg1) */ - fprintf( outfile, " \"\\tmr %%r3, %%r0\\n\"\n" ); + fprintf( outfile, " \"\\tmr r3, r0\\n\"\n" ); /* save return address */ - fprintf( outfile, " \"\\tmflr %%r0\\n\"\n" ); - fprintf( outfile, " \"\\tstw %%r0, 44(%%r1)\\n\"\n" ); + fprintf( outfile, " \"\\tmflr r0\\n\"\n" ); + fprintf( outfile, " \"\\tstw r0, 44(r1)\\n\"\n" ); /* Call the __wine_delay_load function, arg1 is arg1. */ - fprintf( outfile, " \"\\tbl __wine_delay_load\\n\"\n" ); + fprintf( outfile, " \"\\tbl "__ASM_NAME("__wine_delay_load") "\\n\"\n" ); /* Load return value from call into ctr register */ - fprintf( outfile, " \"\\tmtctr %%r3\\n\"\n" ); + fprintf( outfile, " \"\\tmtctr r3\\n\"\n" ); /* restore all saved registers and drop stackframe. */ - fprintf( outfile, " \"\\tlwz %%r3, 4(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r4, 8(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r5, 12(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r6, 16(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r7, 20(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r8, 24(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r9, 28(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r10, 32(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r11, 36(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tlwz %%r12, 40(%%r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r3, 4(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r4, 8(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r5, 12(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r6, 16(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r7, 20(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r8, 24(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r9, 28(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r10, 32(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r11, 36(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r12, 40(r1)\\n\"\n" ); + /* Load return value from call into return register */ - fprintf( outfile, " \"\\tlwz %%r0, 44(%%r1)\\n\"\n" ); - fprintf( outfile, " \"\\tmtlr %%r0\\n\"\n" ); - fprintf( outfile, " \"\\taddi %%r1, %%r1, 48\\n\"\n" ); + fprintf( outfile, " \"\\tlwz r0, 44(r1)\\n\"\n" ); + fprintf( outfile, " \"\\tmtlr r0\\n\"\n" ); + fprintf( outfile, " \"\\taddi r1, r1, 48\\n\"\n" ); + /* branch to ctr register. */ fprintf( outfile, " \"\\tbctr\\n\"\n" ); - #else #error You need to defined delayed import thunks for your architecture! #endif @@ -1047,8 +1048,10 @@ fprintf( outfile, " \"\\tb,a __wine_delay_load_asm\\n\"\n" ); #elif defined(__PPC__) /* g0 is a function scratch register or so I understand. */ - fprintf( outfile, " \"\\tli %%r0, %d\\n\"\n", (idx << 16) | j ); - fprintf( outfile, " \"\\tb __wine_delay_load_asm\\n\"\n" ); + /* First load the upper half-word, and then the lower part */ + fprintf( outfile, " \"\\taddis r0,0, 0x%x\\n\"\n", idx ); + fprintf( outfile, " \"\\taddi r0,0, 0x%x\\n\"\n", j ); + fprintf( outfile, " \"\\tb ___wine_delay_load_asm\\n\"\n" ); #else #error You need to defined delayed import thunks for your architecture! #endif @@ -1092,37 +1095,36 @@ } #elif defined(__PPC__) - fprintf(outfile, "\t\"addi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 9, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 8, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tstw 7, 0(1)\\n\"\n"); - - fprintf(outfile, "\t\"\\tlis 9,delay_imports+%d@ha\\n\"\n", pos); - fprintf(outfile, "\t\"\\tla 8,delay_imports+%d@l(9)\\n\"\n", pos); - fprintf(outfile, "\t\"\\tlwz 7, 0(8)\\n\"\n"); - fprintf(outfile, "\t\"\\tmtctr 7\\n\"\n"); - - fprintf(outfile, "\t\"\\tlwz 7, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tlwz 8, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); - fprintf(outfile, "\t\"\\tlwz 9, 0(1)\\n\"\n"); - fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n"); + fprintf(outfile, "\t\"addi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r9, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r8, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tstw r7, 0(r1)\\n\"\n"); + + fprintf(outfile, "\t\"\\tlis r9,ha16(_delay_imports+%d)\\n\"\n", pos); + fprintf(outfile, "\t\"\\tla r8,lo16(_delay_imports+%d)(r9)\\n\"\n", pos); + fprintf(outfile, "\t\"\\tlwz r7, 0(r8)\\n\"\n"); + fprintf(outfile, "\t\"\\tmtctr r7\\n\"\n"); + + fprintf(outfile, "\t\"\\tlwz r7, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tlwz r8, 0(r1)\\n\"\n"); + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); + fprintf(outfile, "\t\"\\tlwz r9, 0(r1)\\n\"\n"); + + fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n"); fprintf(outfile, "\t\"\\tbctr\\n\""); - /*fprintf(outfile, "\t\"li r0,delay_imports\\n\\t\"\n" ); - fprintf(outfile, "\t\"lwz r0, %d(r0)\\n\\t\"\n", pos); - fprintf(outfile, "\t\"mtctr r0\\n\\t\"\n"); - fprintf(outfile, "\t\"bctr\\n\"");*/ #else #error You need to define delayed import thunks for your architecture! #endif fprintf( outfile, "\n" ); } } + fprintf( outfile, "\".section \\\".text\\\"\");\n" ); + fprintf( outfile, "#ifndef __GNUC__\n" ); fprintf( outfile, "}\n" ); fprintf( outfile, "#endif\n" );