[lld] r339904 - [ELF] mergeSections: remove non-alive MergeInputSection

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 17 00:09:07 PDT 2018


Merged to 7.0 in r339986.

On Thu, Aug 16, 2018 at 7:22 PM, Fangrui Song via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: maskray
> Date: Thu Aug 16 10:22:02 2018
> New Revision: 339904
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339904&view=rev
> Log:
> [ELF] mergeSections: remove non-alive MergeInputSection
>
> Summary: This makes it conform to what the comment says. Otherwise when getErrPlace() is called afterwards, cast<InputSection>(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
>
> Modified:
>     lld/trunk/ELF/SyntheticSections.cpp
>     lld/trunk/test/ELF/x86-64-reloc-error2.s
>
> Modified: lld/trunk/ELF/SyntheticSections.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=339904&r1=339903&r2=339904&view=diff
> ==============================================================================
> --- lld/trunk/ELF/SyntheticSections.cpp (original)
> +++ lld/trunk/ELF/SyntheticSections.cpp Thu Aug 16 10:22:02 2018
> @@ -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<uint32_t>(MS->Alignment, MS->Entsize);
>
> Modified: lld/trunk/test/ELF/x86-64-reloc-error2.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-error2.s?rev=339904&r1=339903&r2=339904&view=diff
> ==============================================================================
> --- lld/trunk/test/ELF/x86-64-reloc-error2.s (original)
> +++ lld/trunk/test/ELF/x86-64-reloc-error2.s Thu Aug 16 10:22:02 2018
> @@ -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", at progbits,1
> +.asciz "a"
> +
>  .section .text.func, "ax", %progbits
>  .globl func
>  .type func, at function
> -.size func, 0x10
>  func:
> - movq func - 0x1000000000000, %rdx
> +  movq $func - 0x1000000000000, %rdx
> +.size func, .-func
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list