1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o 3# RUN: echo '.tbss; .globl b; b:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o 4# RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so 5 6# RUN: ld.lld -shared %t.o %t1.o -o %t.so 7# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=GD-REL %s 8# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s 9 10# RUN: ld.lld %t.o %t1.o -o %t 11# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s 12# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s 13 14# RUN: ld.lld %t.o %t1.so -o %t 15# RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s 16# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s 17 18# GD-REL: .rela.dyn { 19# GD-REL-NEXT: 0x2380 R_X86_64_TLSDESC a 0x0 20# GD-REL-NEXT: 0x2390 R_X86_64_TLSDESC b 0x0 21# GD-REL-NEXT: } 22 23# 0x2380-0x12cf = 4273 24# GD: leaq 4273(%rip), %rax 25# GD-NEXT: 12cf: callq *(%rax) 26# GD-NEXT: movl %fs:(%rax), %eax 27 28# 0x2390-0x12db = 4277 29# GD-NEXT: leaq 4277(%rip), %rax 30# GD-NEXT: 12db: callq *(%rax) 31# GD-NEXT: movl %fs:(%rax), %eax 32 33# NOREL: no relocations 34 35## offset(a) = -4 36# LE: movq $-4, %rax 37# LE-NEXT: nop 38# LE-NEXT: movl %fs:(%rax), %eax 39## offset(b) = 0 40# LE: movq $0, %rax 41# LE-NEXT: nop 42# LE-NEXT: movl %fs:(%rax), %eax 43 44# IE-REL: .rela.dyn { 45# IE-REL-NEXT: 0x202360 R_X86_64_TPOFF64 b 0x0 46# IE-REL-NEXT: } 47 48## a is relaxed to use LE. 49# IE: movq $-4, %rax 50# IE-NEXT: nop 51# IE-NEXT: movl %fs:(%rax), %eax 52## 0x202360 - 0x20129b = 4293 53# IE-NEXT: movq 4293(%rip), %rax 54# IE-NEXT: 20129b: nop 55# IE-NEXT: movl %fs:(%rax), %eax 56 57leaq a@tlsdesc(%rip), %rax 58call *a@tlscall(%rax) 59movl %fs:(%rax), %eax 60 61leaq b@tlsdesc(%rip), %rax 62call *b@tlscall(%rax) 63movl %fs:(%rax), %eax 64 65.section .tbss 66.globl a 67.zero 8 68a: 69.zero 4 70