Alexandre Julliard : winebuild: Support Windows-style name mangling for fastcall functions.

Alexandre Julliard julliard at winehq.org
Thu May 16 16:26:57 CDT 2019


Module: wine
Branch: master
Commit: e755ea2374e6bdaad344165201c2d2ccb443a07f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e755ea2374e6bdaad344165201c2d2ccb443a07f

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu May 16 10:12:42 2019 +0200

winebuild: Support Windows-style name mangling for fastcall functions.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/winebuild/parser.c |  7 -------
 tools/winebuild/spec32.c |  3 +++
 tools/winebuild/utils.c  | 26 ++++++++++++++++++++------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c
index ea9e939..bec9f52 100644
--- a/tools/winebuild/parser.c
+++ b/tools/winebuild/parser.c
@@ -374,13 +374,6 @@ static int parse_spec_export( ORDDEF *odp, DLLSPEC *spec )
             odp->flags |= FLAG_FORWARD;
         }
     }
-    if ((odp->flags & (FLAG_THISCALL | FLAG_FASTCALL)) && !(odp->flags & FLAG_FORWARD))
-    {
-        char *link_name = strmake( "__%s_%s", (odp->flags & FLAG_THISCALL) ? "thiscall" : "fastcall",
-                                   odp->link_name );
-        free( odp->link_name );
-        odp->link_name = link_name;
-    }
     return 1;
 }
 
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 04af291..68b50f9 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -970,6 +970,9 @@ void output_def_file( DLLSPEC *spec, int include_stubs )
         if (!is_private) total++;
         if (!include_stubs && odp->type == TYPE_STUB) continue;
 
+        if ((odp->flags & FLAG_FASTCALL) && target_platform == PLATFORM_WINDOWS)
+            name = strmake( "@%s", name );
+
         output( "  %s", name );
 
         switch(odp->type)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index d4f8845..851a4a7 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -893,15 +893,28 @@ const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec )
 const char *get_link_name( const ORDDEF *odp )
 {
     static char *buffer;
+    char *ret;
 
-    if (!kill_at && target_platform == PLATFORM_WINDOWS && target_cpu == CPU_x86 &&
-        odp->type == TYPE_STDCALL && !(odp->flags & FLAG_THISCALL))
+    if (target_cpu != CPU_x86) return odp->link_name;
+    if (odp->type != TYPE_STDCALL) return odp->link_name;
+
+    if (target_platform == PLATFORM_WINDOWS)
     {
-        free( buffer );
-        buffer = strmake( "%s@%u", odp->link_name, get_args_size( odp ));
-        return buffer;
+        if (odp->flags & FLAG_THISCALL) ret = strmake( "__thiscall_%s", odp->link_name );
+        else if (odp->flags & FLAG_FASTCALL) ret = strmake( "@%s@%u", odp->link_name, get_args_size( odp ));
+        else if (!kill_at) ret = strmake( "%s@%u", odp->link_name, get_args_size( odp ));
+        else return odp->link_name;
     }
-    return odp->link_name;
+    else
+    {
+        if (odp->flags & FLAG_THISCALL) ret = strmake( "__thiscall_%s", odp->link_name );
+        else if (odp->flags & FLAG_FASTCALL) ret = strmake( "__fastcall_%s", odp->link_name );
+        else return odp->link_name;
+    }
+
+    free( buffer );
+    buffer = ret;
+    return ret;
 }
 
 /* parse a cpu name and return the corresponding value */
@@ -1036,6 +1049,7 @@ const char *asm_name( const char *sym )
     {
     case PLATFORM_WINDOWS:
         if (target_cpu != CPU_x86) return sym;
+        if (sym[0] == '@') return sym;  /* fastcall */
         /* fall through */
     case PLATFORM_APPLE:
         if (sym[0] == '.' && sym[1] == 'L') return sym;




More information about the wine-cvs mailing list