mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
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. llvm-svn: 239045
This commit is contained in:
parent
5b17e7f4ee
commit
e4278af625
@ -688,6 +688,8 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
|
||||
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 MCAsmLayout &Layout,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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@zed
|
||||
@ CHECK-NEXT: Value: 0x0
|
||||
@ CHECK-NEXT: Size: 0
|
||||
|
@ -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
|
||||
|
@ -54,20 +54,6 @@ main: # @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
|
||||
|
@ -57,16 +57,6 @@ main: # @main
|
||||
// CHECK: Binding: Local
|
||||
// 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
|
||||
|
@ -24,10 +24,6 @@
|
||||
// CHECK-NOT: }
|
||||
// CHECK: Section: .group (0x7)
|
||||
|
||||
// CHECK: Section: .foo (0x6)
|
||||
// CHECK: Section: .foo (0x8)
|
||||
|
||||
|
||||
.section .foo,"axG",@progbits,f1,comdat
|
||||
nop
|
||||
|
||||
|
@ -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 (
|
||||
|
@ -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: }
|
||||
|
@ -130,3 +130,4 @@ gen_sections4 m
|
||||
|
||||
a:
|
||||
b = a + 1
|
||||
.long dm
|
||||
|
@ -106,3 +106,4 @@ gen_sections8 l
|
||||
.section foo
|
||||
.section bar
|
||||
.section zed
|
||||
.long zed
|
||||
|
@ -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: }
|
||||
|
@ -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: }
|
||||
|
@ -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: ]
|
||||
|
@ -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@zed
|
||||
// CHECK-NEXT: Value: 0x0
|
||||
// CHECK-NEXT: Size: 0
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user