forked from OSchip/llvm-project
Non alloca sections should not keep other sections live.
This matches the gold behaviour and is important to prevent debug info from effectively disabling gc. llvm-svn: 282444
This commit is contained in:
parent
3b66056a3f
commit
2b9008e5e5
|
@ -208,7 +208,8 @@ template <class ELFT> void elf::markLive() {
|
|||
return;
|
||||
R.Sec->Live = true;
|
||||
if (InputSection<ELFT> *S = dyn_cast<InputSection<ELFT>>(R.Sec))
|
||||
Q.push_back(S);
|
||||
if (S->getSectionHdr()->sh_flags & SHF_ALLOC)
|
||||
Q.push_back(S);
|
||||
};
|
||||
|
||||
auto MarkSymbol = [&](const SymbolBody *Sym) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# REQUIRES: x86
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: ld.lld %t -o %t2 --gc-sections -shared
|
||||
# RUN: llvm-readobj -sections -section-data %t2 | FileCheck %s
|
||||
|
||||
# Non alloca section .bar should not keep section .foo alive.
|
||||
|
||||
# CHECK-NOT: Name: .foo
|
||||
|
||||
# CHECK: Name: .bar
|
||||
# CHECK-NEXT: Type: SHT_PROGBITS
|
||||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address:
|
||||
# CHECK-NEXT: Offset:
|
||||
# CHECK-NEXT: Size:
|
||||
# CHECK-NEXT: Link:
|
||||
# CHECK-NEXT: Info:
|
||||
# CHECK-NEXT: AddressAlignment:
|
||||
# CHECK-NEXT: EntrySize:
|
||||
# CHECK-NEXT: SectionData (
|
||||
# CHECK-NEXT: 0000: 00000000 00000000 |
|
||||
# CHECK-NEXT: )
|
||||
|
||||
|
||||
.section .foo,"a"
|
||||
.byte 0
|
||||
|
||||
.section .bar
|
||||
.quad .foo
|
Loading…
Reference in New Issue