1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
# REQUIRES: ppc
# RUN: split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
# RUN: ld.lld -T %t/lds --shared -soname=t-ld %t.o -o %t-ld.so
# RUN: ld.lld -T %t/lds %t.o -o %t-ldtole
# RUN: llvm-readelf -r %t-ld.so | FileCheck %s --check-prefix=LD-RELOC
# RUN: llvm-readelf -s %t-ld.so | FileCheck %s --check-prefix=LD-SYM
# RUN: llvm-readelf -x .got %t-ld.so | FileCheck %s --check-prefix=LD-GOT
# RUN: llvm-objdump -d --no-show-raw-insn %t-ld.so | FileCheck %s --check-prefix=LD
# RUN: llvm-readelf -r %t-ldtole | FileCheck %s --check-prefix=LDTOLE-RELOC
# RUN: llvm-readelf -s %t-ldtole | FileCheck %s --check-prefix=LDTOLE-SYM
# RUN: llvm-readelf -x .got %t-ldtole 2>&1 | FileCheck %s --check-prefix=LDTOLE-GOT
# RUN: llvm-objdump -d --no-show-raw-insn %t-ldtole | FileCheck %s --check-prefix=LDTOLE
## This test checks the Local Dynamic PC Relative TLS implementation for lld.
## LD - Local Dynamic with no relaxation possible
## LDTOLE - Local Dynamic relaxed to Local Exec
# LD-RELOC: Relocation section '.rela.dyn' at offset 0x10080 contains 1 entries:
# LD-RELOC: 0000000001004178 0000000000000044 R_PPC64_DTPMOD64 0
# LD-SYM: Symbol table '.symtab' contains 11 entries:
# LD-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 13 x
# LD-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 13 y
# LD-GOT: section '.got':
# LD-GOT-NEXT: 0x01004170 70c10001 00000000 00000000 00000000
# LD-GOT-NEXT: 0x01004180 00000000 00000000
# LDTOLE-RELOC: There are no relocations in this file.
# LDTOLE-SYM: Symbol table '.symtab' contains 9 entries:
# LDTOLE-SYM: 0000000000000000 0 TLS LOCAL DEFAULT 6 x
# LDTOLE-SYM: 0000000000000004 0 TLS LOCAL DEFAULT 6 y
# LDTOLE-GOT: section '.got':
# LDTOLE-GOT-NEXT: 0x01004020 20c00001 00000000
//--- lds
SECTIONS {
.text_addr 0x1001000 : { *(.text_addr) }
.text_val 0x1002000 : { *(.text_val) }
.text_twoval 0x1003000 : { *(.text_twoval) }
.text_incrval 0x1004000 : { *(.text_incrval) }
}
//--- asm
# LD-LABEL: <LDAddr>:
# LD: paddi 3, 0, 12660, 1
# LD-NEXT: bl 0x1001020
# LD-NEXT: paddi 3, 3, -32768, 0
# LD-NEXT: blr
# LDTOLE-LABEL: <LDAddr>:
# LDTOLE: paddi 3, 13, 4096, 0
# LDTOLE-NEXT: nop
# LDTOLE-NEXT: paddi 3, 3, -32768, 0
# LDTOLE-NEXT: blr
.section .text_addr, "ax", %progbits
LDAddr:
## TODO: Adding a reference to .TOC. since LLD doesn't gracefully handle the
## case where we define a .got section but have no references to the toc base
## yet.
addis 2, 12, .TOC.-LDAddr@ha
paddi 3, 0, x@got@tlsld@pcrel, 1
bl __tls_get_addr@notoc(x@tlsld)
paddi 3, 3, x@dtprel, 0
blr
# LD-LABEL: <LDVal>:
# LD: paddi 3, 0, 8568, 1
# LD-NEXT: bl 0x1001020
# LD-NEXT: paddi 3, 3, -32768, 0
# LD-NEXT: lwz 3, 0(3)
# LD-NEXT: blr
# LDTOLE-LABEL: <LDVal>:
# LDTOLE: paddi 3, 13, 4096, 0
# LDTOLE-NEXT: nop
# LDTOLE-NEXT: paddi 3, 3, -32768, 0
# LDTOLE-NEXT: lwz 3, 0(3)
# LDTOLE-NEXT: blr
.section .text_val, "ax", %progbits
LDVal:
paddi 3, 0, x@got@tlsld@pcrel, 1
bl __tls_get_addr@notoc(x@tlsld)
paddi 3, 3, x@dtprel, 0
lwz 3, 0(3)
blr
# LD-LABEL: <LDTwoVal>:
# LD: paddi 3, 0, 4472, 1
# LD-NEXT: bl 0x1001020
# LD-NEXT: paddi 3, 3, -32768, 0
# LD-NEXT: lwz 2, 0(3)
# LD-NEXT: paddi 3, 3, -32764, 0
# LD-NEXT: lwz 3, 0(3)
# LD-NEXT: blr
# LDTOLE-LABEL: <LDTwoVal>:
# LDTOLE: paddi 3, 13, 4096, 0
# LDTOLE-NEXT: nop
# LDTOLE-NEXT: paddi 3, 3, -32768, 0
# LDTOLE-NEXT: lwz 2, 0(3)
# LDTOLE-NEXT: paddi 3, 3, -32764, 0
# LDTOLE-NEXT: lwz 3, 0(3)
# LDTOLE-NEXT: blr
.section .text_twoval, "ax", %progbits
LDTwoVal:
paddi 3, 0, x@got@tlsld@pcrel, 1
bl __tls_get_addr@notoc(x@tlsld)
paddi 3, 3, x@dtprel, 0
lwz 2, 0(3)
paddi 3, 3, y@dtprel, 0
lwz 3, 0(3)
blr
# LD-LABEL: <LDIncrementVal>:
# LD: paddi 3, 0, 376, 1
# LD-NEXT: bl 0x1001020
# LD-NEXT: paddi 9, 3, -32764, 0
# LD-NEXT: lwz 4, 0(9)
# LD-NEXT: stw 5, 0(9)
# LD-NEXT: blr
# LDTOLE-LABEL: <LDIncrementVal>:
# LDTOLE: paddi 3, 13, 4096, 0
# LDTOLE-NEXT: nop
# LDTOLE-NEXT: paddi 9, 3, -32764, 0
# LDTOLE-NEXT: lwz 4, 0(9)
# LDTOLE-NEXT: stw 5, 0(9)
# LDTOLE-NEXT: blr
.section .text_incrval, "ax", %progbits
LDIncrementVal:
paddi 3, 0, y@got@tlsld@pcrel, 1
bl __tls_get_addr@notoc(y@tlsld)
paddi 9, 3, y@dtprel, 0
lwz 4, 0(9)
stw 5, 0(9)
blr
.section .tbss,"awT",@nobits
x:
.long 0
y:
.long 0
|