[lld] r239994 - COFF: Implement DLL symbol exports for bitcode files.

Rui Ueyama ruiu at google.com
Wed Jun 17 22:33:03 PDT 2015


On second thought, is this something the user of libLTO should do? It feels
something that libLTO itself should do.

On Wed, Jun 17, 2015 at 10:22 PM, Peter Collingbourne <peter at pcc.me.uk>
wrote:

> Author: pcc
> Date: Thu Jun 18 00:22:15 2015
> New Revision: 239994
>
> URL: http://llvm.org/viewvc/llvm-project?rev=239994&view=rev
> Log:
> COFF: Implement DLL symbol exports for bitcode files.
>
> Differential Revision: http://reviews.llvm.org/D10530
>
> Added:
>     lld/trunk/test/COFF/Inputs/export.ll
> Modified:
>     lld/trunk/COFF/InputFiles.cpp
>     lld/trunk/test/COFF/dll.test
>
> Modified: lld/trunk/COFF/InputFiles.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=239994&r1=239993&r2=239994&view=diff
>
> ==============================================================================
> --- lld/trunk/COFF/InputFiles.cpp (original)
> +++ lld/trunk/COFF/InputFiles.cpp Thu Jun 18 00:22:15 2015
> @@ -269,6 +269,14 @@ std::error_code BitcodeFile::parse() {
>        bool Replaceable = (SymbolDef == LTO_SYMBOL_DEFINITION_TENTATIVE ||
>                            (Attrs & LTO_SYMBOL_COMDAT));
>        SymbolBodies.push_back(new (Alloc) DefinedBitcode(SymName,
> Replaceable));
> +
> +      const llvm::GlobalValue *GV = M->getSymbolGV(I);
> +      if (GV && GV->hasDLLExportStorageClass()) {
> +        Directives += " /export:";
> +        Directives += SymName;
> +        if (!GV->getValueType()->isFunctionTy())
> +          Directives += ",data";
> +      }
>      }
>    }
>
>
> Added: lld/trunk/test/COFF/Inputs/export.ll
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/export.ll?rev=239994&view=auto
>
> ==============================================================================
> --- lld/trunk/test/COFF/Inputs/export.ll (added)
> +++ lld/trunk/test/COFF/Inputs/export.ll Thu Jun 18 00:22:15 2015
> @@ -0,0 +1,18 @@
> +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-pc-windows-msvc"
> +
> +define void @_DllMainCRTStartup() {
> +  ret void
> +}
> +
> +define void @exportfn1() {
> +  ret void
> +}
> +
> +define void @exportfn2() {
> +  ret void
> +}
> +
> +define dllexport void @exportfn3() {
> +  ret void
> +}
>
> Modified: lld/trunk/test/COFF/dll.test
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/dll.test?rev=239994&r1=239993&r2=239994&view=diff
>
> ==============================================================================
> --- lld/trunk/test/COFF/dll.test (original)
> +++ lld/trunk/test/COFF/dll.test Thu Jun 18 00:22:15 2015
> @@ -10,10 +10,26 @@ EXPORT:      Ordinal      RVA  Name
>  EXPORT-NEXT:       0        0
>  EXPORT-NEXT:       1   0x1008  exportfn1
>  EXPORT-NEXT:       2   0x1010  exportfn2
> +EXPORT-NEXT:       3   0x1010  exportfn3
> +
> +# RUN: llvm-as -o %t.lto.obj %p/Inputs/export.ll
> +# RUN: lld -flavor link2 /out:%t.lto.dll /dll %t.lto.obj
> /export:exportfn1 /export:exportfn2
> +# RUN: llvm-objdump -p %t.lto.dll | FileCheck -check-prefix=EXPORT-LTO %s
> +
> +EXPORT-LTO:      Export Table:
> +EXPORT-LTO:      DLL name: dll.test.tmp.lto.dll
> +EXPORT-LTO:      Ordinal      RVA  Name
> +EXPORT-LTO-NEXT:       0        0
> +EXPORT-LTO-NEXT:       1   0x1010  exportfn1
> +EXPORT-LTO-NEXT:       2   0x1020  exportfn2
> +EXPORT-LTO-NEXT:       3   0x1030  exportfn3
>
>  # RUN: yaml2obj < %p/Inputs/import.yaml > %t2.obj
>  # RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t.lib
>  # RUN: llvm-readobj -coff-imports %t2.exe | FileCheck
> -check-prefix=IMPORT %s
>
> +# RUN: lld -flavor link2 /out:%t2.lto.exe %t2.obj %t.lto.lib
> +# RUN: llvm-readobj -coff-imports %t2.lto.exe | FileCheck
> -check-prefix=IMPORT %s
> +
>  IMPORT: Symbol: exportfn1
>  IMPORT: Symbol: exportfn2
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150617/b0c8bdf6/attachment.html>


More information about the llvm-commits mailing list