summaryrefslogtreecommitdiffstats
path: root/lld/test
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2015-12-04 11:20:13 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2015-12-04 11:20:13 +0000
commit25411f25589e9df5c2e9a960a8c6c46e9774f1e3 (patch)
tree4e9b6ccd88ceaab8bced93c2789ce50b78faf6f6 /lld/test
parent7cf324772fdeff1db07e6aea8f8f57242f7b9945 (diff)
downloadbcm5719-llvm-25411f25589e9df5c2e9a960a8c6c46e9774f1e3.tar.gz
bcm5719-llvm-25411f25589e9df5c2e9a960a8c6c46e9774f1e3.zip
[ELF] - Implemented @tlsgd optimization (GD->IE case, x64).
"Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5 x86-x64 linker optimizations, http://www.akkadia.org/drepper/tls.pdf) shows how GD can be optimized to IE. This patch implements the optimization. Differential revision: http://reviews.llvm.org/D15000 llvm-svn: 254713
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/ELF/Inputs/tls-opt-gdie.s20
-rw-r--r--lld/test/ELF/tls-opt-gdie.s55
2 files changed, 75 insertions, 0 deletions
diff --git a/lld/test/ELF/Inputs/tls-opt-gdie.s b/lld/test/ELF/Inputs/tls-opt-gdie.s
new file mode 100644
index 00000000000..361578f2140
--- /dev/null
+++ b/lld/test/ELF/Inputs/tls-opt-gdie.s
@@ -0,0 +1,20 @@
+.type tlsshared0,@object
+.section .tbss,"awT",@nobits
+.globl tlsshared0
+.align 4
+tlsshared0:
+ .long 0
+ .size tlsshared0, 4
+
+.type tlsshared1,@object
+.globl tlsshared1
+.align 4
+tlsshared1:
+ .long 0
+ .size tlsshared1, 4
+
+.text
+.globl __tls_get_addr
+.align 16, 0x90
+.type __tls_get_addr,@function
+__tls_get_addr:
diff --git a/lld/test/ELF/tls-opt-gdie.s b/lld/test/ELF/tls-opt-gdie.s
new file mode 100644
index 00000000000..2b59ed78759
--- /dev/null
+++ b/lld/test/ELF/tls-opt-gdie.s
@@ -0,0 +1,55 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-opt-gdie.s -o %tso.o
+// RUN: ld.lld -shared %tso.o -o %t.so
+// RUN: ld.lld %t.o %t.so -o %t1
+// RUN: llvm-readobj -s -r %t1 | FileCheck --check-prefix=RELOC %s
+// RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
+
+//RELOC: Section {
+//RELOC: Index: 9
+//RELOC-NEXT: Name: .got
+//RELOC-NEXT: Type: SHT_PROGBITS
+//RELOC-NEXT: Flags [
+//RELOC-NEXT: SHF_ALLOC
+//RELOC-NEXT: SHF_WRITE
+//RELOC-NEXT: ]
+//RELOC-NEXT: Address: 0x120E0
+//RELOC-NEXT: Offset: 0x20E0
+//RELOC-NEXT: Size: 16
+//RELOC-NEXT: Link: 0
+//RELOC-NEXT: Info: 0
+//RELOC-NEXT: AddressAlignment: 8
+//RELOC-NEXT: EntrySize: 0
+//RELOC-NEXT: }
+//RELOC: Relocations [
+//RELOC-NEXT: Section (4) .rela.dyn {
+//RELOC-NEXT: 0x120E0 R_X86_64_TPOFF64 tlsshared0 0x0
+//RELOC-NEXT: 0x120E8 R_X86_64_TPOFF64 tlsshared1 0x0
+//RELOC-NEXT: }
+//RELOC-NEXT: Section (5) .rela.plt {
+//RELOC-NEXT: 0x12108 R_X86_64_JUMP_SLOT __tls_get_addr 0x0
+//RELOC-NEXT: }
+//RELOC-NEXT: ]
+
+//0x11009 + (4304 + 7) = 0x120E0
+//0x11019 + (4296 + 7) = 0x120E8
+// DISASM: Disassembly of section .text:
+// DISASM-NEXT: _start:
+// DISASM-NEXT: 11000: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
+// DISASM-NEXT: 11009: 48 03 05 d0 10 00 00 addq 4304(%rip), %rax
+// DISASM-NEXT: 11010: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax
+// DISASM-NEXT: 11019: 48 03 05 c8 10 00 00 addq 4296(%rip), %rax
+
+.section .text
+.globl _start
+_start:
+ .byte 0x66
+ leaq tlsshared0@tlsgd(%rip),%rdi
+ .word 0x6666
+ rex64
+ call __tls_get_addr@plt
+ .byte 0x66
+ leaq tlsshared1@tlsgd(%rip),%rdi
+ .word 0x6666
+ rex64
+ call __tls_get_addr@plt
OpenPOWER on IntegriCloud