[lld] r295485 - Fix --print-gc-sections with linker scripts.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 11:37:30 PST 2017


Author: rafael
Date: Fri Feb 17 13:37:30 2017
New Revision: 295485

URL: http://llvm.org/viewvc/llvm-project?rev=295485&view=rev
Log:
Fix --print-gc-sections with linker scripts.

Before it would never print anything.

Thanks to George Rimar for pointing it out.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/discard-print-gc.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=295485&r1=295484&r2=295485&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Feb 17 13:37:30 2017
@@ -252,7 +252,7 @@ void LinkerScript<ELFT>::computeInputSec
     size_t SizeBefore = I->Sections.size();
 
     for (InputSectionBase<ELFT> *S : Symtab<ELFT>::X->Sections) {
-      if (!S->Live || S->Assigned)
+      if (S->Assigned)
         continue;
       // For -emit-relocs we have to ignore entries like
       //   .rela.dyn : { *(.rela.data) }

Modified: lld/trunk/test/ELF/linkerscript/discard-print-gc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/discard-print-gc.s?rev=295485&r1=295484&r2=295485&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/discard-print-gc.s (original)
+++ lld/trunk/test/ELF/linkerscript/discard-print-gc.s Fri Feb 17 13:37:30 2017
@@ -1,11 +1,17 @@
 # REQUIRES: x86
-# RUN: echo "SECTIONS { /DISCARD/ : { *(.foo) } }" > %t.script
+
 # RUN: llvm-mc -triple x86_64-pc-linux %s -o %t.o -filetype=obj
 # RUN: ld.lld -o %t.so --gc-sections %t.o --print-gc-sections -shared 2>&1 | \
 # RUN:   FileCheck -check-prefix=CHECK %s
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.foo) } }" > %t.script
 # RUN: ld.lld -o %t.so -T %t.script %t.o --print-gc-sections -shared 2>&1 | \
 # RUN:   FileCheck -check-prefix=QUIET --allow-empty %s
 
+# RUN: echo "SECTIONS { .foo : { *(.foo) } }" > %t2.script
+# RUN: ld.lld -o %t.so -T %t2.script --gc-sections %t.o --print-gc-sections -shared 2>&1 | \
+# RUN:   FileCheck -check-prefix=CHECK %s
+
 .section .foo,"a"
 .quad 0
 




More information about the llvm-commits mailing list