winebuild: Improved position independent code generation.

Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
André Hentschel 2017-08-06 14:31:09 +02:00 committed by Alexandre Julliard
parent a56bc8f93b
commit db848fa767
2 changed files with 16 additions and 22 deletions

View File

@ -668,15 +668,14 @@ static void output_import_thunk( const char *name, const char *table, int pos )
output( "1:\t.long %s+%u-(1b+4)\n", table, pos ); output( "1:\t.long %s+%u-(1b+4)\n", table, pos );
break; break;
case CPU_ARM64: case CPU_ARM64:
output( "\tadr x9, 1f\n" ); output( "\tadrp x9, %s\n", table );
output( "\tldur x9, [x9, #0]\n" ); output( "\tadd x9, x9, #:lo12:%s\n", table );
if (pos & 0xf000) output( "\tadd x9, x9, #%u\n", pos & 0xf000 ); if (pos & 0xf000) output( "\tadd x9, x9, #%u\n", pos & 0xf000 );
if (pos & 0x0f00) output( "\tadd x9, x9, #%u\n", pos & 0x0f00 ); if (pos & 0x0f00) output( "\tadd x9, x9, #%u\n", pos & 0x0f00 );
if (pos & 0x00f0) output( "\tadd x9, x9, #%u\n", pos & 0x00f0 ); if (pos & 0x00f0) output( "\tadd x9, x9, #%u\n", pos & 0x00f0 );
if (pos & 0x000f) output( "\tadd x9, x9, #%u\n", pos & 0x000f ); if (pos & 0x000f) output( "\tadd x9, x9, #%u\n", pos & 0x000f );
output( "\tldur x9, [x9, #0]\n" ); output( "\tldur x9, [x9, #0]\n" );
output( "\tbr x9\n" ); output( "\tbr x9\n" );
output( "1:\t.quad %s\n", table );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) ); output( "\tmr %s, %s\n", ppc_reg(0), ppc_reg(31) );
@ -980,8 +979,8 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
case CPU_ARM64: case CPU_ARM64:
output( "\tstp x29, x30, [sp,#-16]!\n" ); output( "\tstp x29, x30, [sp,#-16]!\n" );
output( "\tmov x29, sp\n" ); output( "\tmov x29, sp\n" );
output( "\tadr x9, 1f\n" ); output( "\tadrp x9, %s\n", asm_name("__wine_spec_delay_load") );
output( "\tldur x9, [x9, #0]\n" ); output( "\tadd x9, x9, #:lo12:%s\n", asm_name("__wine_spec_delay_load") );
output( "\tblr x9\n" ); output( "\tblr x9\n" );
output( "\tmov x9, x0\n" ); output( "\tmov x9, x0\n" );
output( "\tldp x29, x30, [sp],#16\n" ); output( "\tldp x29, x30, [sp],#16\n" );
@ -990,7 +989,6 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
output( "\tldp x4, x5, [sp,#48]\n" ); output( "\tldp x4, x5, [sp,#48]\n" );
output( "\tldp x6, x7, [sp],#80\n" ); output( "\tldp x6, x7, [sp],#80\n" );
output( "\tbr x9\n" ); /* or "ret x9" */ output( "\tbr x9\n" ); /* or "ret x9" */
output( "1:\t.quad %s\n", asm_name("__wine_spec_delay_load") );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
if (target_platform == PLATFORM_APPLE) extra_stack_storage = 56; if (target_platform == PLATFORM_APPLE) extra_stack_storage = 56;
@ -1089,10 +1087,8 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
output( "\tmul x1, x0, x1\n" ); output( "\tmul x1, x0, x1\n" );
output( "\tmov x0, x1\n" ); output( "\tmov x0, x1\n" );
output( "\tadd x0, x0, #%d\n", j ); output( "\tadd x0, x0, #%d\n", j );
output( "\tadr x9, 1f\n" ); output( "\tadr x9, %s\n", asm_name("__wine_delay_load_asm") );
output( "\tldur x9, [x9, #0]\n" );
output( "\tbr x9\n" ); output( "\tbr x9\n" );
output( "1:\t.quad %s\n", asm_name("__wine_delay_load_asm") );
break; break;
case CPU_POWERPC: case CPU_POWERPC:
switch(target_platform) switch(target_platform)
@ -1281,21 +1277,19 @@ void output_stubs( DLLSPEC *spec )
else output( "\t.long %u\n", odp->ordinal ); else output( "\t.long %u\n", odp->ordinal );
break; break;
case CPU_ARM64: case CPU_ARM64:
output( "\tadr x0, 2f\n" ); output( "\tadrp x0, %s\n", asm_name("__wine_spec_file_name") );
output( "\tldur x0, [x0, #0]\n" ); output( "\tadd x0, x0, #:lo12:%s\n", asm_name("__wine_spec_file_name") );
output( "\tadr x1, 2f+8\n" );
output( "\tldur x1, [x1, #0]\n" );
output( "\tadr x2, 1f\n" );
output( "\tldur x2, [x2, #0]\n" );
output( "\tblr x2\n" );
output( "1:\t.quad %s\n", asm_name("__wine_spec_unimplemented_stub") );
output( "2:\t.quad %s\n", asm_name("__wine_spec_file_name") );
if (exp_name) if (exp_name)
{ {
output( "\t.quad .L%s_string\n", name ); output( "\tadrp x1, .L%s_string\n", name );
output( "\tadd x1, x1, #:lo12:.L%s_string\n", name );
count++; count++;
} }
else output( "\t.quad %u\n", odp->ordinal ); else
output( "\tmov x1, %u\n", odp->ordinal );
output( "\tadrp x2, %s\n", asm_name("__wine_spec_unimplemented_stub") );
output( "\tadd x2, x2, #:lo12:%s\n", asm_name("__wine_spec_unimplemented_stub") );
output( "\tblr x2\n" );
break; break;
default: default:
assert(0); assert(0);

View File

@ -257,14 +257,14 @@ static void output_relay_debug( DLLSPEC *spec )
output( "\tmov w1, #%u\n", (flags << 24) ); output( "\tmov w1, #%u\n", (flags << 24) );
if (args) output( "\tadd w1, w1, #%u\n", (args << 16) ); if (args) output( "\tadd w1, w1, #%u\n", (args << 16) );
if (i - spec->base) output( "\tadd w1, w1, #%u\n", i - spec->base ); if (i - spec->base) output( "\tadd w1, w1, #%u\n", i - spec->base );
output( "\tldr x0, 1f\n"); output( "\tadrp x0, .L__wine_spec_relay_descr\n");
output( "\tadd x0, x0, #:lo12:.L__wine_spec_relay_descr\n");
output( "\tldr x3, [x0, #8]\n"); output( "\tldr x3, [x0, #8]\n");
output( "\tblr x3\n"); output( "\tblr x3\n");
output( "\tadd SP, SP, #16\n" ); output( "\tadd SP, SP, #16\n" );
output( "\tldp x29, x30, [SP], #16\n" ); output( "\tldp x29, x30, [SP], #16\n" );
if (args) output( "\tadd SP, SP, #%u\n", 8 * ((min(args, 8) + 1) & 0xe) ); if (args) output( "\tadd SP, SP, #%u\n", 8 * ((min(args, 8) + 1) & 0xe) );
output( "\tret\n"); output( "\tret\n");
output( "\t1: .quad .L__wine_spec_relay_descr\n");
break; break;
case CPU_x86_64: case CPU_x86_64: