[PATCH] D24733: [ELF] Add .debug* and .comment sections to the list of sections ignored by GC.

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 10:06:34 PDT 2016


evgeny777 created this revision.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.

The name says it. 

Repository:
  rL LLVM

https://reviews.llvm.org/D24733

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

Index: test/ELF/gc-sections.s
===================================================================
--- test/ELF/gc-sections.s
+++ test/ELF/gc-sections.s
@@ -14,6 +14,8 @@
 # NOGC: Name: .dtors
 # NOGC: Name: .init
 # NOGC: Name: .fini
+# NOGC: Name: .debug_pubtypes
+# NOGC: Name: .comment
 # NOGC: Name: a
 # NOGC: Name: b
 # NOGC: Name: c
@@ -100,3 +102,9 @@
 
 .section .eh_frame,"a", at unwind
   .quad 0
+
+.section .debug_pubtypes,"", at progbits
+  .quad 0
+
+.section .comment,"MS", at progbits,8
+  .quad 0
Index: ELF/MarkLive.cpp
===================================================================
--- ELF/MarkLive.cpp
+++ ELF/MarkLive.cpp
@@ -69,7 +69,7 @@
                                         RelT &Rel) {
   SymbolBody &B = Sec.getFile()->getRelocTargetSym(Rel);
   auto *D = dyn_cast<DefinedRegular<ELFT>>(&B);
-  if (!D || !D->Section)
+  if (!D || !D->Section || D->Section == &InputSectionBase<ELFT>::Discarded)
     return {nullptr, 0};
   typename ELFT::uint Offset = D->Value;
   if (D->isSection())
@@ -176,7 +176,8 @@
     if (isValidCIdentifier(S))
       return true;
 
-    return S.startswith(".ctors") || S.startswith(".dtors") ||
+    return S.startswith(".comment") || S.startswith(".ctors") ||
+           S.startswith(".debug") || S.startswith(".dtors") ||
            S.startswith(".init") || S.startswith(".fini") ||
            S.startswith(".jcr");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24733.71843.patch
Type: text/x-patch
Size: 1383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160919/07c2bc49/attachment.bin>


More information about the llvm-commits mailing list