From 5be6064974db2ae9f9e412dac6a29655a7deb585 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 21 Apr 2016 23:59:19 +0000 Subject: [PATCH] Don't gc protected symbols. llvm-svn: 267081 --- lld/ELF/MarkLive.cpp | 2 +- lld/test/ELF/gc-sections-protected.s | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/gc-sections-protected.s diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 155fe3f..cbc5fd2 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -116,7 +116,7 @@ template void elf::markLive(SymbolTable *Symtab) { 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); } } diff --git a/lld/test/ELF/gc-sections-protected.s b/lld/test/ELF/gc-sections-protected.s new file mode 100644 index 0000000..9f1efed --- /dev/null +++ b/lld/test/ELF/gc-sections-protected.s @@ -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 -- 2.7.4