[lld] r218695 - [PECOFF] Fix /export option.
Rui Ueyama
ruiu at google.com
Tue Sep 30 13:03:12 PDT 2014
Author: ruiu
Date: Tue Sep 30 15:03:11 2014
New Revision: 218695
URL: http://llvm.org/viewvc/llvm-project?rev=218695&view=rev
Log:
[PECOFF] Fix /export option.
MSDN doesn't say about /export:foo=bar style option, but
it turned out MSVC link.exe actually accepts that. So we need that
too.
It also means that the export directive in the module definition
file and /export command line option are functionally equivalent.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/test/pecoff/export.test
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=218695&r1=218694&r2=218695&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Sep 30 15:03:11 2014
@@ -361,7 +361,10 @@ static bool parseManifestUAC(StringRef o
}
}
-// Parse /export:name[, at ordinal[,NONAME]][,DATA].
+// Parse /export:entryname[=internalname][, at ordinal[,NONAME]][,DATA].
+//
+// MSDN doesn't say anything about /export:foo=bar style option,
+// but link.exe actually accepts it.
static bool parseExport(StringRef option,
PECOFFLinkingContext::ExportDesc &ret) {
StringRef name;
@@ -369,8 +372,14 @@ static bool parseExport(StringRef option
std::tie(name, rest) = option.split(",");
if (name.empty())
return false;
- ret.name = name;
- ret.externalName = name;
+ if (name.find('=') == StringRef::npos) {
+ ret.name = name;
+ ret.externalName = name;
+ } else {
+ std::tie(ret.externalName, ret.name) = name.split("=");
+ if (ret.name.empty())
+ return false;
+ }
for (;;) {
if (rest.empty())
Modified: lld/trunk/test/pecoff/export.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/export.test?rev=218695&r1=218694&r2=218695&view=diff
==============================================================================
--- lld/trunk/test/pecoff/export.test (original)
+++ lld/trunk/test/pecoff/export.test Tue Sep 30 15:03:11 2014
@@ -69,3 +69,15 @@ DUP: DLL name: export.test.tmp6.dll
DUP: Ordinal RVA Name
DUP: 1 0x2010 exportfn8
DUP-NOT: 1 0x2010 exportfn8
+
+# 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 -- %t.obj
+# RUN: llvm-objdump -p %t1.dll | FileCheck -check-prefix=EQUAL %s
+
+EQUAL: Export Table:
+EQUAL: DLL name: export.test.tmp1.dll
+EQUAL: Ordinal RVA Name
+EQUAL-NEXT: 1 0x2008 f1
+EQUAL-NEXT: 2 0x2010 f2
More information about the llvm-commits
mailing list