[lld] r282444 - Non alloca sections should not keep other sections live.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 14:34:35 PDT 2016
Author: rafael
Date: Mon Sep 26 16:34:34 2016
New Revision: 282444
URL: http://llvm.org/viewvc/llvm-project?rev=282444&view=rev
Log:
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.
Added:
lld/trunk/test/ELF/gc-sections-alloc.s
Modified:
lld/trunk/ELF/MarkLive.cpp
Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=282444&r1=282443&r2=282444&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Mon Sep 26 16:34:34 2016
@@ -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) {
Added: lld/trunk/test/ELF/gc-sections-alloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-alloc.s?rev=282444&view=auto
==============================================================================
--- lld/trunk/test/ELF/gc-sections-alloc.s (added)
+++ lld/trunk/test/ELF/gc-sections-alloc.s Mon Sep 26 16:34:34 2016
@@ -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
More information about the llvm-commits
mailing list