xref: /llvm-project/lld/test/ELF/x86-64-tls-pie.s (revision c5e35986d8064775182b03a7e1a7e02f1cf7e4a9)
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-cloudabi %s -o %t1.o
3# RUN: ld.lld -pie %t1.o -o %t
4# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOCS %s
5# RUN: llvm-objdump -d --no-show-raw-insn --no-print-imm-hex --no-leading-addr %t1.o | FileCheck --check-prefix=DIS %s
6
7# Bug 27174: R_X86_64_TPOFF32 and R_X86_64_GOTTPOFF relocations should
8# be eliminated when building a PIE executable, as the static TLS layout
9# is fixed.
10#
11# RELOCS:      Relocations [
12# RELOCS-NEXT: ]
13#
14# DIS: <_start>:
15# DIS-NEXT:                movq    %fs:0, %rax
16# DIS-NEXT:                movl    $3, (%rax)
17# DIS-NEXT:                movq    %fs:0, %rdx
18# DIS-NEXT:                movq    (%rip), %rcx
19# DIS-NEXT:                movl    $3, (%rdx,%rcx)
20# DIS-NEXT:                movabsq 0, %rax
21
22	.globl	_start
23_start:
24	movq	%fs:0, %rax
25	movl	$3, i@TPOFF(%rax)
26
27	movq	%fs:0, %rdx
28	movq	i@GOTTPOFF(%rip), %rcx
29	movl	$3, (%rdx,%rcx)
30
31	# This additionally tests support for R_X86_64_TPOFF64 relocations.
32	movabs  i@TPOFF, %rax
33
34	.section	.tbss.i,"awT",@nobits
35	.globl	i
36i:
37	.long	0
38	.size	i, 4
39