[llvm] r239045 - Omit unused section symbols from the symbol table.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 4 08:33:30 PDT 2015
Author: rafael
Date: Thu Jun 4 10:33:30 2015
New Revision: 239045
URL: http://llvm.org/viewvc/llvm-project?rev=239045&view=rev
Log:
Omit unused section symbols from the symbol table.
Section symbols exist as an optimization: instead of having multiple relocations
point to different symbols, many of them can point to a single section symbol.
When that optimization is unused, a section symbol is also unused and adds no
extra information to the object file.
This saves a bit of space on the object files and makes the output of
llvm-objdump -t easier to read and consequently some tests get quite a bit
simpler.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ARM/arm-elf-symver.s
llvm/trunk/test/MC/ELF/alias.s
llvm/trunk/test/MC/ELF/basic-elf-32.s
llvm/trunk/test/MC/ELF/basic-elf-64.s
llvm/trunk/test/MC/ELF/comdat-dup-group-name.s
llvm/trunk/test/MC/ELF/comdat.s
llvm/trunk/test/MC/ELF/empty.s
llvm/trunk/test/MC/ELF/many-sections-2.s
llvm/trunk/test/MC/ELF/many-sections.s
llvm/trunk/test/MC/ELF/noexec.s
llvm/trunk/test/MC/ELF/reloc-same-name-section.s
llvm/trunk/test/MC/ELF/section-sym.s
llvm/trunk/test/MC/ELF/symver.s
llvm/trunk/test/MC/ELF/undef.s
llvm/trunk/test/MC/ELF/weakref.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Jun 4 10:33:30 2015
@@ -688,6 +688,8 @@ void ELFObjectWriter::RecordRelocation(M
auto *ELFSec = cast_or_null<MCSectionELF>(SecA);
const auto *SectionSymbol =
ELFSec ? cast<MCSymbolELF>(ELFSec->getBeginSymbol()) : nullptr;
+ if (SectionSymbol)
+ SectionSymbol->setUsedInReloc();
ELFRelocationEntry Rec(FixupOffset, SectionSymbol, Type, Addend);
Relocations[&FixupSection].push_back(Rec);
return;
@@ -733,12 +735,12 @@ bool ELFObjectWriter::isInSymtab(const M
if (Symbol.isUndefined() && !Symbol.isBindingSet())
return false;
- if (Symbol.getType() == ELF::STT_SECTION)
- return true;
-
if (Symbol.isTemporary())
return false;
+ if (Symbol.getType() == ELF::STT_SECTION)
+ return false;
+
return true;
}
Modified: llvm/trunk/test/MC/ARM/arm-elf-symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/arm-elf-symver.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/arm-elf-symver.s (original)
+++ llvm/trunk/test/MC/ARM/arm-elf-symver.s Thu Jun 4 10:33:30 2015
@@ -87,24 +87,6 @@ global1:
@ CHECK-NEXT: Section: .text
@ CHECK-NEXT: }
@ CHECK-NEXT: Symbol {
-@ CHECK-NEXT: Name: (0)
-@ CHECK-NEXT: Value: 0x0
-@ CHECK-NEXT: Size: 0
-@ CHECK-NEXT: Binding: Local (0x0)
-@ CHECK-NEXT: Type: Section (0x3)
-@ CHECK-NEXT: Other: 0
-@ CHECK-NEXT: Section: .data
-@ CHECK-NEXT: }
-@ CHECK-NEXT: Symbol {
-@ CHECK-NEXT: Name: (0)
-@ CHECK-NEXT: Value: 0x0
-@ CHECK-NEXT: Size: 0
-@ CHECK-NEXT: Binding: Local (0x0)
-@ CHECK-NEXT: Type: Section (0x3)
-@ CHECK-NEXT: Other: 0
-@ CHECK-NEXT: Section: .bss
-@ CHECK-NEXT: }
-@ CHECK-NEXT: Symbol {
@ CHECK-NEXT: Name: bar2 at zed
@ CHECK-NEXT: Value: 0x0
@ CHECK-NEXT: Size: 0
Modified: llvm/trunk/test/MC/ELF/alias.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/alias.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/alias.s (original)
+++ llvm/trunk/test/MC/ELF/alias.s Thu Jun 4 10:33:30 2015
@@ -111,14 +111,6 @@ leaq .Llocal1(%rip), %rdi
// CHECK-NOT: Symbol {
// CHECK: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NOT: Symbol {
-// CHECK: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NOT: Symbol {
-// CHECK: }
-// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar2
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
Modified: llvm/trunk/test/MC/ELF/basic-elf-32.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/basic-elf-32.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/basic-elf-32.s (original)
+++ llvm/trunk/test/MC/ELF/basic-elf-32.s Thu Jun 4 10:33:30 2015
@@ -54,20 +54,6 @@ main:
// CHECK: ]
// CHECK: Symbols [
-// CHECK: Symbol {
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: }
-
-// CHECK: Symbol {
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: }
-
-// CHECK: Symbol {
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: }
// CHECK: Symbol {
// CHECK: Name: main
Modified: llvm/trunk/test/MC/ELF/basic-elf-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/basic-elf-64.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/basic-elf-64.s (original)
+++ llvm/trunk/test/MC/ELF/basic-elf-64.s Thu Jun 4 10:33:30 2015
@@ -58,16 +58,6 @@ main:
// CHECK: Type: Section
// CHECK: Symbol {
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: }
-
-// CHECK: Symbol {
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: }
-
-// CHECK: Symbol {
// CHECK: Name: main
// CHECK: Binding: Global
// CHECK: Type: Function
Modified: llvm/trunk/test/MC/ELF/comdat-dup-group-name.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comdat-dup-group-name.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/comdat-dup-group-name.s (original)
+++ llvm/trunk/test/MC/ELF/comdat-dup-group-name.s Thu Jun 4 10:33:30 2015
@@ -24,10 +24,6 @@
// CHECK-NOT: }
// CHECK: Section: .group (0x7)
-// CHECK: Section: .foo (0x6)
-// CHECK: Section: .foo (0x8)
-
-
.section .foo,"axG", at progbits,f1,comdat
nop
Modified: llvm/trunk/test/MC/ELF/comdat.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comdat.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/comdat.s (original)
+++ llvm/trunk/test/MC/ELF/comdat.s Thu Jun 4 10:33:30 2015
@@ -46,7 +46,7 @@
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 12
// CHECK-NEXT: Link:
-// CHECK-NEXT: Info: 10
+// CHECK-NEXT: Info: 3
// CHECK-NEXT: AddressAlignment: 4
// CHECK-NEXT: EntrySize: 4
// CHECK-NEXT: SectionData (
Modified: llvm/trunk/test/MC/ELF/empty.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/empty.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/empty.s (original)
+++ llvm/trunk/test/MC/ELF/empty.s Thu Jun 4 10:33:30 2015
@@ -78,9 +78,9 @@
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x0
// CHECK-NEXT: Offset:
-// CHECK-NEXT: Size: 96
+// CHECK-NEXT: Size: 24
// CHECK-NEXT: Link:
-// CHECK-NEXT: Info: 4
+// CHECK-NEXT: Info: 1
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
// CHECK-NEXT: }
Modified: llvm/trunk/test/MC/ELF/many-sections-2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/many-sections-2.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/many-sections-2.s (original)
+++ llvm/trunk/test/MC/ELF/many-sections-2.s Thu Jun 4 10:33:30 2015
@@ -130,3 +130,4 @@ gen_sections4 m
a:
b = a + 1
+.long dm
Modified: llvm/trunk/test/MC/ELF/many-sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/many-sections.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/many-sections.s (original)
+++ llvm/trunk/test/MC/ELF/many-sections.s Thu Jun 4 10:33:30 2015
@@ -106,3 +106,4 @@ gen_sections8 l
.section foo
.section bar
.section zed
+.long zed
Modified: llvm/trunk/test/MC/ELF/noexec.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/noexec.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/noexec.s (original)
+++ llvm/trunk/test/MC/ELF/noexec.s Thu Jun 4 10:33:30 2015
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -no-exec-stack -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t | FileCheck %s
+// RUN: llvm-mc -no-exec-stack -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s | FileCheck %s
// CHECK: Section {
// CHECK: Index:
@@ -14,13 +14,3 @@
// CHECK-NEXT: AddressAlignment: 1
// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: }
-
-// CHECK: Symbol {
-// CHECK: Name: (0)
-// CHECK: Value: 0x0
-// CHECK: Size: 0
-// CHECK: Binding: Local
-// CHECK: Type: Section
-// CHECK: Other: 0
-// CHECK: Section: .note.GNU-stack
-// CHECK-NEXT: }
Modified: llvm/trunk/test/MC/ELF/reloc-same-name-section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/reloc-same-name-section.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/reloc-same-name-section.s (original)
+++ llvm/trunk/test/MC/ELF/reloc-same-name-section.s Thu Jun 4 10:33:30 2015
@@ -7,13 +7,13 @@
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset:
// CHECK-NEXT: Type:
-// CHECK-NEXT: Symbol: .foo (7)
+// CHECK-NEXT: Symbol: .foo (4)
// CHECK-NEXT: Addend:
// CHECK-NEXT: }
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset:
// CHECK-NEXT: Type:
-// CHECK-NEXT: Symbol: .foo (8)
+// CHECK-NEXT: Symbol: .foo (5)
// CHECK-NEXT: Addend:
// CHECK-NEXT: }
// CHECK-NEXT: }
Modified: llvm/trunk/test/MC/ELF/section-sym.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section-sym.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section-sym.s (original)
+++ llvm/trunk/test/MC/ELF/section-sym.s Thu Jun 4 10:33:30 2015
@@ -40,14 +40,54 @@
// CHECK-NEXT: EntrySize: 0
// CHECK-NEXT: }
-// The relocation points to symbol 6
+// The relocation points to symbol 3
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .relabar {
// CHECK-NEXT: Relocation {
// CHECK-NEXT: Offset: 0x0
// CHECK-NEXT: Type: R_X86_64_32 (10)
-// CHECK-NEXT: Symbol: foo (6)
+// CHECK-NEXT: Symbol: foo (3)
// CHECK-NEXT: Addend: 0x0
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ]
+
+// Symbol 3 is section 6
+// CHECK: Symbols [
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: (0)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: Undefined (0x0)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: f1 (57)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .group (0x5)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: f2 (54)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: None (0x0)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .group (0x7)
+// CHECK-NEXT: }
+// CHECK-NEXT: Symbol {
+// CHECK-NEXT: Name: (0)
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Local (0x0)
+// CHECK-NEXT: Type: Section (0x3)
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: foo (0x6)
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
Modified: llvm/trunk/test/MC/ELF/symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/symver.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/symver.s (original)
+++ llvm/trunk/test/MC/ELF/symver.s Thu Jun 4 10:33:30 2015
@@ -86,24 +86,6 @@ global1:
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .bss
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar2 at zed
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
Modified: llvm/trunk/test/MC/ELF/undef.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/undef.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/undef.s (original)
+++ llvm/trunk/test/MC/ELF/undef.s Thu Jun 4 10:33:30 2015
@@ -42,42 +42,6 @@ test2_b = undef + 1
// CHECK-NEXT: Section: .rodata.str1.1
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .text
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .bss
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .rodata.str1.1
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: .Lsym1
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
Modified: llvm/trunk/test/MC/ELF/weakref.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/weakref.s?rev=239045&r1=239044&r2=239045&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/weakref.s (original)
+++ llvm/trunk/test/MC/ELF/weakref.s Thu Jun 4 10:33:30 2015
@@ -125,24 +125,6 @@ bar15:
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .data
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: (0)
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Local
-// CHECK-NEXT: Type: Section
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: .bss
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar10
// CHECK-NEXT: Value: 0x28
// CHECK-NEXT: Size: 0
More information about the llvm-commits
mailing list