[lld] 82de4e0 - [LLD] [COFF] Actually include the exported comdat symbols
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Tue May 4 12:13:19 PDT 2021
Author: Martin Storsjö
Date: 2021-05-04T22:13:08+03:00
New Revision: 82de4e075339f5ad8d68cfe31eb45b771d4750ae
URL: https://github.com/llvm/llvm-project/commit/82de4e075339f5ad8d68cfe31eb45b771d4750ae
DIFF: https://github.com/llvm/llvm-project/commit/82de4e075339f5ad8d68cfe31eb45b771d4750ae.diff
LOG: [LLD] [COFF] Actually include the exported comdat symbols
This is a followup to 2b01a417d7ccb001ccc1185ef5fdc967c9fac8d7;
previously the RVAs of the exported symbols from comdats were left
zero.
Thanks to Kleis Auke Wolthuizen for the fix suggestion and pointing
out the omission.
Differential Revision: https://reviews.llvm.org/D101615
Added:
Modified:
lld/COFF/Driver.cpp
lld/test/COFF/export-all.s
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 072af2bef159..cf1169211985 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1205,6 +1205,11 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
if (!exporter.shouldExport(def))
return;
+ if (!def->isGCRoot) {
+ def->isGCRoot = true;
+ config->gcroot.push_back(def);
+ }
+
Export e;
e.name = def->getName();
e.sym = def;
diff --git a/lld/test/COFF/export-all.s b/lld/test/COFF/export-all.s
index ff0f087a84ad..079d0a25d79b 100644
--- a/lld/test/COFF/export-all.s
+++ b/lld/test/COFF/export-all.s
@@ -4,6 +4,7 @@
# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup at 12 %t.obj -implib:%t.lib
# RUN: llvm-readobj --coff-exports %t.dll | grep Name: | FileCheck %s
+# RUN: llvm-readobj --coff-exports %t.dll | FileCheck %s --check-prefix=CHECK-RVA
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s
# CHECK: Name:
@@ -12,6 +13,13 @@
# CHECK-NEXT: Name: foobar
# CHECK-EMPTY:
+# CHECK-RVA: Name: comdatFunc
+# CHECK-RVA-NEXT: RVA: 0x1003
+# CHECK-RVA: Name: dataSym
+# CHECK-RVA-NEXT: RVA: 0x3000
+# CHECK-RVA: Name: foobar
+# CHECK-RVA-NEXT: RVA: 0x1001
+
# IMPLIB: Symbol: __imp__comdatFunc
# IMPLIB: Symbol: _comdatFunc
# IMPLIB: Symbol: __imp__dataSym
@@ -33,7 +41,7 @@ _foobar:
ret
_unexported:
ret
-.section .text at _comdatFunc,"xr",one_only,_comdatFunc
+.section .text$_comdatFunc,"xr",one_only,_comdatFunc
_comdatFunc:
ret
.data
More information about the llvm-commits
mailing list