2016-04-05 06:29:24 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy-alias.s -o %t2.o
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv -shared %t2.o -o %t.so
|
|
|
|
// RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t3
|
2016-04-05 06:29:24 +08:00
|
|
|
// RUN: llvm-readobj --dyn-symbols -r --expand-relocs %t3 | FileCheck %s
|
2017-11-29 04:13:12 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv --gc-sections %t.o %t.so -o %t3
|
|
|
|
// RUN: llvm-readobj --dyn-symbols -r --expand-relocs %t3 | FileCheck %s
|
2016-04-05 06:29:24 +08:00
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
movl $5, a1
|
|
|
|
movl $5, b1
|
|
|
|
movl $5, b2
|
|
|
|
|
|
|
|
// CHECK: .rela.dyn {
|
|
|
|
// CHECK-NEXT: Relocation {
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Type: R_X86_64_COPY
|
|
|
|
// CHECK-NEXT: Symbol: a1
|
|
|
|
// CHECK-NEXT: Addend: 0x0
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Relocation {
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Type: R_X86_64_COPY
|
|
|
|
// CHECK-NEXT: Symbol: b1
|
|
|
|
// CHECK-NEXT: Addend: 0x0
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
|
|
|
// CHECK: Name: a1
|
|
|
|
// CHECK-NEXT: Value: [[A:.*]]
|
|
|
|
// CHECK-NEXT: Size: 1
|
|
|
|
// CHECK-NEXT: Binding: Global (0x1)
|
|
|
|
// CHECK-NEXT: Type: Object (0x1)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss (0x7)
|
|
|
|
|
|
|
|
// CHECK: Name: b1
|
|
|
|
// CHECK-NEXT: Value: [[B:.*]]
|
|
|
|
// CHECK-NEXT: Size: 1
|
2016-04-26 21:50:46 +08:00
|
|
|
// CHECK-NEXT: Binding: Global
|
2016-04-05 06:29:24 +08:00
|
|
|
// CHECK-NEXT: Type: Object (0x1)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
|
|
|
|
// CHECK: Name: b2
|
|
|
|
// CHECK-NEXT: Value: [[B]]
|
|
|
|
// CHECK-NEXT: Size: 1
|
2016-04-26 21:50:46 +08:00
|
|
|
// CHECK-NEXT: Binding: Global
|
2016-04-05 06:29:24 +08:00
|
|
|
// CHECK-NEXT: Type: Object (0x1)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
|
|
|
|
// CHECK: Name: a2
|
|
|
|
// CHECK-NEXT: Value: [[A]]
|
|
|
|
// CHECK-NEXT: Size: 1
|
ELF: New symbol table design.
This patch implements a new design for the symbol table that stores
SymbolBodies within a memory region of the Symbol object. Symbols are mutated
by constructing SymbolBodies in place over existing SymbolBodies, rather
than by mutating pointers. As mentioned in the initial proposal [1], this
memory layout helps reduce the cache miss rate by improving memory locality.
Performance numbers:
old(s) new(s)
Without debug info:
chrome 7.178 6.432 (-11.5%)
LLVMgold.so 0.505 0.502 (-0.5%)
clang 0.954 0.827 (-15.4%)
llvm-as 0.052 0.045 (-15.5%)
With debug info:
scylla 5.695 5.613 (-1.5%)
clang 14.396 14.143 (-1.8%)
Performance counter results show that the fewer required indirections is
indeed the cause of the improved performance. For example, when linking
chrome, stalled cycles decreases from 14,556,444,002 to 12,959,238,310, and
instructions per cycle increases from 0.78 to 0.83. We are also executing
many fewer instructions (15,516,401,933 down to 15,002,434,310), probably
because we spend less time allocating SymbolBodies.
The new mechanism by which symbols are added to the symbol table is by calling
add* functions on the SymbolTable.
In this patch, I handle local symbols by storing them inside "unparented"
SymbolBodies. This is suboptimal, but if we do want to try to avoid allocating
these SymbolBodies, we can probably do that separately.
I also removed a few members from the SymbolBody class that were only being
used to pass information from the input file to the symbol table.
This patch implements the new design for the ELF linker only. I intend to
prepare a similar patch for the COFF linker.
[1] http://lists.llvm.org/pipermail/llvm-dev/2016-April/098832.html
Differential Revision: http://reviews.llvm.org/D19752
llvm-svn: 268178
2016-05-01 12:55:03 +08:00
|
|
|
// CHECK-NEXT: Binding: Weak
|
2016-04-05 06:29:24 +08:00
|
|
|
// CHECK-NEXT: Type: Object (0x1)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
|
|
|
|
// CHECK: Name: b3
|
|
|
|
// CHECK-NEXT: Value: [[B]]
|
|
|
|
// CHECK-NEXT: Size: 1
|
2017-11-28 09:04:51 +08:00
|
|
|
// CHECK-NEXT: Binding: Global
|
2016-04-05 06:29:24 +08:00
|
|
|
// CHECK-NEXT: Type: Object (0x1)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss
|