1// REQUIRES: ppc
2
3// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
5// RUN: ld.lld  %t.o -o %t
6// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s
7// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
8
9// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
10// RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
11// RUN: ld.lld  %t.o -o %t
12// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s
13// RUN: llvm-readelf -r %t | FileCheck --check-prefix=OutputRelocs %s
14
15	.text
16	.abiversion 2
17	.globl	_start                    # -- Begin function _start
18	.p2align	4
19	.type	_start,@function
20_start:                                   # @_start
21.Lfunc_begin0:
22.Lfunc_gep0:
23	addis 2, 12, .TOC.-.Lfunc_gep0@ha
24	addi 2, 2, .TOC.-.Lfunc_gep0@l
25.Lfunc_lep0:
26	.localentry	_start, .Lfunc_lep0-.Lfunc_gep0
27# %bb.0:                                # %entry
28	mflr 0
29	std 31, -8(1)
30	std 0, 16(1)
31	stdu 1, -64(1)
32	mr 31, 1
33	std 30, 48(31)                  # 8-byte Folded Spill
34	li 3, 0
35	stw 3, 44(31)
36	addis 3, 2, a@got@tlsld@ha
37	addi 3, 3, a@got@tlsld@l
38	bl __tls_get_addr(a@tlsld)
39	nop
40	addis 3, 3, a@dtprel@ha
41	addi 3, 3, a@dtprel@l
42	lwz 30, 0(3)
43	extsw 3, 30
44	ld 30, 48(31)                   # 8-byte Folded Reload
45	addi 1, 1, 64
46	ld 0, 16(1)
47	ld 31, -8(1)
48	mtlr 0
49	blr
50	.long	0
51	.quad	0
52.Lfunc_end0:
53	.size	_start, .Lfunc_end0-.Lfunc_begin0
54                                        # -- End function
55
56	.type	a,@object               # @a
57	.section	.tdata,"awT",@progbits
58	.p2align	2
59a:
60	.long	2                       # 0x2
61	.size	a, 4
62
63// Verify that the input has local-dynamic tls relocation types
64// InputRelocs:  Relocation section '.rela.text'
65// InputRelocs: R_PPC64_GOT_TLSLD16_HA  {{0+}}  a + 0
66// InputRelocs: R_PPC64_GOT_TLSLD16_LO  {{0+}}  a + 0
67// InputRelocs: R_PPC64_TLSLD           {{0+}}  a + 0
68
69// Verify that the local-dynamic sequence is relaxed to local exec.
70// Dis: <_start>:
71// Dis: nop
72// Dis: addis 3, 13, 0
73// Dis: nop
74// Dis: addi 3, 3, 4096
75
76// #ha(a@dtprel) --> (0x0 -0x8000 + 0x8000) >> 16 = 0
77// #lo(a@dtprel) --> (0x0 -0x8000) = -0x8000 = -32768
78// Dis: addis 3, 3, 0
79// Dis: addi 3, 3, -32768
80
81// Verify that no local-dynamic relocations exist for the dynamic linker.
82// OutputRelocs-NOT: R_PPC64_DTPMOD64
83