diff options
-rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 15 | ||||
-rw-r--r-- | lld/test/pecoff/export.test | 12 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 4fdbd00af87..f4e32b39943 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -361,7 +361,10 @@ static bool parseManifestUAC(StringRef option, } } -// Parse /export:name[,@ordinal[,NONAME]][,DATA]. +// Parse /export:entryname[=internalname][,@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()) diff --git a/lld/test/pecoff/export.test b/lld/test/pecoff/export.test index ef2a1d19724..f8e75bf605d 100644 --- a/lld/test/pecoff/export.test +++ b/lld/test/pecoff/export.test @@ -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 |