[PATCH] D30964: [ELF] Restore GC handling of LINK_ORDER, C-named sections

Evgeniy Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 13:51:52 PDT 2017


eugenis updated this revision to Diff 92049.
eugenis added a comment.

Extend the test case with a check for __start_yy.


Repository:
  rL LLVM

https://reviews.llvm.org/D30964

Files:
  ELF/MarkLive.cpp
  test/ELF/gc-sections-metadata-startstop.s


Index: test/ELF/gc-sections-metadata-startstop.s
===================================================================
--- /dev/null
+++ test/ELF/gc-sections-metadata-startstop.s
@@ -0,0 +1,33 @@
+# LINK_ORDER cnamed sections are not kept alive by the __start_* reference.
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections %t.o -o %t
+# RUN: llvm-objdump -section-headers -t %t | FileCheck  %s
+
+# CHECK: Sections:
+# CHECK-NOT: yy
+# CHECK: xx {{.*}} DATA
+# CHECK-NOT: yy
+
+# CHECK: SYMBOL TABLE:
+# CHECK: xx 00000000 __start_xx
+# CHECK: w *UND* 00000000 __start_yy
+
+.weak __start_xx
+.weak __start_yy
+
+.global _start
+_start:
+.quad __start_xx
+.quad __start_yy
+
+.section xx,"a"
+.quad 0
+
+.section .foo,"a"
+.quad 0
+
+.section yy,"am", at progbits,.foo
+.quad 0
+
Index: ELF/MarkLive.cpp
===================================================================
--- ELF/MarkLive.cpp
+++ ELF/MarkLive.cpp
@@ -175,9 +175,6 @@
   case SHT_PREINIT_ARRAY:
     return true;
   default:
-    if (Sec->Flags & SHF_LINK_ORDER)
-      return false;
-
     if (!(Sec->Flags & SHF_ALLOC))
       return true;
 
@@ -247,6 +244,8 @@
     // referred by .eh_frame here.
     if (auto *EH = dyn_cast_or_null<EhInputSection>(Sec))
       scanEhFrameSection<ELFT>(*EH, Enqueue);
+    if (Sec->Flags & SHF_LINK_ORDER)
+      continue;
     if (isReserved<ELFT>(Sec) || Script<ELFT>::X->shouldKeep(Sec))
       Enqueue({Sec, 0});
     else if (isValidCIdentifier(Sec->Name)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30964.92049.patch
Type: text/x-patch
Size: 1526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170316/f4430d6d/attachment.bin>


More information about the llvm-commits mailing list