[lld] r338064 - [COFF] Handle comdat sections without leader symbols
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 26 13:14:50 PDT 2018
Author: mstorsjo
Date: Thu Jul 26 13:14:50 2018
New Revision: 338064
URL: http://llvm.org/viewvc/llvm-project?rev=338064&view=rev
Log:
[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
Added:
lld/trunk/test/COFF/pending-comdat.s
Modified:
lld/trunk/COFF/InputFiles.cpp
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=338064&r1=338063&r2=338064&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Thu Jul 26 13:14:50 2018
@@ -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);
}
Added: lld/trunk/test/COFF/pending-comdat.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pending-comdat.s?rev=338064&view=auto
==============================================================================
--- lld/trunk/test/COFF/pending-comdat.s (added)
+++ lld/trunk/test/COFF/pending-comdat.s Thu Jul 26 13:14:50 2018
@@ -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
More information about the llvm-commits
mailing list