[lld] r258948 - Handle local symbols in discarded sections.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 09:09:38 PST 2016
Author: rafael
Date: Wed Jan 27 11:09:37 2016
New Revision: 258948
URL: http://llvm.org/viewvc/llvm-project?rev=258948&view=rev
Log:
Handle local symbols in discarded sections.
We were reserving space for them but never writing them out.
Added:
lld/trunk/test/ELF/gc-sections-local-sym.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=258948&r1=258947&r2=258948&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Jan 27 11:09:37 2016
@@ -397,6 +397,11 @@ template <class ELFT> void Writer<ELFT>:
StringRef SymName = *SymNameOrErr;
if (!shouldKeepInSymtab<ELFT>(*F, SymName, Sym))
continue;
+ if (Sym.st_shndx != SHN_ABS) {
+ InputSectionBase<ELFT> *Section = F->getSection(Sym);
+ if (!Section->isLive())
+ continue;
+ }
Out<ELFT>::SymTab->addLocalSymbol(SymName);
}
}
Added: lld/trunk/test/ELF/gc-sections-local-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-local-sym.s?rev=258948&view=auto
==============================================================================
--- lld/trunk/test/ELF/gc-sections-local-sym.s (added)
+++ lld/trunk/test/ELF/gc-sections-local-sym.s Wed Jan 27 11:09:37 2016
@@ -0,0 +1,46 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+// RUN: ld.lld %t -o %t2 -shared --gc-sections
+// RUN: llvm-readobj -t -s -section-data %t2 | FileCheck %s
+// REQUIRES: x86
+
+.global foo
+foo:
+
+.section bar,"a"
+zed:
+
+// CHECK: Name: .strtab
+// CHECK-NEXT: Type: SHT_STRTAB
+// 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: 00666F6F 00 |.foo.|
+// CHECK-NEXT: )
+
+// CHECK: Symbols [
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: (0)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: Undefined
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: foo
+// CHECK-NEXT: Value:
+// CHECK-NEXT: Size:
+// CHECK-NEXT: Binding: Global
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other:
+// CHECK-NEXT: Section: .text
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
More information about the llvm-commits
mailing list