[lld] r310989 - [COFF] Fix the name type for stdcall functions in import libraries

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 09:59:44 PDT 2017


Merged to 5.0 in r311098.

On Tue, Aug 15, 2017 at 10:13 PM, Martin Storsjo via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: mstorsjo
> Date: Tue Aug 15 22:13:25 2017
> New Revision: 310989
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310989&view=rev
> Log:
> [COFF] Fix the name type for stdcall functions in import libraries
>
> Since SVN r303491 and r304573, LLD used the COFFImportLibrary
> functions from LLVM. These only had two names, Name and ExtName,
> which wasn't enough to convey all the details of stdcall functions.
>
> Stdcall functions got the wrong symbol name in the import library
> itself in r303491, which is why it was reverted in r304561. When
> re-landed and fixed in r304573 (after adding a test in r304572),
> the symbol name itself in the import library ended up right, but the
> name type of the import library entry was wrong.
>
> This had the effect that linking to the import library succeeded
> (contrary to in r303491, where linking to such an import library
> failed), but at runtime, the symbol wouldn't be found in the DLL
> (since the caller linked to the stdcall decorated name).
>
> Differential Revision: https://reviews.llvm.org/D36545
>
> Modified:
>     lld/trunk/COFF/Driver.cpp
>     lld/trunk/test/COFF/def-export-stdcall.s
>
> Modified: lld/trunk/COFF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=310989&r1=310988&r2=310989&view=diff
> ==============================================================================
> --- lld/trunk/COFF/Driver.cpp (original)
> +++ lld/trunk/COFF/Driver.cpp Tue Aug 15 22:13:25 2017
> @@ -461,8 +461,8 @@ static void createImportLibrary(bool AsL
>    std::vector<COFFShortExport> Exports;
>    for (Export &E1 : Config->Exports) {
>      COFFShortExport E2;
> -    // Use SymbolName, which will have any stdcall or fastcall qualifiers.
> -    E2.Name = E1.SymbolName;
> +    E2.Name = E1.Name;
> +    E2.SymbolName = E1.SymbolName;
>      E2.ExtName = E1.ExtName;
>      E2.Ordinal = E1.Ordinal;
>      E2.Noname = E1.Noname;
>
> Modified: lld/trunk/test/COFF/def-export-stdcall.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/def-export-stdcall.s?rev=310989&r1=310988&r2=310989&view=diff
> ==============================================================================
> --- lld/trunk/test/COFF/def-export-stdcall.s (original)
> +++ lld/trunk/test/COFF/def-export-stdcall.s Tue Aug 15 22:13:25 2017
> @@ -2,7 +2,8 @@
>  # RUN: llvm-mc -filetype=obj -triple=i686-windows-msvc %s -o %t.obj
>  # RUN: echo -e "LIBRARY foo\nEXPORTS\n  stdcall" > %t.def
>  # RUN: lld-link -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib
> -# RUN: llvm-nm %t.lib | FileCheck %s
> +# RUN: llvm-readobj %t.lib | FileCheck %s
> +# CHECK: Name type: undecorate
>  # CHECK: __imp__stdcall at 8
>  # CHECK: _stdcall at 8
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list