[lld] r223524 - [PECOFF] Fix exported symbols in an import library.
Rui Ueyama
ruiu at google.com
Fri Dec 5 13:52:02 PST 2014
Author: ruiu
Date: Fri Dec 5 15:52:02 2014
New Revision: 223524
URL: http://llvm.org/viewvc/llvm-project?rev=223524&view=rev
Log:
[PECOFF] Fix exported symbols in an import library.
Looks like if you have symbol foo in a module-definition file
(.def file), and if the actual symbol name to match that export
description is _foo at x (where x is an integer), the exported
symbol name becomes this.
- foo in the .dll file
- foo at x in the .lib file
I have checked in a few fixes recently for exported symbol name mangling.
I haven't found a simple rule that governs all the mangling rules.
There may not ever exist. For now, this is a patch to improve .lib
file compatibility.
Added:
lld/trunk/test/pecoff/Inputs/exports2.def
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp
lld/trunk/test/pecoff/exportlib2.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp?rev=223524&r1=223523&r2=223524&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp Fri Dec 5 15:52:02 2014
@@ -35,6 +35,8 @@ createModuleDefinitionFile(const PECOFFL
os << " ";
if (!desc.externalName.empty()) {
os << desc.externalName;
+ } else if (!desc.mangledName.empty()) {
+ os << ctx.undecorateSymbol(desc.mangledName);
} else {
os << ctx.undecorateSymbol(desc.name);
}
Added: lld/trunk/test/pecoff/Inputs/exports2.def
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/exports2.def?rev=223524&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/exports2.def (added)
+++ lld/trunk/test/pecoff/Inputs/exports2.def Fri Dec 5 15:52:02 2014
@@ -0,0 +1,6 @@
+; This is a comment line
+
+EXPORTS
+ exportfn1 @5 ; foo
+ exportfn7
+ exportfn5=exportfn6 PRIVATE
Modified: lld/trunk/test/pecoff/exportlib2.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/exportlib2.test?rev=223524&r1=223523&r2=223524&view=diff
==============================================================================
--- lld/trunk/test/pecoff/exportlib2.test (original)
+++ lld/trunk/test/pecoff/exportlib2.test Fri Dec 5 15:52:02 2014
@@ -1,8 +1,8 @@
# RUN: yaml2obj %p/Inputs/export.obj.yaml > %t.obj
#
# RUN: lld -flavor link /out:%t.dll /dll /entry:init \
-# RUN: /export:exportfn1 /export:exportfn2 /lldmoduledeffile:%t.def -- %t.obj
-# RUN: FileCheck -check-prefix=CHECK1 %s < %t.def
+# RUN: /export:exportfn1 /export:exportfn2 /lldmoduledeffile:%t1.def -- %t.obj
+# RUN: FileCheck -check-prefix=CHECK1 %s < %t1.def
CHECK1: LIBRARY "exportlib2.test.tmp.dll"
CHECK1: EXPORTS
@@ -11,11 +11,11 @@ CHECK1: exportfn2 @2
CHECK1: exportfn3 at 256 @3
# RUN: lld -flavor link /out:%t.dll /dll /entry:init \
-# RUN: /def:%p/Inputs/exports.def /lldmoduledeffile:%t.def -- %t.obj
-# RUN: FileCheck -check-prefix=CHECK2 %s < %t.def
+# RUN: /def:%p/Inputs/exports2.def /lldmoduledeffile:%t2.def -- %t.obj
+# RUN: FileCheck -check-prefix=CHECK2 %s < %t2.def
CHECK2: LIBRARY "exportlib2.test.tmp.dll"
CHECK2: EXPORTS
CHECK2: exportfn1 @5
-CHECK2: exportfn2 @6
-CHECK2: exportfn3 at 256 @7
+CHECK2: exportfn3 at 256 @6
+CHECK2: exportfn7 at 8 @7
More information about the llvm-commits
mailing list