diff options
| -rw-r--r-- | lld/ELF/InputSection.cpp | 3 | ||||
| -rw-r--r-- | lld/test/ELF/gc-sections-non-alloc-to-merge.s | 6 |
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 |

