[lld] r223326 - [PECOFF] Improve compatibility of /export option.

Rui Ueyama ruiu at google.com
Wed Dec 3 16:31:34 PST 2014


Author: ruiu
Date: Wed Dec  3 18:31:34 2014
New Revision: 223326

URL: http://llvm.org/viewvc/llvm-project?rev=223326&view=rev
Log:
[PECOFF] Improve compatibility of /export option.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/test/pecoff/export.test

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=223326&r1=223325&r2=223326&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Wed Dec  3 18:31:34 2014
@@ -261,6 +261,16 @@ static bool sameExportDesc(const PECOFFL
 void PECOFFLinkingContext::addDllExport(ExportDesc &desc) {
   addInitialUndefinedSymbol(allocate(desc.name));
 
+  // MSVC link.exe silently drops characters after the first atsign.
+  // For example, /export:foo at 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.

Modified: lld/trunk/test/pecoff/export.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/export.test?rev=223326&r1=223325&r2=223326&view=diff
==============================================================================
--- lld/trunk/test/pecoff/export.test (original)
+++ lld/trunk/test/pecoff/export.test Wed Dec  3 18:31:34 2014
@@ -78,7 +78,7 @@ DUP-NOT:  exportfn3 at 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 at 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.d
 EQUAL:       Ordinal      RVA  Name
 EQUAL-NEXT:       1   0x2010  exportfn3 at 256
 EQUAL-NEXT:       2   0x2008  f1
-EQUAL-NEXT:       3   0x2010  f2
+EQUAL-NEXT:       3   0x2010  f2{{$}}





More information about the llvm-commits mailing list