aboutsummaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorJacek Caban <jacek@codeweavers.com>2024-03-26 13:07:13 +0100
committerGitHub <noreply@github.com>2024-03-26 13:07:13 +0100
commitbfb12ef33a90bd20c3a76094ef4393a8defbb712 (patch)
treeb719d0940990cdefca5201fb9e49df79330a4468 /lld
parentf914e8e77c4703814e2f2dcef1d4569b17837c92 (diff)
downloadllvm-bfb12ef33a90bd20c3a76094ef4393a8defbb712.zip
llvm-bfb12ef33a90bd20c3a76094ef4393a8defbb712.tar.gz
llvm-bfb12ef33a90bd20c3a76094ef4393a8defbb712.tar.bz2
[LLD][COFF] Allow additional attributes in forwarding exports. (#86535)
Testing with MSVC link.exe showed that it respects such options, while LLD currently discards them.
Diffstat (limited to 'lld')
-rw-r--r--lld/COFF/DriverUtils.cpp13
-rw-r--r--lld/test/COFF/export.test33
2 files changed, 36 insertions, 10 deletions
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index fc8eb32..0fa4769 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -577,16 +577,15 @@ Export LinkerDriver::parseExport(StringRef arg) {
if (y.contains(".")) {
e.name = x;
e.forwardTo = y;
- return e;
+ } else {
+ e.extName = x;
+ e.name = y;
+ if (e.name.empty())
+ goto err;
}
-
- e.extName = x;
- e.name = y;
- if (e.name.empty())
- goto err;
}
- // If "<name>=<internalname>[,@ordinal[,NONAME]][,DATA][,PRIVATE]"
+ // Optional parameters "[,@ordinal[,NONAME]][,DATA][,PRIVATE]"
while (!rest.empty()) {
StringRef tok;
std::tie(tok, rest) = rest.split(",");
diff --git a/lld/test/COFF/export.test b/lld/test/COFF/export.test
index d340e01..b91fdcf 100644
--- a/lld/test/COFF/export.test
+++ b/lld/test/COFF/export.test
@@ -76,18 +76,45 @@ 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: llvm-nm -M %t.lib | FileCheck --check-prefix=SYMTAB-FWD %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
+# RUN: lld-link /out:%t-def.dll /dll %t.obj /def:%t.def
+# RUN: llvm-objdump -p %t-def.dll | FileCheck --check-prefix=FORWARDER %s
+# RUN: llvm-nm -M %t-def.lib | FileCheck --check-prefix=SYMTAB-FWD %s
FORWARDER: Export Table:
-FORWARDER: DLL name: export.test.tmp.dll
+FORWARDER: DLL name: export.test.tmp
FORWARDER: Ordinal base: 1
FORWARDER: Ordinal RVA Name
FORWARDER: 1 0x1010 exportfn
FORWARDER: 2 foo (forwarded to kernel32.foobar)
+SYMTAB-FWD: __imp_exportfn3 in export.test.tmp
+SYMTAB-FWD-NEXT: __imp_foo in export.test.tmp
+SYMTAB-FWD-NEXT: exportfn3 in export.test.tmp
+SYMTAB-FWD-NEXT: foo in export.test.tmp
+
+# RUN: lld-link /out:%t-fwd-priv.dll /dll %t.obj /export:foo=kernel32.foobar,DATA,PRIVATE
+# RUN: llvm-objdump -p %t-fwd-priv.dll | FileCheck --check-prefix=FORWARDER %s
+# RUN: llvm-nm -M %t-fwd-priv.lib | FileCheck --check-prefix=SYMTAB-FWD-PRIV %s
+
+SYMTAB-FWD-PRIV: __imp_exportfn3 in export.test.tmp-fwd-priv
+SYMTAB-FWD-PRIV-NOT: __imp_foo
+SYMTAB-FWD-PRIV-NEXT: exportfn3 in export.test.tmp-fwd-priv
+SYMTAB-FWD-PRIV-NOT: foo
+
+# RUN: lld-link /out:%t-fwd-ord.dll /dll %t.obj /export:foo=kernel32.foobar,@3,NONAME
+# RUN: llvm-objdump -p %t-fwd-ord.dll | FileCheck --check-prefix=FORWARDER-ORD %s
+# RUN: llvm-nm -M %t-fwd-ord.lib | FileCheck --check-prefix=SYMTAB-FWD %s
+
+FORWARDER-ORD: Export Table:
+FORWARDER-ORD-NEXT: DLL name: export.test.tmp-fwd-ord
+FORWARDER-ORD-NEXT: Ordinal base: 3
+FORWARDER-ORD-NEXT: Ordinal RVA Name
+FORWARDER-ORD-NEXT: 3 (forwarded to kernel32.foobar)
+FORWARDER-ORD-NEXT: 4 0x1010 exportfn3
+
# RUN: lld-link /out:%t.dll /dll %t.obj /merge:.rdata=.text /export:exportfn1 /export:exportfn2
# RUN: llvm-objdump -p %t.dll | FileCheck --check-prefix=MERGE --match-full-lines %s