From: Fangrui Song Date: Thu, 16 Aug 2018 17:22:02 +0000 (+0000) Subject: [ELF] mergeSections: remove non-alive MergeInputSection X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ebf9607d7dd01dcbbe0054868ce3c7672bde3fce;p=platform%2Fupstream%2Fllvm.git [ELF] mergeSections: remove non-alive MergeInputSection Summary: This makes it conform to what the comment says. Otherwise when getErrPlace() is called afterwards, cast(D) will cause incompatible cast as MergeInputSection is not a subclass of InputSection. Reviewers: ruiu, grimar, espindola, pcc Reviewed By: grimar Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D50742 llvm-svn: 339904 --- diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 1e6e3d2..f5a2498 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2929,8 +2929,10 @@ void elf::mergeSections() { // We do not want to handle sections that are not alive, so just remove // them instead of trying to merge. - if (!MS->Live) + if (!MS->Live) { + S = nullptr; continue; + } StringRef OutsecName = getOutputSectionName(MS); uint32_t Alignment = std::max(MS->Alignment, MS->Entsize); diff --git a/lld/test/ELF/x86-64-reloc-error2.s b/lld/test/ELF/x86-64-reloc-error2.s index d49b675..81f033f 100644 --- a/lld/test/ELF/x86-64-reloc-error2.s +++ b/lld/test/ELF/x86-64-reloc-error2.s @@ -1,14 +1,18 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s +# RUN: not ld.lld --entry=func --gc-sections %t.o -o /dev/null 2>&1 | FileCheck %s ## Check we are able to find a function symbol that encloses ## a given location when reporting error messages. # CHECK: {{.*}}.o:(function func): relocation R_X86_64_32S out of range: -281474974609408 is not in [-2147483648, 2147483647] +# This mergeable section will be garbage collected. We had a crash issue in that case. Test it. +.section .rodata.str1,"aMS",@progbits,1 +.asciz "a" + .section .text.func, "ax", %progbits .globl func .type func,@function -.size func, 0x10 func: - movq func - 0x1000000000000, %rdx + movq $func - 0x1000000000000, %rdx +.size func, .-func