From 238e1868b2b29df813250ae2961a68a9b744f2f6 Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Sat, 31 May 2008 10:51:01 +0200 Subject: [PATCH] winebuild: Fix import stub on ppc. The address calculation was wrong, as the addition of the lower 16 bits is a signed addition, so if bit 15 is set, the upper 16 bits need to be incremented by one (so the hi portion of the symbol always references the symbol + 0x8000). --- tools/winebuild/import.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 5b62512a53b..5e0c172de29 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -699,30 +699,20 @@ static void output_import_thunk( const char *name, const char *table, int pos ) output( "\tjmp $31,($0)\n" ); break; case CPU_POWERPC: - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) ); - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) ); - output( "\taddi %s, %s, -0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tstw %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) ); + output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) ); if (target_platform == PLATFORM_APPLE) { - output( "\tlis %s, ha16(%s+%d)\n", ppc_reg(9), table, pos ); - output( "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) ); + output( "\tlis %s, ha16(%s+%d+32768)\n", ppc_reg(31), table, pos ); + output( "\tla %s, lo16(%s+%d)(%s)\n", ppc_reg(31), table, pos, ppc_reg(31) ); } else { - output( "\tlis %s, (%s+%d)@h\n", ppc_reg(9), table, pos ); - output( "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(8), table, pos, ppc_reg(9) ); + output( "\tlis %s, (%s+%d+32768)@h\n", ppc_reg(31), table, pos ); + output( "\tla %s, (%s+%d)@l(%s)\n", ppc_reg(31), table, pos, ppc_reg(31) ); } - output( "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(8) ); - output( "\tmtctr %s\n", ppc_reg(7) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(7), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(8), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); - output( "\tlwz %s, 0(%s)\n", ppc_reg(9), ppc_reg(1) ); - output( "\taddi %s, %s, 0x4\n", ppc_reg(1), ppc_reg(1) ); + output( "\tlwz %s, 0(%s)\n", ppc_reg(31), ppc_reg(31) ); + output( "\tmtctr %s\n", ppc_reg(31) ); + output( "\tmr %s, %s\n", ppc_reg(31), ppc_reg(0) ); output( "\tbctr\n" ); break; } -- 2.11.4.GIT