[lld] r267081 - Don't gc protected symbols.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 16:59:19 PDT 2016


Author: rafael
Date: Thu Apr 21 18:59:19 2016
New Revision: 267081

URL: http://llvm.org/viewvc/llvm-project?rev=267081&view=rev
Log:
Don't gc protected symbols.

Added:
    lld/trunk/test/ELF/gc-sections-protected.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=267081&r1=267080&r2=267081&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Thu Apr 21 18:59:19 2016
@@ -116,7 +116,7 @@ template <class ELFT> void elf::markLive
   if (Config->Shared || Config->ExportDynamic) {
     for (const Symbol *S : Symtab->getSymbols()) {
       SymbolBody *B = S->Body;
-      if (B->getVisibility() == STV_DEFAULT)
+      if (B->includeInDynsym())
         MarkSymbol(B);
     }
   }

Added: lld/trunk/test/ELF/gc-sections-protected.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-protected.s?rev=267081&view=auto
==============================================================================
--- lld/trunk/test/ELF/gc-sections-protected.s (added)
+++ lld/trunk/test/ELF/gc-sections-protected.s Thu Apr 21 18:59:19 2016
@@ -0,0 +1,18 @@
+// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
+// RUN: ld.lld %t.o -o %t.so -shared --gc-sections
+// RUN: llvm-readobj -s %t.so | FileCheck %s
+
+// CHECK:      Name: .text
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT:   SHF_ALLOC
+// CHECK-NEXT:   SHF_EXECINSTR
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 1
+
+.protected g
+.globl g
+g:
+retq




More information about the llvm-commits mailing list