diff options
Diffstat (limited to 'lld')
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp | 10 | ||||
-rw-r--r-- | lld/test/pecoff/export.test | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index b8f8e39cdcd..ae236f475ba 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -261,6 +261,16 @@ static bool sameExportDesc(const PECOFFLinkingContext::ExportDesc &a, void PECOFFLinkingContext::addDllExport(ExportDesc &desc) { addInitialUndefinedSymbol(allocate(desc.name)); + // MSVC link.exe silently drops characters after the first atsign. + // For example, /export:foo@4=bar is equivalent to /export:foo=bar. + // We do the same thing for compatibility. + if (!desc.externalName.empty()) { + StringRef s(desc.externalName); + size_t pos = s.find('@'); + if (pos != s.npos) + desc.externalName = s.substr(0, pos); + } + // Scan the vector to look for existing entry. It's not very fast, // but because the number of exported symbol is usually not that // much, it should be okay. diff --git a/lld/test/pecoff/export.test b/lld/test/pecoff/export.test index dd73c41ba8b..38ad8d56040 100644 --- a/lld/test/pecoff/export.test +++ b/lld/test/pecoff/export.test @@ -78,7 +78,7 @@ DUP-NOT: exportfn3@256 # RUN: yaml2obj %p/Inputs/export.obj.yaml > %t.obj # # RUN: lld -flavor link /out:%t1.dll /dll /entry:init \ -# RUN: /export:f1=exportfn1 /export:f2=exportfn2,private -- %t.obj +# RUN: /export:f1=exportfn1 /export:f2@4=exportfn2,private -- %t.obj # RUN: llvm-objdump -p %t1.dll | FileCheck -check-prefix=EQUAL %s EQUAL: Export Table: @@ -86,4 +86,4 @@ EQUAL: DLL name: export.test.tmp1.dll EQUAL: Ordinal RVA Name EQUAL-NEXT: 1 0x2010 exportfn3@256 EQUAL-NEXT: 2 0x2008 f1 -EQUAL-NEXT: 3 0x2010 f2 +EQUAL-NEXT: 3 0x2010 f2{{$}} |