[lld] r283214 - [ELF] Don't discard excluded section if -r is used

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 09:55:47 PDT 2016


This code needs comment.

On Tue, Oct 4, 2016 at 5:05 AM, Eugene Leviant via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: evgeny777
> Date: Tue Oct  4 07:05:42 2016
> New Revision: 283214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283214&view=rev
> Log:
> [ELF] Don't discard excluded section if -r is used
>
> This conforms to GNU ld/gold behavior and fixes crash in case
> excluded section also has associated relocation section
>
> Modified:
>     lld/trunk/ELF/InputFiles.cpp
>     lld/trunk/test/ELF/exclude.s
>
> Modified: lld/trunk/ELF/InputFiles.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> InputFiles.cpp?rev=283214&r1=283213&r2=283214&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/InputFiles.cpp (original)
> +++ lld/trunk/ELF/InputFiles.cpp Tue Oct  4 07:05:42 2016
> @@ -226,7 +226,7 @@ void elf::ObjectFile<ELFT>::initializeSe
>      if (Sections[I] == &InputSection<ELFT>::Discarded)
>        continue;
>
> -    if (Sec.sh_flags & SHF_EXCLUDE) {
> +    if (!Config->Relocatable && (Sec.sh_flags & SHF_EXCLUDE)) {
>        Sections[I] = &InputSection<ELFT>::Discarded;
>        continue;
>      }
>
> Modified: lld/trunk/test/ELF/exclude.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> exclude.s?rev=283214&r1=283213&r2=283214&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/exclude.s (original)
> +++ lld/trunk/test/ELF/exclude.s Tue Oct  4 07:05:42 2016
> @@ -2,11 +2,18 @@
>  # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
>  # RUN: ld.lld -o %t1 %t
>  # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
> +# RUN: ld.lld -r -o %t1 %t
> +# RUN: llvm-objdump -section-headers %t1 | FileCheck
> --check-prefix=RELOCATABLE %s
> +
>  # CHECK-NOT:      .aaa
> +# RELOCATABLE:    .aaa
>
>  .globl _start
>  _start:
>    jmp _start
>
>  .section .aaa,"ae"
> + .quad .bbb
> +
> +.section .bbb,"a"
>   .quad 0
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/b055de69/attachment.html>


More information about the llvm-commits mailing list