Fix --print-gc-sections with linker scripts.
Before it would never print anything.
Thanks to George Rimar for pointing it out.
llvm-svn: 295485
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 8dfbfe8..a323d3a 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -252,7 +252,7 @@
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) }
diff --git a/lld/test/ELF/linkerscript/discard-print-gc.s b/lld/test/ELF/linkerscript/discard-print-gc.s
index 2d6cb04..2a230e5 100644
--- a/lld/test/ELF/linkerscript/discard-print-gc.s
+++ b/lld/test/ELF/linkerscript/discard-print-gc.s
@@ -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