diff options
author | Rui Ueyama <ruiu@google.com> | 2014-12-04 00:31:34 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-12-04 00:31:34 +0000 |
commit | a5e2a66dda6e64695d74293d3400f8b336acd68f (patch) | |
tree | abfd827a818a1127173b9530d943580c8499c094 | |
parent | 597fbb52306ce1de32c74ad25e177fec8ccee24a (diff) | |
download | bcm5719-llvm-a5e2a66dda6e64695d74293d3400f8b336acd68f.tar.gz bcm5719-llvm-a5e2a66dda6e64695d74293d3400f8b336acd68f.zip |
[PECOFF] Improve compatibility of /export option.
llvm-svn: 223326
-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{{$}} |