From e755ea2374e6bdaad344165201c2d2ccb443a07f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 16 May 2019 10:12:42 +0200 Subject: [PATCH] winebuild: Support Windows-style name mangling for fastcall functions. Signed-off-by: Alexandre Julliard --- 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 ea9e939f29a..bec9f523eb8 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 04af2918c99..68b50f93e7c 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 d4f88457983..851a4a75cbf 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;