<div dir="ltr">This code needs comment.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 4, 2016 at 5:05 AM, Eugene Leviant via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: evgeny777<br>
Date: Tue Oct  4 07:05:42 2016<br>
New Revision: 283214<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=283214&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=283214&view=rev</a><br>
Log:<br>
[ELF] Don't discard excluded section if -r is used<br>
<br>
This conforms to GNU ld/gold behavior and fixes crash in case<br>
excluded section also has associated relocation section<br>
<br>
Modified:<br>
    lld/trunk/ELF/InputFiles.cpp<br>
    lld/trunk/test/ELF/exclude.s<br>
<br>
Modified: lld/trunk/ELF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=283214&r1=283213&r2=283214&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputFiles.cpp?rev=283214&r1=<wbr>283213&r2=283214&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputFiles.cpp (original)<br>
+++ lld/trunk/ELF/InputFiles.cpp Tue Oct  4 07:05:42 2016<br>
@@ -226,7 +226,7 @@ void elf::ObjectFile<ELFT>::<wbr>initializeSe<br>
     if (Sections[I] == &InputSection<ELFT>::<wbr>Discarded)<br>
       continue;<br>
<br>
-    if (Sec.sh_flags & SHF_EXCLUDE) {<br>
+    if (!Config->Relocatable && (Sec.sh_flags & SHF_EXCLUDE)) {<br>
       Sections[I] = &InputSection<ELFT>::<wbr>Discarded;<br>
       continue;<br>
     }<br>
<br>
Modified: lld/trunk/test/ELF/exclude.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/exclude.s?rev=283214&r1=283213&r2=283214&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>exclude.s?rev=283214&r1=<wbr>283213&r2=283214&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/exclude.s (original)<br>
+++ lld/trunk/test/ELF/exclude.s Tue Oct  4 07:05:42 2016<br>
@@ -2,11 +2,18 @@<br>
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t<br>
 # RUN: ld.lld -o %t1 %t<br>
 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s<br>
+# RUN: ld.lld -r -o %t1 %t<br>
+# RUN: llvm-objdump -section-headers %t1 | FileCheck --check-prefix=RELOCATABLE %s<br>
+<br>
 # CHECK-NOT:      .aaa<br>
+# RELOCATABLE:    .aaa<br>
<br>
 .globl _start<br>
 _start:<br>
   jmp _start<br>
<br>
 .section .aaa,"ae"<br>
+ .quad .bbb<br>
+<br>
+.section .bbb,"a"<br>
  .quad 0<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>