[PATCH 1/4] winebuild: Use the right arm64 page/pageoff relocation syntax for darwin

Martin Storsjo martin at martin.st
Fri Aug 14 06:54:14 CDT 2020


Signed-off-by: Martin Storsjo <martin at martin.st>
---
 tools/winebuild/build.h  |  2 ++
 tools/winebuild/import.c | 34 ++++++++++++++++++----------------
 tools/winebuild/spec32.c |  4 ++--
 tools/winebuild/utils.c  | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index e1d2e5edf8..03715af956 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -291,6 +291,8 @@ extern const char *get_asm_export_section(void);
 extern const char *get_asm_rodata_section(void);
 extern const char *get_asm_rsrc_section(void);
 extern const char *get_asm_string_section(void);
+extern const char *arm64_page( const char *sym );
+extern const char *arm64_pageoff( const char *sym );
 extern void output_function_size( const char *name );
 extern void output_gnu_stack_note(void);
 
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index da9ad62022..751335f36f 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -761,8 +761,8 @@ static void output_import_thunk( const char *name, const char *table, int pos )
         output( "1:\t.long %s+%u-(1b+4)\n", table, pos );
         break;
     case CPU_ARM64:
-        output( "\tadrp x9, %s\n", table );
-        output( "\tadd x9, x9, #:lo12:%s\n", table );
+        output( "\tadrp x9, %s\n", arm64_page( table ) );
+        output( "\tadd x9, x9, #%s\n", arm64_pageoff( table ) );
         if (pos & 0xf000) output( "\tadd x9, x9, #%u\n", pos & 0xf000 );
         if (pos & 0x0f00) output( "\tadd x9, x9, #%u\n", pos & 0x0f00 );
         if (pos & 0x00f0) output( "\tadd x9, x9, #%u\n", pos & 0x00f0 );
@@ -1080,8 +1080,8 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
     case CPU_ARM64:
         output( "\tstp x29, x30, [sp,#-16]!\n" );
         output( "\tmov x29, sp\n" );
-        output( "\tadrp x9, %s\n", asm_name("__wine_spec_delay_load") );
-        output( "\tadd x9, x9, #:lo12:%s\n", asm_name("__wine_spec_delay_load") );
+        output( "\tadrp x9, %s\n", arm64_page( asm_name("__wine_spec_delay_load") ) );
+        output( "\tadd x9, x9, #%s\n", arm64_pageoff( asm_name("__wine_spec_delay_load") ) );
         output( "\tblr x9\n" );
         output( "\tmov x9, x0\n" );
         output( "\tldp x29, x30, [sp],#16\n" );
@@ -1367,17 +1367,19 @@ void output_stubs( DLLSPEC *spec )
             else output( "\t.long %u\n", odp->ordinal );
             break;
         case CPU_ARM64:
-            output( "\tadrp x0, .L__wine_spec_file_name\n" );
-            output( "\tadd x0, x0, #:lo12:.L__wine_spec_file_name\n" );
+            output( "\tadrp x0, %s\n", arm64_page(".L__wine_spec_file_name") );
+            output( "\tadd x0, x0, #%s\n", arm64_pageoff(".L__wine_spec_file_name") );
             if (exp_name)
             {
-                output( "\tadrp x1, .L%s_string\n", name );
-                output( "\tadd x1, x1, #:lo12:.L%s_string\n", name );
+                char *sym = strmake( ".L%s_string", name );
+                output( "\tadrp x1, %s\n", arm64_page( sym ) );
+                output( "\tadd x1, x1, #%s\n", arm64_pageoff( sym ) );
+                free( sym );
             }
             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( "\tadrp x2, %s\n", arm64_page( asm_name("__wine_spec_unimplemented_stub") ) );
+            output( "\tadd x2, x2, #%s\n", arm64_pageoff( asm_name("__wine_spec_unimplemented_stub") ) );
             output( "\tblr x2\n" );
             break;
         default:
@@ -1627,8 +1629,8 @@ void output_syscalls( DLLSPEC *spec )
             output( "\tldr x20, [x19]\n" );  /* prev frame */
             output( "\tstr x20, [sp, #88]\n" );
             output( "\tstr x29, [x19]\n" );  /* syscall frame */
