[COFF] Allow specifying export forwarding in a def file

Previously this was only supported when specified on the command line
or in directives.

Differential Revision: https://reviews.llvm.org/D46244

llvm-svn: 331900
This commit is contained in:
Martin Storsjo
2018-05-09 18:19:41 +00:00
parent c15ea70b1f
commit 0ca06f7950
2 changed files with 14 additions and 0 deletions

View File

@@ -625,6 +625,16 @@ static void parseModuleDefs(StringRef Path) {
for (COFFShortExport E1 : M.Exports) {
Export E2;
// In simple cases, only Name is set. Renamed exports are parsed
// and set as "ExtName = Name". If Name has the form "OtherDll.Func",
// it shouldn't be a normal exported function but a forward to another
// DLL instead. This is supported by both MS and GNU linkers.
if (E1.ExtName != E1.Name && StringRef(E1.Name).contains('.')) {
E2.Name = E1.ExtName;
E2.ForwardTo = E1.Name;
Config->Exports.push_back(E2);
continue;
}
E2.Name = Saver.save(E1.Name);
E2.ExtName = Saver.save(E1.ExtName);
E2.Ordinal = E1.Ordinal;

View File

@@ -86,6 +86,10 @@ SYMTAB: exportfn3 in export.test.tmp.DLL
# RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=kernel32.foobar
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=FORWARDER %s
# RUN: echo "EXPORTS foo=kernel32.foobar" > %t.def
# RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=FORWARDER %s
FORWARDER: Export Table:
FORWARDER: DLL name: export.test.tmp.dll
FORWARDER: Ordinal base: 0