diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-09-30 20:03:11 +0000 | 
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-09-30 20:03:11 +0000 | 
| commit | 3837e1000231c77abf54f12decc156b6cbfec224 (patch) | |
| tree | ae02f08dafe779c8549d5d1980236b16843cfc2c | |
| parent | c28ce3aba646d0ea24ab584b9bac88e3a2a7374e (diff) | |
| download | bcm5719-llvm-3837e1000231c77abf54f12decc156b6cbfec224.tar.gz bcm5719-llvm-3837e1000231c77abf54f12decc156b6cbfec224.zip  | |
[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.
llvm-svn: 218695
| -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  | 

