diff options
author | Rui Ueyama <ruiu@google.com> | 2014-11-04 22:09:13 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-11-04 22:09:13 +0000 |
commit | 4f5cbc1a1ec5adb2d2f91138092b83dcd6e654a2 (patch) | |
tree | ee2044500748714c138aca05ba99202fa5f23ebb | |
parent | 860a1abf1d0bc97af527f1a01ea7c3358bd6a6a1 (diff) | |
download | bcm5719-llvm-4f5cbc1a1ec5adb2d2f91138092b83dcd6e654a2.tar.gz bcm5719-llvm-4f5cbc1a1ec5adb2d2f91138092b83dcd6e654a2.zip |
[PECOFF] Fix symbols in module-definition file.
llvm-svn: 221303
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp | 10 | ||||
-rw-r--r-- | lld/test/pecoff/exportlib2.test | 22 |
2 files changed, 25 insertions, 7 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp index 74ca2bfb86b..d6081c1cf4b 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp @@ -30,7 +30,15 @@ createModuleDefinitionFile(const PECOFFLinkingContext &ctx) { << "EXPORTS\n"; for (const PECOFFLinkingContext::ExportDesc &desc : ctx.getDllExports()) { - os << " " << desc.getExternalName(); + // Symbol names in a module-definition file will be mangled by lib.exe, + // so we need to demangle them before writing to a .def file. + os << " "; + if (!desc.externalName.empty()) { + os << desc.externalName; + } else { + os << ctx.undecorateSymbol(desc.name); + } + if (!desc.isPrivate) os << " @" << desc.ordinal; if (desc.noname) diff --git a/lld/test/pecoff/exportlib2.test b/lld/test/pecoff/exportlib2.test index f00073d423f..b2b070b2324 100644 --- a/lld/test/pecoff/exportlib2.test +++ b/lld/test/pecoff/exportlib2.test @@ -2,10 +2,20 @@ # # RUN: lld -flavor link /out:%t.dll /dll /entry:init \ # RUN: /export:exportfn1 /export:exportfn2 /lldmoduledeffile:%t.def -- %t.obj -# RUN: FileCheck %s < %t.def +# RUN: FileCheck -check-prefix=CHECK1 %s < %t.def -CHECK: LIBRARY "exportlib2.test.tmp.dll" -CHECK: EXPORTS -CHECK: exportfn1 @1 -CHECK: exportfn2 @2 -CHECK: exportfn3@256 @3 +CHECK1: LIBRARY "exportlib2.test.tmp.dll" +CHECK1: EXPORTS +CHECK1: exportfn1 @1 +CHECK1: exportfn2 @2 +CHECK1: exportfn3@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 + +CHECK2: LIBRARY "exportlib2.test.tmp.dll" +CHECK2: EXPORTS +CHECK2: exportfn1 @5 +CHECK2: exportfn2 @6 +CHECK2: exportfn3@256 @7 |