[PATCH] D101522: [LLD] [COFF] Fix the mingw --export-all-symbols behaviour with comdat symbols
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 05:03:18 PDT 2021
mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
When looking for the "all" symbols that are supposed to be exported,
we can't look at the live flag - the symbols we mark as to be
exported will become GC roots even if they aren't yet marked as live.
With this in place, building an LLVM library with BUILD_SHARED_LIBS
produces the same set of symbols exported regardless of whether the
--gc-symbols flag is specified, both with and without being built
with -ffunction-sections.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101522
Files:
lld/COFF/MinGW.cpp
lld/test/COFF/export-all.s
Index: lld/test/COFF/export-all.s
===================================================================
--- lld/test/COFF/export-all.s
+++ lld/test/COFF/export-all.s
@@ -7,10 +7,13 @@
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s
# CHECK: Name:
+# CHECK-NEXT: Name: comdatFunc
# CHECK-NEXT: Name: dataSym
# CHECK-NEXT: Name: foobar
# CHECK-EMPTY:
+# IMPLIB: Symbol: __imp__comdatFunc
+# IMPLIB: Symbol: _comdatFunc
# IMPLIB: Symbol: __imp__dataSym
# IMPLIB-NOT: Symbol: _dataSym
# IMPLIB: Symbol: __imp__foobar
@@ -22,6 +25,7 @@
.global _unexported
.global __imp__unexported
.global .refptr._foobar
+.global _comdatFunc
.text
_DllMainCRTStartup at 12:
ret
@@ -29,6 +33,9 @@
ret
_unexported:
ret
+.section .text at _comdatFunc,"xr",one_only,_comdatFunc
+_comdatFunc:
+ ret
.data
_dataSym:
.int 4
Index: lld/COFF/MinGW.cpp
===================================================================
--- lld/COFF/MinGW.cpp
+++ lld/COFF/MinGW.cpp
@@ -123,7 +123,7 @@
}
bool AutoExporter::shouldExport(Defined *sym) const {
- if (!sym || !sym->isLive() || !sym->getChunk())
+ if (!sym || !sym->getChunk())
return false;
// Only allow the symbol kinds that make sense to export; in particular,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101522.341478.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/50df35f0/attachment.bin>
More information about the llvm-commits
mailing list