[lld] r282847 - Fix another --gc-sections crash.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 23:48:09 PDT 2016
Author: rafael
Date: Fri Sep 30 01:48:09 2016
New Revision: 282847
URL: http://llvm.org/viewvc/llvm-project?rev=282847&view=rev
Log:
Fix another --gc-sections crash.
The missing case was when a merge section was only referenced from
non-alloca sections.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/gc-sections-non-alloc-to-merge.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=282847&r1=282846&r2=282847&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Sep 30 01:48:09 2016
@@ -620,6 +620,9 @@ typename ELFT::uint MergeInputSection<EL
if (It != OffsetMap.end())
return It->second;
+ if (!this->Live)
+ return 0;
+
// If Offset is not at beginning of a section piece, it is not in the map.
// In that case we need to search from the original section piece vector.
const SectionPiece &Piece = *this->getSectionPiece(Offset);
Modified: lld/trunk/test/ELF/gc-sections-non-alloc-to-merge.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-non-alloc-to-merge.s?rev=282847&r1=282846&r2=282847&view=diff
==============================================================================
--- lld/trunk/test/ELF/gc-sections-non-alloc-to-merge.s (original)
+++ lld/trunk/test/ELF/gc-sections-non-alloc-to-merge.s Fri Sep 30 01:48:09 2016
@@ -17,5 +17,11 @@ _start:
.Lbar:
.long 2
+ .section .merge2,"aM", at progbits,4
+ .p2align 2
+.Lzed:
+ .long 1
+
.section bar
.quad .Lbar
+ .quad .Lzed
More information about the llvm-commits
mailing list