[lld] r208452 - [PECOFF] Resolve dllexported symbols.

Rui Ueyama ruiu at google.com
Fri May 9 15:19:49 PDT 2014


Author: ruiu
Date: Fri May  9 17:19:49 2014
New Revision: 208452

URL: http://llvm.org/viewvc/llvm-project?rev=208452&view=rev
Log:
[PECOFF] Resolve dllexported symbols.

We did not actively try to resolve dllexported symbols specified
by /export or by a module definition file. So if exported symbols
would be resolved for other reasons, like other symbols refer to
them, that was fine, but if (unreferenced) exported symbols were
in an archive file, and no one refers to that file in the archive,
they remained unresolved.

That would obviously cause the issue that dllexported symbols are
not in a resultant DLL.

In this patch, we create an undefined symbol for each dllexported
symbol, to let the core linker to resolve it.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/test/pecoff/Inputs/export.obj.yaml
    lld/trunk/test/pecoff/exportlib2.test

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=208452&r1=208451&r2=208452&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Fri May  9 17:19:49 2014
@@ -262,6 +262,7 @@ static bool exportConflicts(const PECOFF
 }
 
 void PECOFFLinkingContext::addDllExport(ExportDesc &desc) {
+  addInitialUndefinedSymbol(allocate(desc.name));
   auto existing = _dllExports.insert(desc);
   if (existing.second)
     return;

Modified: lld/trunk/test/pecoff/Inputs/export.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/export.obj.yaml?rev=208452&r1=208451&r2=208452&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/export.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/export.obj.yaml Fri May  9 17:19:49 2014
@@ -36,7 +36,7 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
-  - Name:            "_exportfn2 at 8"
+  - Name:            _exportfn2
     Value:           16
     SectionNumber:   1
     SimpleType:      IMAGE_SYM_TYPE_NULL

Modified: lld/trunk/test/pecoff/exportlib2.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/exportlib2.test?rev=208452&r1=208451&r2=208452&view=diff
==============================================================================
--- lld/trunk/test/pecoff/exportlib2.test (original)
+++ lld/trunk/test/pecoff/exportlib2.test Fri May  9 17:19:49 2014
@@ -7,4 +7,5 @@
 CHECK: LIBRARY "exportlib2.test.tmp.dll"
 CHECK: EXPORTS
 CHECK:   exportfn1 @1
-CHECK:   exportfn2 at 8 @2
+CHECK:   exportfn2 @2
+CHECK:   exportfn3 at 256 @3





More information about the llvm-commits mailing list