summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-07-26 20:14:50 +0000
committerMartin Storsjo <martin@martin.st>2018-07-26 20:14:50 +0000
commit6c8cbf6db0839e525db4969377fa8109b6a6fcc9 (patch)
treee15a55c1ccf94f3033e8d8039345f768e3c05c00
parent390bce43220111640bfe94733282ae7db4708f82 (diff)
downloadbcm5719-llvm-6c8cbf6db0839e525db4969377fa8109b6a6fcc9.tar.gz
bcm5719-llvm-6c8cbf6db0839e525db4969377fa8109b6a6fcc9.zip
[COFF] Handle comdat sections without leader symbols
Discard them unless they have been associated by other means (yet uimplemented). According to MS link.exe, such sections are illegal, but MinGW setups use them in their take on associative comdats. This avoids leaving references to the bogus SectionChunk* PendingComdat, which cannot be dereferenced. This fixes PR38183. Differential Revision: https://reviews.llvm.org/D49653 llvm-svn: 338064
-rw-r--r--lld/COFF/InputFiles.cpp7
-rw-r--r--lld/test/COFF/pending-comdat.s21
2 files changed, 28 insertions, 0 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 2788f3b2f71..2b3e65fae04 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -281,6 +281,13 @@ void ObjFile::initializeSymbols() {
if (auto *Def = Sym.getSectionDefinition())
if (Def->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE)
readAssociativeDefinition(Sym, Def);
+ if (SparseChunks[Sym.getSectionNumber()] == PendingComdat) {
+ StringRef Name;
+ COFFObj->getSymbolName(Sym, Name);
+ log("comdat section " + Name +
+ " without leader and unassociated, discarding");
+ continue;
+ }
Symbols[I] = createRegular(Sym);
}
diff --git a/lld/test/COFF/pending-comdat.s b/lld/test/COFF/pending-comdat.s
new file mode 100644
index 00000000000..b10dce1f1ea
--- /dev/null
+++ b/lld/test/COFF/pending-comdat.s
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
+
+# RUN: not lld-link -lldmingw -out:%t.exe -entry:main -subsystem:console %t.obj 2>&1 | FileCheck %s
+
+# CHECK: error: undefined symbol: other
+
+# Check that the comdat section without a symbol isn't left pending once we iterate symbols
+# to print source of the undefined symbol.
+
+ .text
+ .globl main
+main:
+ call other
+ ret
+
+ .section .data$pending,"w"
+ .linkonce discard
+.Llocal:
+ .byte 0
OpenPOWER on IntegriCloud