diff --git a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp index d6081c1cf4b8..fd3360f018b6 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp @@ -35,6 +35,8 @@ createModuleDefinitionFile(const PECOFFLinkingContext &ctx) { os << " "; if (!desc.externalName.empty()) { os << desc.externalName; + } else if (!desc.mangledName.empty()) { + os << ctx.undecorateSymbol(desc.mangledName); } else { os << ctx.undecorateSymbol(desc.name); } diff --git a/lld/test/pecoff/Inputs/exports2.def b/lld/test/pecoff/Inputs/exports2.def new file mode 100644 index 000000000000..1c95f42ceb60 --- /dev/null +++ b/lld/test/pecoff/Inputs/exports2.def @@ -0,0 +1,6 @@ +; This is a comment line + +EXPORTS + exportfn1 @5 ; foo + exportfn7 + exportfn5=exportfn6 PRIVATE diff --git a/lld/test/pecoff/exportlib2.test b/lld/test/pecoff/exportlib2.test index b2b070b23249..e846b0bdd064 100644 --- a/lld/test/pecoff/exportlib2.test +++ b/lld/test/pecoff/exportlib2.test @@ -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@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@256 @7 +CHECK2: exportfn3@256 @6 +CHECK2: exportfn7@8 @7