summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-09-30 06:48:09 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-09-30 06:48:09 +0000
commit2629602f28a451b9d0edb70392414bffec0aed7b (patch)
tree716d56a4c08e5a1179adf2b1beef5864c46f75fc
parentb3e7d68d5cb654c0ac54f7a28c7b0bac348b6094 (diff)
downloadbcm5719-llvm-2629602f28a451b9d0edb70392414bffec0aed7b.tar.gz
bcm5719-llvm-2629602f28a451b9d0edb70392414bffec0aed7b.zip
Fix another --gc-sections crash.
The missing case was when a merge section was only referenced from non-alloca sections. llvm-svn: 282847
-rw-r--r--lld/ELF/InputSection.cpp3
-rw-r--r--lld/test/ELF/gc-sections-non-alloc-to-merge.s6
2 files changed, 9 insertions, 0 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 1c01972fc8a..6e73f6ff1d0 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -620,6 +620,9 @@ typename ELFT::uint MergeInputSection<ELFT>::getOffset(uintX_t Offset) const {
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);
diff --git a/lld/test/ELF/gc-sections-non-alloc-to-merge.s b/lld/test/ELF/gc-sections-non-alloc-to-merge.s
index cdc11de8889..37b0328d845 100644
--- a/lld/test/ELF/gc-sections-non-alloc-to-merge.s
+++ b/lld/test/ELF/gc-sections-non-alloc-to-merge.s
@@ -17,5 +17,11 @@ _start:
.Lbar:
.long 2
+ .section .merge2,"aM",@progbits,4
+ .p2align 2
+.Lzed:
+ .long 1
+
.section bar
.quad .Lbar
+ .quad .Lzed
OpenPOWER on IntegriCloud