Fix --print-gc-sections with linker scripts.

Before it would never print anything.

Thanks to George Rimar for pointing it out.

llvm-svn: 295485
This commit is contained in:
Rafael Espindola 2017-02-17 19:37:30 +00:00
parent 0ee7c63fd7
commit 3773bcac55
2 changed files with 8 additions and 2 deletions

View File

@ -252,7 +252,7 @@ void LinkerScript<ELFT>::computeInputSections(InputSectionDescription *I) {
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) }

View File

@ -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