Skip to content

Commit fd913d7

Browse files
committed
[LLD][COFF] Allow additional attributes in forwarding exports.
1 parent f01377d commit fd913d7

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

lld/COFF/DriverUtils.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,16 +577,15 @@ Export LinkerDriver::parseExport(StringRef arg) {
577577
if (y.contains(".")) {
578578
e.name = x;
579579
e.forwardTo = y;
580-
return e;
580+
} else {
581+
e.extName = x;
582+
e.name = y;
583+
if (e.name.empty())
584+
goto err;
581585
}
582-
583-
e.extName = x;
584-
e.name = y;
585-
if (e.name.empty())
586-
goto err;
587586
}
588587

589-
// If "<name>=<internalname>[,@ordinal[,NONAME]][,DATA][,PRIVATE]"
588+
// Optional parameters "[,@ordinal[,NONAME]][,DATA][,PRIVATE]"
590589
while (!rest.empty()) {
591590
StringRef tok;
592591
std::tie(tok, rest) = rest.split(",");

lld/test/COFF/export.test

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,45 @@ SYMTAB: exportfn3 in export.test.tmp.DLL
7676

7777
# RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=kernel32.foobar
7878
# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=FORWARDER %s
79+
# RUN: llvm-nm -M %t.lib | FileCheck --check-prefix=SYMTAB-FWD %s
7980

8081
# RUN: echo "EXPORTS foo=kernel32.foobar" > %t.def
81-
# RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def
82-
# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=FORWARDER %s
82+
# RUN: lld-link /out:%t-def.dll /dll %t.obj /def:%t.def
83+
# RUN: llvm-objdump -p %t-def.dll | FileCheck --check-prefix=FORWARDER %s
84+
# RUN: llvm-nm -M %t-def.lib | FileCheck --check-prefix=SYMTAB-FWD %s
8385

8486
FORWARDER: Export Table:
85-
FORWARDER: DLL name: export.test.tmp.dll
87+
FORWARDER: DLL name: export.test.tmp
8688
FORWARDER: Ordinal base: 1
8789
FORWARDER: Ordinal RVA Name
8890
FORWARDER: 1 0x1010 exportfn
8991
FORWARDER: 2 foo (forwarded to kernel32.foobar)
9092

93+
SYMTAB-FWD: __imp_exportfn3 in export.test.tmp
94+
SYMTAB-FWD-NEXT: __imp_foo in export.test.tmp
95+
SYMTAB-FWD-NEXT: exportfn3 in export.test.tmp
96+
SYMTAB-FWD-NEXT: foo in export.test.tmp
97+
98+
# RUN: lld-link /out:%t-fwd-priv.dll /dll %t.obj /export:foo=kernel32.foobar,DATA,PRIVATE
99+
# RUN: llvm-objdump -p %t-fwd-priv.dll | FileCheck --check-prefix=FORWARDER %s
100+
# RUN: llvm-nm -M %t-fwd-priv.lib | FileCheck --check-prefix=SYMTAB-FWD-PRIV %s
101+
102+
SYMTAB-FWD-PRIV: __imp_exportfn3 in export.test.tmp-fwd-priv
103+
SYMTAB-FWD-PRIV-NOT: __imp_foo
104+
SYMTAB-FWD-PRIV-NEXT: exportfn3 in export.test.tmp-fwd-priv
105+
SYMTAB-FWD-PRIV-NOT: foo
106+
107+
# RUN: lld-link /out:%t-fwd-ord.dll /dll %t.obj /export:foo=kernel32.foobar,@3,NONAME
108+
# RUN: llvm-objdump -p %t-fwd-ord.dll | FileCheck --check-prefix=FORWARDER-ORD %s
109+
# RUN: llvm-nm -M %t-fwd-ord.lib | FileCheck --check-prefix=SYMTAB-FWD %s
110+
111+
FORWARDER-ORD: Export Table:
112+
FORWARDER-ORD-NEXT: DLL name: export.test.tmp-fwd-ord
113+
FORWARDER-ORD-NEXT: Ordinal base: 3
114+
FORWARDER-ORD-NEXT: Ordinal RVA Name
115+
FORWARDER-ORD-NEXT: 3 (forwarded to kernel32.foobar)
116+
FORWARDER-ORD-NEXT: 4 0x1010 exportfn3
117+
91118
# RUN: lld-link /out:%t.dll /dll %t.obj /merge:.rdata=.text /export:exportfn1 /export:exportfn2
92119
# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=MERGE --match-full-lines %s
93120

0 commit comments

Comments
 (0)