-            output( "\tadrp x16, .Lsyscall_args\n" );
-            output( "\tadd x16, x16, #:lo12:.Lsyscall_args\n" );
+            output( "\tadrp x16, %s\n", arm64_page(".Lsyscall_args") );
+            output( "\tadd x16, x16, #%s\n", arm64_pageoff(".Lsyscall_args") );
             output( "\tldrb w9, [x16, x8]\n" );
             output( "\tsubs x9, x9, #64\n" );
             output( "\tbls 2f\n" );
@@ -1640,8 +1642,8 @@ void output_syscalls( DLLSPEC *spec )
             output( "\tldr x10, [x11, x9]\n" );
             output( "\tstr x10, [sp, x9]\n" );
             output( "\tcbnz x9, 1b\n" );
-            output( "2:\tadrp x16, .Lsyscall_table\n" );
-            output( "\tadd x16, x16, #:lo12:.Lsyscall_table\n" );
+            output( "2:\tadrp x16, %s\n", arm64_page(".Lsyscall_table") );
+            output( "\tadd x16, x16, #%s\n", arm64_pageoff(".Lsyscall_table") );
             output( "\tldr x16, [x16, x8, lsl 3]\n" );
             output( "\tblr x16\n" );
             output( "\tmov sp, x29\n" );
@@ -1741,8 +1743,8 @@ void output_syscalls( DLLSPEC *spec )
         case CPU_ARM64:
             output( "\tstp x29, x30, [sp,#-16]!\n" );
             output( "\tmov x8, #%u\n", i );
-            output( "\tadrp x16, %s\n", asm_name("__wine_syscall_dispatcher") );
-            output( "\tldr x16, [x16, #:lo12:%s]\n", asm_name("__wine_syscall_dispatcher") );
+            output( "\tadrp x16, %s\n", arm64_page( asm_name("__wine_syscall_dispatcher") ) );
+            output( "\tldr x16, [x16, #%s]\n", arm64_pageoff( asm_name("__wine_syscall_dispatcher") ) );
             output( "\tblr x16\n");
             output( "\tldp x29, x30, [sp], #16\n" );
             output( "\tret\n" );
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index c85249b2a9..efb136a8e6 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -339,8 +339,8 @@ static void output_relay_debug( DLLSPEC *spec )
             output( "\tstp x8, x9, [SP,#-16]!\n" );
             output( "\tmov w1, #%u\n", odp->u.func.args_str_offset << 16 );
             if (i - spec->base) output( "\tadd w1, w1, #%u\n", i - spec->base );
-            output( "\tadrp x0, .L__wine_spec_relay_descr\n");
-            output( "\tadd x0, x0, #:lo12:.L__wine_spec_relay_descr\n");
+            output( "\tadrp x0, %s\n", arm64_page(".L__wine_spec_relay_descr") );
+            output( "\tadd x0, x0, #%s\n", arm64_pageoff(".L__wine_spec_relay_descr") );
             output( "\tldr x3, [x0, #8]\n");
             output( "\tblr x3\n");
             output( "\tadd SP, SP, #16\n" );
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 07ef2ed298..1af42f1000 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -1291,3 +1291,35 @@ const char *get_asm_string_section(void)
     default:             return ".section .rodata";
     }
 }
+
+const char *arm64_page( const char *sym )
+{
+    static char *buffer;
+
+    switch (target_platform)
+    {
+    case PLATFORM_APPLE:
+        free( buffer );
+        buffer = strmake( "%s at PAGE", sym );
+        return buffer;
+    default:
+        return sym;
+    }
+}
+
+const char *arm64_pageoff( const char *sym )
+{
+    static char *buffer;
+
+    free( buffer );
+    switch (target_platform)
+    {
+    case PLATFORM_APPLE:
+        buffer = strmake( "%s at PAGEOFF", sym );
+        break;
+    default:
+        buffer = strmake( ":lo12:%s", sym );
+        break;
+    }
+    return buffer;
+}
-- 
2.17.1




More information about the wine-devel mailing list